Comparison

mod_turncredentials/mod_turncredentials.lua @ 3773:915c7bd5f754

mod_turncredentials: Rename variable for clarity
author Kim Alvefur <zash@zash.se>
date Mon, 23 Dec 2019 23:01:19 +0100
parent 3642:2bbf655431be
child 3774:20346da6d241
comparison
equal deleted inserted replaced
3772:22f02716819f 3773:915c7bd5f754
21 module:hook("iq-get/host/urn:xmpp:extdisco:1:services", function(event) 21 module:hook("iq-get/host/urn:xmpp:extdisco:1:services", function(event)
22 local origin, stanza = event.origin, event.stanza; 22 local origin, stanza = event.origin, event.stanza;
23 if origin.type ~= "c2s" then 23 if origin.type ~= "c2s" then
24 return; 24 return;
25 end 25 end
26 local now = os_time() + ttl; 26 local expires_at = os_time() + ttl;
27 local userpart = tostring(now); 27 local userpart = tostring(expires_at);
28 local nonce = base64.encode(hmac_sha1(secret, tostring(userpart), false)); 28 local nonce = base64.encode(hmac_sha1(secret, tostring(userpart), false));
29 origin.send(st.reply(stanza):tag("services", {xmlns = "urn:xmpp:extdisco:1"}) 29 origin.send(st.reply(stanza):tag("services", {xmlns = "urn:xmpp:extdisco:1"})
30 :tag("service", { type = "stun", host = host, port = ("%d"):format(port) }):up() 30 :tag("service", { type = "stun", host = host, port = ("%d"):format(port) }):up()
31 :tag("service", { type = "turn", host = host, port = ("%d"):format(port), username = userpart, password = nonce, ttl = ("%d"):format(ttl) }):up() 31 :tag("service", { type = "turn", host = host, port = ("%d"):format(port), username = userpart, password = nonce, ttl = ("%d"):format(ttl) }):up()
32 ); 32 );
38 module:hook("iq-get/host/urn:xmpp:extdisco:2:services", function(event) 38 module:hook("iq-get/host/urn:xmpp:extdisco:2:services", function(event)
39 local origin, stanza = event.origin, event.stanza; 39 local origin, stanza = event.origin, event.stanza;
40 if origin.type ~= "c2s" then 40 if origin.type ~= "c2s" then
41 return; 41 return;
42 end 42 end
43 local now = os_time() + ttl; 43 local expires_at = os_time() + ttl;
44 local userpart = tostring(now); 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", host = host, port = ("%d"):format(port) }):up()
48 :tag("service", { type = "turn", host = host, port = ("%d"):format(port), username = userpart, password = nonce, expires = datetime(ttl), restricted = "1" }):up() 48 :tag("service", { type = "turn", host = host, port = ("%d"):format(port), username = userpart, password = nonce, expires = datetime(ttl), restricted = "1" }):up()
49 ); 49 );