Merge with Zash
authorMatthew Wild <mwild1@gmail.com>
Sat, 3 Mar 2012 01:12:16 +0000 (01:12 +0000)
committerMatthew Wild <mwild1@gmail.com>
Sat, 3 Mar 2012 01:12:16 +0000 (01:12 +0000)
core/portmanager.lua
plugins/mod_admin_telnet.lua
plugins/mod_dialback.lua
plugins/s2s/mod_s2s.lua

index 353c4a896f416ff197d4123bc2f8df0c671e8aa9..3d6dada442e19a50747f603603eed0f755c0cdd3 100644 (file)
@@ -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);
        
index d3f5543e6f5692627a2abc9df0b0b7d0b6ff305a..fd72787e0a322494eb615b8efd37ee357576563c 100644 (file)
@@ -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;
index 977e58c33f8e5510ce8182373a7d12f583e8387d..5cb59fef32cd6f0140236c9642fda0d53cbc5ce3 100644 (file)
@@ -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();
index 9f5225954c2842264bf422767add6e40b1790f72..9ab2ee0a02b5f9a6ecf9ba21557abc5e27a5dc3c 100644 (file)
@@ -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)