From f42be7fe985da6ef9a738bf1b641dae44cd92439 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Fri, 11 May 2012 02:04:29 +0100 Subject: mod_dialback: Final sweep to get nameprep + error handling in order (hopefully) --- plugins/mod_dialback.lua | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) (limited to 'plugins/mod_dialback.lua') diff --git a/plugins/mod_dialback.lua b/plugins/mod_dialback.lua index 3d1fe0e1..e47d63ed 100644 --- a/plugins/mod_dialback.lua +++ b/plugins/mod_dialback.lua @@ -65,37 +65,30 @@ module:hook("stanza/jabber:server:dialback:result", function(event) -- he wants to be identified through dialback -- We need to check the key with the Authoritative server local attr = stanza.attr; - local to, from = attr.to, attr.from; - - origin.hosts[from] = { dialback_key = stanza[1] }; + local to, from = nameprep(attr.to), nameprep(attr.from); if not hosts[to] then -- Not a host that we serve origin.log("info", "%s tried to connect to %s, which we don't serve", from, to); origin:close("host-unknown"); return true; + elseif not from then + origin:close("improper-addressing"); end + origin.hosts[from] = { dialback_key = stanza[1] }; + dialback_requests[from.."/"..origin.streamid] = origin; -- COMPAT: ejabberd, gmail and perhaps others do not always set 'to' and 'from' -- on streams. We fill in the session's to/from here instead. if not origin.from_host then - origin.from_host = nameprep(attr.from); - if not origin.from_host then - 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."); - origin:close("invalid-from"); - end + origin.from_host = from; end if not origin.to_host then origin.to_host = nameprep(attr.to); end - if not origin.from_host or not origin.to_host then - origin.log("debug", "Improper addressing supplied, no to or from?"); - origin:close("improper-addressing"); - end - origin.log("debug", "asking %s if key %s belongs to them", from, stanza[1]); module:fire_event("route/remote", { from_host = to, to_host = from; -- cgit v1.2.3