xmppserver_listener: Add status() function to signal when a connection completes its SSL handshake

Sun, 04 Oct 2009 14:35:39 +0100

author
Matthew Wild <mwild1@gmail.com>
date
Sun, 04 Oct 2009 14:35:39 +0100
changeset 1880
d5dc9e06d917
parent 1879
42157c066813
child 1881
35e05b77f6ce

xmppserver_listener: Add status() function to signal when a connection completes its SSL handshake

net/xmppserver_listener.lua file | annotate | diff | comparison | revisions
--- a/net/xmppserver_listener.lua	Sun Oct 04 14:24:55 2009 +0100
+++ b/net/xmppserver_listener.lua	Sun Oct 04 14:35:39 2009 +0100
@@ -134,6 +134,17 @@
 	end
 end
 	
+function xmppserver.status(conn, status)
+	if status == "ssl-handshake-complete" then
+		local session = sessions[conn];
+		if session and session.direction == "outgoing" then
+			local format, to_host, from_host = string.format, session.to_host, session.from_host;
+			session.log("warn", "Sending stream header...");
+			session.sends2s(format([[<stream:stream xmlns='jabber:server' xmlns:db='jabber:server:dialback' xmlns:stream='http://etherx.jabber.org/streams' from='%s' to='%s' version='1.0'>]], from_host, to_host));
+		end
+	end
+end
+
 function xmppserver.disconnect(conn, err)
 	local session = sessions[conn];
 	if session then

mercurial