493: Undecipherable

-Blog-

-Projects-

-About me-

-RSS-

Asterisk: Conferencing Server with LUA

Dennis Guse

Asterisk is a powerful telephone server. However, its configuration via extensions.conf is a little bit annoying, if you would really like to program your dialplan (e.g., if-then-else, read a file, execute some command line program, ...). The diaplan can also be implemented using LUA: extensions.lua.

Here, is a short demo setup for a telephone conference server that is reachable via telephone number using sipgate.de and a lua-based dialplan.

The server registers at sipgate.de, who provide a telephone number for the server. All incoming calls at the server are forward to a telephone conference room.

I used this setup from Asterisk 11 until Asterisk 13 running on a FreeBSD 10.X.

sip.conf:

 1[general]
 2allowguest=no
 3alwaysauthreject=yes
 4
 5canreinvite=no
 6
 7disallow=allow
 8allow=g711
 9
10;SIPGATE This is the incoming uplink
11register => USERNAME:PASSWORD@sipgate.de/USERNAME
12
13[trunk_incoming]
14type=peer
15host=sipgate.de
16context=trunk_incoming

extensions.lua:

 1extensions = {}
 2
 3extensions.trunk_incoming = {
 4    ["_X"] = function(c, e)
 5 app.playback("beep")
 6 
 7 app.read("room", "conf-getconfno")
 8 room = channel["room"]:get()
 9 if room == nil then
10     app.playback("beepErr")
11     app.hangup()
12 end
13
14 app.verbose("Conference room " .. room .. ": " .. channel.CALLERID("num"):get() .. " entered")
15 app.playback("conf-enteringno")
16 app.sayDigits(room, "f")
17 
18 app.confBridge(room)
19    end;
20}

NOTE: Asterisk does not reload the extensions.lua automatically even not using core reload. After configuration changes the module must be reloaded: module reload pbxlua.so_.

NOTE: The LUA-parser in Asterisk is very nitty-gritty. Be careful about using only spaces and align the code properly.

NOTE: The traffic is not encrypted. Take care of it yourself by setting up a IPSec-tunnel!