mod_turncredentials: Add 'transport' attribute
XEP-0215 recommends using 'transport' attribute and since coturn
can work in both TCP and UPD modes this patch adds one <service>
element for each combination of STUN/TURN and TCP/UDP.
--- a/mod_turncredentials/mod_turncredentials.lua Wed Apr 15 21:19:45 2020 +0100
+++ b/mod_turncredentials/mod_turncredentials.lua Thu Apr 16 17:34:53 2020 +0200
@@ -44,8 +44,10 @@
local userpart = tostring(expires_at);
local nonce = base64.encode(hmac_sha1(secret, tostring(userpart), false));
origin.send(st.reply(stanza):tag("services", {xmlns = "urn:xmpp:extdisco:2"})
- :tag("service", { type = "stun", host = host, port = ("%d"):format(port) }):up()
- :tag("service", { type = "turn", host = host, port = ("%d"):format(port), username = userpart, password = nonce, expires = datetime(expires_at), restricted = "1" }):up()
+ :tag("service", { type = "stun", transport = "udp", host = host, port = ("%d"):format(port) }):up()
+ :tag("service", { type = "stun", transport = "tcp", host = host, port = ("%d"):format(port) }):up()
+ :tag("service", { type = "turn", transport = "udp", host = host, port = ("%d"):format(port), username = userpart, password = nonce, expires = datetime(expires_at), restricted = "1" }):up()
+ :tag("service", { type = "turn", transport = "tcp", host = host, port = ("%d"):format(port), username = userpart, password = nonce, expires = datetime(expires_at), restricted = "1" }):up()
);
return true;
end);