aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2008-10-24 06:13:38 +0100
committerMatthew Wild <mwild1@gmail.com>2008-10-24 06:13:38 +0100
commit5031be1f8cb3a5a8785c07c5e4c5802913c209f6 (patch)
treeadec7557363290a3295101bdee3ca9392bd8dee0 /core
parent8fa7f063020263100d17978e2c97f9441d9db337 (diff)
downloadprosody-5031be1f8cb3a5a8785c07c5e4c5802913c209f6.tar.gz
prosody-5031be1f8cb3a5a8785c07c5e4c5802913c209f6.zip
working incoming s2s \o/
Diffstat (limited to 'core')
-rw-r--r--core/stanza_router.lua71
1 files changed, 53 insertions, 18 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