# HG changeset patch # User Matthew Wild # Date 1224825218 -3600 # Node ID ccebb27207414c955d50807cad15d11126da93e1 # Parent 3826ca244eb6a83d36353af1a4f330fabc20c83d working incoming s2s \o/ diff -r 3826ca244eb6 -r ccebb2720741 core/stanza_router.lua --- a/core/stanza_router.lua Fri Oct 24 03:42:26 2008 +0100 +++ b/core/stanza_router.lua Fri Oct 24 06:13:38 2008 +0100 @@ -51,6 +51,8 @@ core_handle_stanza(origin, stanza); elseif origin.type == "c2s" then core_route_stanza(origin, stanza); + elseif origin.type == "s2sin" then + core_deliver_stanza(origin, stanza); end end @@ -97,26 +99,52 @@ handle_stanza(session, stanza); end elseif origin.type == "s2sin_unauthed" then - if stanza.name == "verify" and stanza.attr.xmlns == "jabber:server:dialback" then - log("debug", "verifying dialback key..."); - local attr = stanza.attr; - print(tostring(attr.to), tostring(attr.from)) - print(tostring(origin.to_host), tostring(origin.from_host)) - -- FIXME: Grr, ejabberd breaks this one too?? it is black and white in XEP-220 example 34 - --if attr.from ~= origin.to_host then error("invalid-from"); end - local type = "invalid"; - if s2s_verify_dialback(attr.id, attr.from, attr.to, stanza[1]) then - type = "valid" + if stanza.attr.xmlns == "jabber:server:dialback" then + if stanza.name == "verify" then + -- We are being asked to verify the key, to ensure it was generated by us + log("debug", "verifying dialback key..."); + local attr = stanza.attr; + print(tostring(attr.to), tostring(attr.from)) + print(tostring(origin.to_host), tostring(origin.from_host)) + -- FIXME: Grr, ejabberd breaks this one too?? it is black and white in XEP-220 example 34 + --if attr.from ~= origin.to_host then error("invalid-from"); end + local type = "invalid"; + if s2s_verify_dialback(attr.id, attr.from, attr.to, stanza[1]) then + type = "valid" + end + origin.send(format("%s", attr.to, attr.from, attr.id, type, stanza[1])); + elseif stanza.name == "result" then + -- We need to check the key with the Authoritative server + local attr = stanza.attr; + origin.from_host = attr.from; + origin.to_host = attr.to; + origin.dialback_key = stanza[1]; + log("debug", "asking %s if key %s belongs to them", attr.from, stanza[1]); + send_s2s(attr.to, attr.from, format("%s", attr.to, attr.from, origin.streamid, stanza[1])); + hosts[attr.from].dialback_verifying = origin; end - origin.send(format("%s", attr.to, attr.from, attr.id, type, stanza[1])); end - elseif origin.type == "s2sout_unauthed" then - if stanza.name == "result" and stanza.attr.xmlns == "jabber:server:dialback" then - if stanza.attr.type == "valid" then - s2s_make_authenticated(origin); - else - -- FIXME - error("dialback failed!"); + elseif origin.type == "s2sout_unauthed" or origin.type == "s2sout" then + if stanza.attr.xmlns == "jabber:server:dialback" then + if stanza.name == "result" then + if stanza.attr.type == "valid" then + s2s_make_authenticated(origin); + else + -- FIXME + error("dialback failed!"); + end + elseif stanza.name == "verify" and origin.dialback_verifying then + local valid; + local attr = stanza.attr; + if attr.type == "valid" then + s2s_make_authenticated(origin.dialback_verifying); + valid = "valid"; + else + -- Warn the original connection that is was not verified successfully + log("warn", "dialback for "..(origin.dialback_verifying.from_host or "(unknown)").." failed"); + valid = "invalid"; + end + origin.dialback_verifying.send(format("%s", attr.from, attr.to, attr.id, valid, origin.dialback_verifying.dialback_key)); end end else @@ -225,6 +253,13 @@ stanza.attr.to = to; -- reset end +function core_deliver_stanza(origin, stanza) + local name, attr = stanza.name, stanza.attr; + if name == "message" then + + end +end + function handle_stanza_toremote(stanza) log("error", "Stanza bound for remote host, but s2s is not implemented"); end diff -r 3826ca244eb6 -r ccebb2720741 util/logger.lua --- a/util/logger.lua Fri Oct 24 03:42:26 2008 +0100 +++ b/util/logger.lua Fri Oct 24 06:13:38 2008 +0100 @@ -6,7 +6,7 @@ module "logger" function init(name) - name = nil; -- While this line is not commented, will automatically fill in file/line number info + --name = nil; -- While this line is not commented, will automatically fill in file/line number info return function (level, message, ...) if not name then local inf = debug.getinfo(3, 'Snl');