-
Notifications
You must be signed in to change notification settings - Fork 0
/
mod_jinglerelaynodes.lua
34 lines (27 loc) · 1.39 KB
/
mod_jinglerelaynodes.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
local st = require "util.stanza";
local host = module:get_host();
local stun_ip = module:get_option('stun_ip');
local stun_port = module:get_option_number('stun_port');
local uuid = require "util.uuid";
module:add_feature('http://jabber.org/protocol/jinglenodes');
module:hook('iq-get/host/http://jabber.org/protocol/jinglenodes', function(event)
local session, stanza = event.origin, event.stanza;
local reply = st.iq({type='result', id=stanza.attr.id, from=host, to=stanza.attr.from})
reply:tag("services", {xmlns="http://jabber.org/protocol/jinglenodes"})
:tag("relay", {policy="public", address=host, protocol="tcp"}):up()
:tag("tracker", {policy="public", address=host, protocol="tcp"}):up()
:tag("stun", {policy="public", address=stun_ip, port=stun_port, protocol="tcp"}):up()
session.send(reply);
end);
module:hook('iq-get/host/http://jabber.org/protocol/jinglenodes#channel', function(event)
local session, stanza = event.origin, event.stanza;
local reply = st.iq({type='result', id=stanza.attr.id, from=host, to=stanza.attr.from})
reply:tag("channel", { id = uuid.generate(),
host = host,
localport = "35800",
remoteport = "35802",
protocol = "tcp",
expire = "60"
})
session.send(reply)
end);