Comparison

mod_turncredentials/mod_turncredentials.lua @ 1170:6695c3098025

mod_turncredentials: Use iq-get event, to save checking attr.type manually
author Matthew Wild <mwild1@gmail.com>
date Wed, 28 Aug 2013 10:35:56 +0100
parent 1169:0ae2c250f274
child 1171:a18effacd384
comparison
equal deleted inserted replaced
1169:0ae2c250f274 1170:6695c3098025
13 if not (secret and host) then 13 if not (secret and host) then
14 module:log("error", "turncredentials not configured"); 14 module:log("error", "turncredentials not configured");
15 return; 15 return;
16 end 16 end
17 17
18 module:hook("iq/host/urn:xmpp:extdisco:1:services", function(event) 18 module:hook("iq-get/host/urn:xmpp:extdisco:1:services", function(event)
19 local origin, stanza = event.origin, event.stanza; 19 local origin, stanza = event.origin, event.stanza;
20 if stanza.attr.type ~= "get" or stanza.tags[1].name ~= "services" or origin.type ~= "c2s" then 20 if stanza.tags[1].name ~= "services" or origin.type ~= "c2s" then
21 return; 21 return;
22 end 22 end
23 local now = os_time() + ttl; 23 local now = os_time() + ttl;
24 local userpart = tostring(now); 24 local userpart = tostring(now);
25 local nonce = base64.encode(hmac_sha1(secret, tostring(userpart), false)); 25 local nonce = base64.encode(hmac_sha1(secret, tostring(userpart), false));