Mercurial > prosody-hg
comparison plugins/mod_dialback.lua @ 4851:8e3992ae7bf5
mod_dialback: Remove a remaining usage of string.format, ick.
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Fri, 11 May 2012 14:24:05 +0100 |
| parents | f7a4920aed6b |
| children | 7a4f00168260 |
comparison
equal
deleted
inserted
replaced
| 4850:3662091d303c | 4851:8e3992ae7bf5 |
|---|---|
| 3 -- Copyright (C) 2008-2010 Waqas Hussain | 3 -- Copyright (C) 2008-2010 Waqas Hussain |
| 4 -- | 4 -- |
| 5 -- This project is MIT/X11 licensed. Please see the | 5 -- This project is MIT/X11 licensed. Please see the |
| 6 -- COPYING file in the source package for more information. | 6 -- COPYING file in the source package for more information. |
| 7 -- | 7 -- |
| 8 | |
| 9 local format = string.format; | |
| 10 | 8 |
| 11 local hosts = _G.hosts; | 9 local hosts = _G.hosts; |
| 12 local s2s_make_authenticated = require "core.s2smanager".make_authenticated; | 10 local s2s_make_authenticated = require "core.s2smanager".make_authenticated; |
| 13 | 11 |
| 14 local log = module._log; | 12 local log = module._log; |
| 26 end | 24 end |
| 27 | 25 |
| 28 function initiate_dialback(session) | 26 function initiate_dialback(session) |
| 29 -- generate dialback key | 27 -- generate dialback key |
| 30 session.dialback_key = generate_dialback(session.streamid, session.to_host, session.from_host); | 28 session.dialback_key = generate_dialback(session.streamid, session.to_host, session.from_host); |
| 31 session.sends2s(format("<db:result from='%s' to='%s'>%s</db:result>", session.from_host, session.to_host, session.dialback_key)); | 29 session.sends2s(st.stanza("db:result", { from = session.from_host, to = session.to_host }):text(session.dialback_key)); |
| 32 session.log("info", "sent dialback key on outgoing s2s stream"); | 30 session.log("info", "sent dialback key on outgoing s2s stream"); |
| 33 end | 31 end |
| 34 | 32 |
| 35 function verify_dialback(id, to, from, key) | 33 function verify_dialback(id, to, from, key) |
| 36 return key == generate_dialback(id, to, from); | 34 return key == generate_dialback(id, to, from); |
