Asterisk: Conferencing Server with LUA
Dennis GuseAsterisk 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
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
[general]
allowguest=no
alwaysauthreject=yes
canreinvite=no
disallow=allow
allow=g711
;SIPGATE This is the incoming uplink
register => USERNAME:PASSWORD@sipgate.de/USERNAME
[trunk_incoming]
type=peer
host=sipgate.de
context=trunk_incoming
extensions.lua:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
extensions = {}
extensions.trunk_incoming = {
["_X"] = function(c, e)
app.playback("beep")
app.read("room", "conf-getconfno")
room = channel["room"]:get()
if room == nil then
app.playback("beepErr")
app.hangup()
end
app.verbose("Conference room " .. room .. ": " .. channel.CALLERID("num"):get() .. " entered")
app.playback("conf-enteringno")
app.sayDigits(room, "f")
app.confBridge(room)
end;
}
NOTE: Asterisk does not reload the extensions.lua automatically even not using core reload. After configuration changes the module must be reloaded: module reload pbx_lua.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!