Changeset

3977:bbfcd786cc78

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.
author Wiktor Kwapisiewicz <wiktor@metacode.biz>
date Thu, 16 Apr 2020 17:34:53 +0200
parents 3974:f14c862598a9
children 3978:dd8ef22d4857
files mod_turncredentials/mod_turncredentials.lua
diffstat 1 files changed, 4 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- 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);