aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2012-03-03 01:12:16 +0000
committerMatthew Wild <mwild1@gmail.com>2012-03-03 01:12:16 +0000
commit70d52039207bfec821b6d30046802e9615843c33 (patch)
tree8f9d31409a96454dcd8a82185d2c76e39ba810d4
parent0a43ddb0f8c91982fba926e2d2f4fe9828198e6e (diff)
parent71528cdc3726be326d6a0afb76f490b7d3c4fcc6 (diff)
downloadprosody-70d52039207bfec821b6d30046802e9615843c33.tar.gz
prosody-70d52039207bfec821b6d30046802e9615843c33.zip
Merge with Zash
-rw-r--r--core/portmanager.lua2
-rw-r--r--plugins/mod_admin_telnet.lua3
-rw-r--r--plugins/mod_dialback.lua7
-rw-r--r--plugins/s2s/mod_s2s.lua52
4 files changed, 35 insertions, 29 deletions
diff --git a/core/portmanager.lua b/core/portmanager.lua
index 353c4a89..3d6dada4 100644
--- a/core/portmanager.lua
+++ b/core/portmanager.lua
@@ -62,9 +62,9 @@ function activate_service(service_name)
local bind_interfaces = set.new(config.get("*", service_name.."_interfaces")
or config.get("*", service_name.."_interface") -- COMPAT w/pre-0.9
+ or (service_info.private and default_local_interfaces)
or config.get("*", "interfaces")
or config.get("*", "interface") -- COMPAT w/pre-0.9
- or (service_info.private and default_local_interfaces)
or service_info.default_interface -- COMPAT w/pre0.9
or default_interfaces);
diff --git a/plugins/mod_admin_telnet.lua b/plugins/mod_admin_telnet.lua
index d3f5543e..fd72787e 100644
--- a/plugins/mod_admin_telnet.lua
+++ b/plugins/mod_admin_telnet.lua
@@ -15,7 +15,8 @@ local hosts = prosody.hosts;
local console_listener = { default_port = 5582; default_mode = "*l"; interface = "127.0.0.1" };
-require "util.iterators";
+local iterators = require "util.iterators";
+local keys, values = iterators.keys, iterators.values;
local jid_bare = require "util.jid".bare;
local set, array = require "util.set", require "util.array";
local cert_verify_identity = require "util.x509".verify_identity;
diff --git a/plugins/mod_dialback.lua b/plugins/mod_dialback.lua
index 977e58c3..5cb59fef 100644
--- a/plugins/mod_dialback.lua
+++ b/plugins/mod_dialback.lua
@@ -9,7 +9,6 @@
local format = string.format;
local hosts = _G.hosts;
-local send_s2s = require "core.s2smanager".send_to_host;
local s2s_make_authenticated = require "core.s2smanager".make_authenticated;
local log = module._log;
@@ -87,7 +86,6 @@ module:hook("stanza/jabber:server:dialback:result", function(event)
end
origin.log("debug", "asking %s if key %s belongs to them", attr.from, stanza[1]);
- --send_s2s(attr.to, attr.from,
origin.send(st.stanza("db:verify", { from = attr.to, to = attr.from, id = origin.streamid }):text(stanza[1]));
return true;
end
@@ -162,6 +160,11 @@ module:hook_stanza(xmlns_stream, "features", function (origin, stanza)
end
end, 100);
+module:hook("s2s-no-stream-features", function (event)
+ initiate_dialback(event.origin);
+ return true;
+end, 100);
+
-- Offer dialback to incoming hosts
module:hook("s2s-stream-features", function (data)
data.features:tag("dialback", { xmlns='urn:xmpp:features:dialback' }):up();
diff --git a/plugins/s2s/mod_s2s.lua b/plugins/s2s/mod_s2s.lua
index 9f522595..9ab2ee0a 100644
--- a/plugins/s2s/mod_s2s.lua
+++ b/plugins/s2s/mod_s2s.lua
@@ -9,6 +9,7 @@
module:set_global();
local tostring, type = tostring, type;
+local t_insert = table.insert;
local xpcall, traceback = xpcall, debug.traceback;
local add_task = require "util.timer".add_task;
@@ -59,7 +60,8 @@ local function bounce_sendq(session, reason)
session.sendq = nil;
end
-function send_to_host(from_host, to_host, stanza)
+module:hook("route/remote", function (event)
+ local from_host, to_host, stanza = event.from_host, event.to_host, event.stanza;
if not hosts[from_host] then
log("warn", "Attempt to send stanza from %s - a host we don't serve", from_host);
return false;
@@ -69,7 +71,7 @@ function send_to_host(from_host, to_host, stanza)
-- We have a connection to this host already
if host.type == "s2sout_unauthed" and (stanza.name ~= "db:verify" or not host.dialback_key) then
(host.log or log)("debug", "trying to send over unauthed s2sout to "..to_host);
-
+
-- Queue stanza until we are able to send it
if host.sendq then t_insert(host.sendq, {tostring(stanza), stanza.attr.type ~= "error" and stanza.attr.type ~= "result" and st.reply(stanza)});
else host.sendq = { {tostring(stanza), stanza.attr.type ~= "error" and stanza.attr.type ~= "result" and st.reply(stanza)} }; end
@@ -88,31 +90,31 @@ function send_to_host(from_host, to_host, stanza)
end
host.sends2s(stanza);
host.log("debug", "stanza sent over "..host.type);
- end
- else
- log("debug", "opening a new outgoing connection for this stanza");
- local host_session = s2s_new_outgoing(from_host, to_host);
-
- -- Store in buffer
- host_session.bounce_sendq = bounce_sendq;
- host_session.sendq = { {tostring(stanza), stanza.attr.type ~= "error" and stanza.attr.type ~= "result" and st.reply(stanza)} };
- log("debug", "stanza [%s] queued until connection complete", tostring(stanza.name));
- s2sout.initiate_connection(host_session);
- if (not host_session.connecting) and (not host_session.conn) then
- log("warn", "Connection to %s failed already, destroying session...", to_host);
- if not s2s_destroy_session(host_session, "Connection failed") then
- -- Already destroyed, we need to bounce our stanza
- host_session:bounce_sendq(host_session.destruction_reason);
- end
- return false;
+ return true;
end
end
- return true;
-end
+end, 200);
module:hook("route/remote", function (event)
- return send_to_host(event.from_host, event.to_host, event.stanza);
-end);
+ local from_host, to_host, stanza = event.from_host, event.to_host, event.stanza;
+ log("debug", "opening a new outgoing connection for this stanza");
+ local host_session = s2s_new_outgoing(from_host, to_host);
+
+ -- Store in buffer
+ host_session.bounce_sendq = bounce_sendq;
+ host_session.sendq = { {tostring(stanza), stanza.attr.type ~= "error" and stanza.attr.type ~= "result" and st.reply(stanza)} };
+ log("debug", "stanza [%s] queued until connection complete", tostring(stanza.name));
+ s2sout.initiate_connection(host_session);
+ if (not host_session.connecting) and (not host_session.conn) then
+ log("warn", "Connection to %s failed already, destroying session...", to_host);
+ if not s2s_destroy_session(host_session, "Connection failed") then
+ -- Already destroyed, we need to bounce our stanza
+ host_session:bounce_sendq(host_session.destruction_reason);
+ end
+ return false;
+ end
+ return true;
+end, 100);
--- Helper to check that a session peer's certificate is valid
local function check_cert_status(session)
@@ -231,14 +233,14 @@ function stream_callbacks.streamopened(session, attr)
if session.version < 1.0 then
if not session.dialback_verifying then
log("debug", "Initiating dialback...");
- initiate_dialback(session);
+ hosts[session.from_host].events.fire_event("s2s-no-stream-features", { origin = session });
else
s2s_mark_connected(session);
end
end
end
session.notopen = nil;
- session.send = function(stanza) send_to_host(session.to_host, session.from_host, stanza); end;
+ session.send = function(stanza) prosody.events.fire_event("route/remote", { from_host = session.to_host, to_host = session.from_host, stanza = stanza}) end;
end
function stream_callbacks.streamclosed(session)