Changeset

4906:89df1f03546a

mod_s2s, s2sout.lib: Send stream header in onconnect()
author Matthew Wild <mwild1@gmail.com>
date Thu, 24 May 2012 03:08:42 +0100
parents 4905:274ef78aa173
children 4907:32b638a8da5b
files plugins/mod_s2s/mod_s2s.lua plugins/mod_s2s/s2sout.lib.lua
diffstat 2 files changed, 5 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/mod_s2s/mod_s2s.lua	Thu May 24 02:55:37 2012 +0100
+++ b/plugins/mod_s2s/mod_s2s.lua	Thu May 24 03:08:42 2012 +0100
@@ -427,8 +427,9 @@
 end
 
 function listener.onconnect(conn)
-	if not sessions[conn] then -- May be an existing outgoing session
-		local session = s2s_new_incoming(conn);
+	local session = sessions[conn];
+	if not session then -- New incoming connection
+		session = s2s_new_incoming(conn);
 		sessions[conn] = session;
 		session.log("debug", "Incoming s2s connection");
 
@@ -448,6 +449,8 @@
 		end
 	
 		initialize_session(session);
+	else -- Outgoing session connected
+		session:open_stream(session.from_host, session.to_host);
 	end
 end
 
--- a/plugins/mod_s2s/s2sout.lib.lua	Thu May 24 02:55:37 2012 +0100
+++ b/plugins/mod_s2s/s2sout.lib.lua	Thu May 24 03:08:42 2012 +0100
@@ -314,8 +314,6 @@
 	-- otherwise it will assume it is a new incoming connection
 	s2s_listener.register_outgoing(conn, host_session);
 	
-	host_session:open_stream(from_host, to_host);
-	
 	log("debug", "Connection attempt in progress...");
 	return true;
 end