A new module in 3.1.0, named app_lua, provides the functionality to execute Lua code and scripts in your configuration file.
The readme and the API are available at:
Lua language is small and fast, therefore fits very well in a sip proxy environment, it has a lot of extensions, so when you cannot do something with existing cfg functions, check Lua documentation. The interpreter is embedded in app_lua module, so it is executed within Kamailio context.
Inside the Lua scripts, you get access to SIP message and functions from Kamailio core and modules. I did a presentation at Amoocon 2010 showing a practical example: how to use Lua to send notifications to Twitter from your SIP server, see the slides at:
lua_dostring("sr.sl.send_reply(200, [[Lua says is ok]])");This is execution of Lua code provided within the string parameter of lua_dostring(). Also, you can execute a Lua script by providing the path in the parameter of lua_dofile():
lua_dofile("/path/to/yourscript.lua");Other options to run Lua code are provide by the new module, like to load a script at startup and execute functions from it at runtime.