# HG changeset patch # User Philipp Hancke # Date 1377682275 -3600 # Node ID 0b6b33688b756442612e9794437cfafc7acf25ba # Parent 8ceab233121660c4033250264f7666b99b4efc41 mod_turncredentials: use smarter timestamp expiry from draft-uberti-behave-turn-rest-00 diff -r 8ceab2331216 -r 0b6b33688b75 mod_turncredentials/mod_turncredentials.lua --- a/mod_turncredentials/mod_turncredentials.lua Wed Aug 21 19:03:16 2013 +0200 +++ b/mod_turncredentials/mod_turncredentials.lua Wed Aug 28 10:31:15 2013 +0100 @@ -9,6 +9,7 @@ local secret = module:get_option("turncredentials_secret") or false; local host = module:get_option("turncredentials_host") or false -- use ip addresses here to avoid further dns lookup latency local port = module:get_option("turncredentials_port") or 3478 +local ttl = module:get_option("turncredentials_ttl") or 86400 if not (secret and host) then module:log("error", "turncredentials not configured"); return; @@ -19,12 +20,12 @@ if stanza.attr.type ~= "get" or stanza.tags[1].name ~= "services" or origin.type ~= "c2s" then return; end - local now = os_time(); + local now = os_time() + ttl; local userpart = tostring(now); local nonce = base64.encode(hmac_sha1(secret, tostring(userpart), false)); origin.send(st.reply(stanza):tag("services", {xmlns = "urn:xmpp:extdisco:1"}) :tag("service", { type = "stun", host = host, port = port }):up() - :tag("service", { type = "turn", host = host, port = port, username = userpart, password = nonce }):up() + :tag("service", { type = "turn", host = host, port = port, username = userpart, password = nonce, ttl = ttl}):up() ); return true; end);