comparison mod_turncredentials/mod_turncredentials.lua @ 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 20346da6d241
children
comparison
equal deleted inserted replaced
3974:f14c862598a9 3977:bbfcd786cc78
42 end 42 end
43 local expires_at = os_time() + ttl; 43 local expires_at = os_time() + ttl;
44 local userpart = tostring(expires_at); 44 local userpart = tostring(expires_at);
45 local nonce = base64.encode(hmac_sha1(secret, tostring(userpart), false)); 45 local nonce = base64.encode(hmac_sha1(secret, tostring(userpart), false));
46 origin.send(st.reply(stanza):tag("services", {xmlns = "urn:xmpp:extdisco:2"}) 46 origin.send(st.reply(stanza):tag("services", {xmlns = "urn:xmpp:extdisco:2"})
47 :tag("service", { type = "stun", host = host, port = ("%d"):format(port) }):up() 47 :tag("service", { type = "stun", transport = "udp", host = host, port = ("%d"):format(port) }):up()
48 :tag("service", { type = "turn", host = host, port = ("%d"):format(port), username = userpart, password = nonce, expires = datetime(expires_at), restricted = "1" }):up() 48 :tag("service", { type = "stun", transport = "tcp", host = host, port = ("%d"):format(port) }):up()
49 :tag("service", { type = "turn", transport = "udp", host = host, port = ("%d"):format(port), username = userpart, password = nonce, expires = datetime(expires_at), restricted = "1" }):up()
50 :tag("service", { type = "turn", transport = "tcp", host = host, port = ("%d"):format(port), username = userpart, password = nonce, expires = datetime(expires_at), restricted = "1" }):up()
49 ); 51 );
50 return true; 52 return true;
51 end); 53 end);