Comparison

plugins/mod_dialback.lua @ 4846:3bc3498df0a0

Merge with Maranda
author Matthew Wild <mwild1@gmail.com>
date Fri, 11 May 2012 01:53:32 +0100
parent 4822:5ef05f32bc42
parent 4843:d91dda67647a
child 4847:7a7cc4d98faf
comparison
equal deleted inserted replaced
4834:878f75ccc4fb 4846:3bc3498df0a0
13 13
14 local log = module._log; 14 local log = module._log;
15 15
16 local st = require "util.stanza"; 16 local st = require "util.stanza";
17 local sha256_hash = require "util.hashes".sha256; 17 local sha256_hash = require "util.hashes".sha256;
18 local nameprep = require "util.encodings".stringprep.nameprep;
18 19
19 local xmlns_stream = "http://etherx.jabber.org/streams"; 20 local xmlns_stream = "http://etherx.jabber.org/streams";
20 21
21 local dialback_requests = setmetatable({}, { __mode = 'v' }); 22 local dialback_requests = setmetatable({}, { __mode = 'v' });
22 23
77 78
78 dialback_requests[from.."/"..origin.streamid] = origin; 79 dialback_requests[from.."/"..origin.streamid] = origin;
79 80
80 -- COMPAT: ejabberd, gmail and perhaps others do not always set 'to' and 'from' 81 -- COMPAT: ejabberd, gmail and perhaps others do not always set 'to' and 'from'
81 -- on streams. We fill in the session's to/from here instead. 82 -- on streams. We fill in the session's to/from here instead.
82 if not origin.from_host then origin.from_host = from; end 83 if not origin.from_host then
83 if not origin.to_host then origin.to_host = to; end 84 origin.from_host = nameprep(attr.from);
85 if not origin.from_host then
86 origin.log("debug", "We need to know where to connect but remote server blindly refuses to tell us and to comply to specs, closing connection.");
87 origin:close("invalid-from");
88 end
89 end
90 if not origin.to_host then
91 origin.to_host = nameprep(attr.to);
92 end
93
94 if not origin.from_host and not origin.to_host then
95 origin.log("debug", "Improper addressing supplied, no to or from?");
96 origin:close("improper-addressing");
97 end
84 98
85 origin.log("debug", "asking %s if key %s belongs to them", from, stanza[1]); 99 origin.log("debug", "asking %s if key %s belongs to them", from, stanza[1]);
86 module:fire_event("route/remote", { 100 module:fire_event("route/remote", {
87 from_host = to, to_host = from; 101 from_host = to, to_host = from;
88 stanza = st.stanza("db:verify", { from = to, to = from, id = origin.streamid }):text(stanza[1]); 102 stanza = st.stanza("db:verify", { from = to, to = from, id = origin.streamid }):text(stanza[1]);