mod_s2s: port functionality once in s2smanager.
authorFlorian Zeitz <florob@babelmonkeys.de>
Fri, 24 Feb 2012 15:21:21 +0000
changeset 4568 aae7a62671de
parent 4567 24617f360200
child 4569 34b1122126f6
mod_s2s: port functionality once in s2smanager.
plugins/s2s/mod_s2s.lua
--- a/plugins/s2s/mod_s2s.lua	Fri Feb 24 15:20:03 2012 +0000
+++ b/plugins/s2s/mod_s2s.lua	Fri Feb 24 15:21:21 2012 +0000
@@ -14,10 +14,12 @@
 local add_task = require "util.timer".add_task;
 local st = require "util.stanza";
 local initialize_filters = require "util.filters".initialize;
+local nameprep = require "util.encodings".stringprep.nameprep;
 local new_xmpp_stream = require "util.xmppstream".new;
 local s2s_new_incoming = require "core.s2smanager".new_incoming;
 local s2s_new_outgoing = require "core.s2smanager".new_outgoing;
 local s2s_destroy_session = require "core.s2smanager".destroy_session;
+local uuid_gen = require "util.uuid".generate;
 
 local s2sout = module:require("s2sout");
 
@@ -94,6 +96,7 @@
 		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
@@ -102,7 +105,6 @@
 			end
 			return false;
 		end
-		s2sout.initiate_connection(host_session);
 	end
 	return true;
 end
@@ -189,7 +191,7 @@
 		if session.secure and not session.cert_chain_status then check_cert_status(session); end
 
 		send("<?xml version='1.0'?>");
-		send(stanza("stream:stream", { xmlns='jabber:server', ["xmlns:db"]='jabber:server:dialback',
+		send(stanza.stanza("stream:stream", { xmlns='jabber:server', ["xmlns:db"]='jabber:server:dialback',
 				["xmlns:stream"]='http://etherx.jabber.org/streams', id=session.streamid, from=session.to_host, to=session.from_host, version=(session.version > 0 and "1.0" or nil) }):top_tag());
 		if session.version >= 1.0 then
 			local features = st.stanza("stream:features");
@@ -235,6 +237,7 @@
 		end
 	end
 	session.notopen = nil;
+	session.send = function(stanza) send_to_host(session.to_host, session.from_host, stanza); end;
 end
 
 function stream_callbacks.streamclosed(session)