aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2008-12-05 05:23:42 +0000
committerMatthew Wild <mwild1@gmail.com>2008-12-05 05:23:42 +0000
commit7c9f4818c3558c260b2f37df92371c1b33a3b121 (patch)
treeff8caf06849642257e1664d30d19aefa428179bb
parentffd26762181bfbbd870e91ae39ac77876f9e5382 (diff)
downloadprosody-7c9f4818c3558c260b2f37df92371c1b33a3b121.tar.gz
prosody-7c9f4818c3558c260b2f37df92371c1b33a3b121.zip
Remove an incorrect line which I didn't add, and fix the proper way. Corrects the sending of stanzas over unauthed s2sout's. Also fixes mod_dialback to send stanzas and not strings.
-rw-r--r--core/s2smanager.lua11
-rw-r--r--net/xmppclient_listener.lua5
-rw-r--r--plugins/mod_dialback.lua7
3 files changed, 14 insertions, 9 deletions
diff --git a/core/s2smanager.lua b/core/s2smanager.lua
index 09e163f0..5eb28b50 100644
--- a/core/s2smanager.lua
+++ b/core/s2smanager.lua
@@ -52,11 +52,10 @@ module "s2smanager"
local function compare_srv_priorities(a,b) return a.priority < b.priority or a.weight < b.weight; end
function send_to_host(from_host, to_host, data)
- if data.name then data = tostring(data); end
local host = hosts[from_host].s2sout[to_host];
if host then
-- We have a connection to this host already
- if host.type == "s2sout_unauthed" and (data.xmlns == "jabber:client" or data.xmlns == "jabber:server") then
+ if host.type == "s2sout_unauthed" and data.name ~= "db:verify" and ((not data.xmlns) or data.xmlns == "jabber:client" or data.xmlns == "jabber:server") then
(host.log or log)("debug", "trying to send over unauthed s2sout to "..to_host);
if not host.notopen and not host.dialback_key then
host.log("debug", "dialback had not been initiated");
@@ -64,9 +63,9 @@ function send_to_host(from_host, to_host, data)
end
-- Queue stanza until we are able to send it
- if host.sendq then t_insert(host.sendq, data);
- else host.sendq = { data }; end
- host.log("debug", "stanza queued");
+ if host.sendq then t_insert(host.sendq, tostring(data));
+ else host.sendq = { tostring(data) }; end
+ host.log("debug", "stanza [%s] queued ", data.name);
elseif host.type == "local" or host.type == "component" then
log("error", "Trying to send a stanza to ourselves??")
log("error", "Traceback: %s", get_traceback());
@@ -85,7 +84,7 @@ function send_to_host(from_host, to_host, data)
log("debug", "opening a new outgoing connection for this stanza");
local host_session = new_outgoing(from_host, to_host);
-- Store in buffer
- host_session.sendq = { data };
+ host_session.sendq = { tostring(data) };
end
end
diff --git a/net/xmppclient_listener.lua b/net/xmppclient_listener.lua
index 33dcef10..22af2de4 100644
--- a/net/xmppclient_listener.lua
+++ b/net/xmppclient_listener.lua
@@ -47,6 +47,11 @@ function stream_callbacks.error(session, error, data)
end
end
+local function handleerr(err) print("Traceback:", err, debug.traceback()); end
+function stream_callbacks.handlestanza(a, b)
+ xpcall(function () core_process_stanza(a, b) end, handleerr);
+end
+
local sessions = {};
local xmppclient = { default_port = 5222, default_mode = "*a" };
diff --git a/plugins/mod_dialback.lua b/plugins/mod_dialback.lua
index ea0f9e91..4b3a970d 100644
--- a/plugins/mod_dialback.lua
+++ b/plugins/mod_dialback.lua
@@ -24,6 +24,8 @@ local send_s2s = require "core.s2smanager".send_to_host;
local s2s_make_authenticated = require "core.s2smanager".make_authenticated;
local s2s_verify_dialback = require "core.s2smanager".verify_dialback;
+local st = require "util.stanza";
+
local log = require "util.logger".init("mod_dialback");
local xmlns_dialback = "jabber:server:dialback";
@@ -42,7 +44,7 @@ module:add_handler({"s2sin_unauthed", "s2sin"}, "verify", xmlns_dialback,
type = "invalid"
log("warn", "Asked to verify a dialback key that was incorrect. An imposter is claiming to be %s?", attr.to);
end
- log("debug", "verifyied dialback key... it is %s", type);
+ log("debug", "verified dialback key... it is %s", type);
origin.sends2s(format("<db:verify from='%s' to='%s' id='%s' type='%s'>%s</db:verify>", attr.to, attr.from, attr.id, type, stanza[1]));
end);
@@ -57,8 +59,7 @@ module:add_handler("s2sin_unauthed", "result", xmlns_dialback,
origin.dialback_key = stanza[1];
log("debug", "asking %s if key %s belongs to them", origin.from_host, origin.dialback_key);
send_s2s(origin.to_host, origin.from_host,
- format("<db:verify from='%s' to='%s' id='%s'>%s</db:verify>", origin.to_host, origin.from_host,
- origin.streamid, origin.dialback_key));
+ st.stanza("db:verify", { from = origin.to_host, to = origin.from_host, id = origin.streamid }):text(origin.dialback_key));
hosts[origin.to_host].s2sout[origin.from_host].dialback_verifying = origin;
end);