Software /
code /
prosody
Changeset
147:ccebb2720741 s2s
working incoming s2s \o/
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Fri, 24 Oct 2008 06:13:38 +0100 |
parents | 146:3826ca244eb6 |
children | 148:4c0dcd245d34 |
files | core/stanza_router.lua util/logger.lua |
diffstat | 2 files changed, 54 insertions(+), 19 deletions(-) [+] |
line wrap: on
line diff
--- 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("<db:verify from='%s' to='%s' id='%s' type='%s'>%s</db:verify>", 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("<db:verify from='%s' to='%s' id='%s'>%s</db:verify>", attr.to, attr.from, origin.streamid, stanza[1])); + hosts[attr.from].dialback_verifying = origin; end - origin.send(format("<db:verify from='%s' to='%s' id='%s' type='%s'>%s</db:verify>", 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("<db:result from='%s' to='%s' id='%s' type='%s'>%s</db:result>", 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
--- 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');