diff options
author | Matthew Wild <mwild1@gmail.com> | 2008-10-24 06:13:38 +0100 |
---|---|---|
committer | Matthew Wild <mwild1@gmail.com> | 2008-10-24 06:13:38 +0100 |
commit | 5031be1f8cb3a5a8785c07c5e4c5802913c209f6 (patch) | |
tree | adec7557363290a3295101bdee3ca9392bd8dee0 | |
parent | 8fa7f063020263100d17978e2c97f9441d9db337 (diff) | |
download | prosody-5031be1f8cb3a5a8785c07c5e4c5802913c209f6.tar.gz prosody-5031be1f8cb3a5a8785c07c5e4c5802913c209f6.zip |
working incoming s2s \o/
-rw-r--r-- | core/stanza_router.lua | 71 | ||||
-rw-r--r-- | util/logger.lua | 2 |
2 files changed, 54 insertions, 19 deletions
diff --git a/core/stanza_router.lua b/core/stanza_router.lua index 215b01a0..2399c25f 100644 --- a/core/stanza_router.lua +++ b/core/stanza_router.lua @@ -51,6 +51,8 @@ function core_process_stanza(origin, stanza) 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 @@ function core_handle_stanza(origin, stanza) 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 @@ function core_route_stanza(origin, stanza) 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 --git a/util/logger.lua b/util/logger.lua index 623ceb67..8d983605 100644 --- a/util/logger.lua +++ b/util/logger.lua @@ -6,7 +6,7 @@ local tostring = tostring; 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'); |