Skip to content

Instantly share code, notes, and snippets.

@tsudot
Created August 6, 2011 19:47
Show Gist options
  • Save tsudot/1129686 to your computer and use it in GitHub Desktop.
Save tsudot/1129686 to your computer and use it in GitHub Desktop.
Jingle Relay Nodes implementation in Prosody.
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 = "udp",
expire = "60"
})
session.send(reply)
end);
@butonic
Copy link

butonic commented May 8, 2013

Hm, two yeras have passed. Can you still recommend using this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment