Diff

plugins/mod_tls.lua @ 2595:015934e20f03

mod_tls: Switched to new events API.
author Waqas Hussain <waqas20@gmail.com>
date Fri, 12 Feb 2010 01:56:18 +0500
parent 2594:ab52fdd9f5d0
child 2596:187cd90860cb
line wrap: on
line diff
--- a/plugins/mod_tls.lua	Fri Feb 12 01:47:10 2010 +0500
+++ b/plugins/mod_tls.lua	Fri Feb 12 01:56:18 2010 +0500
@@ -44,8 +44,18 @@
 	end
 end
 
-module:add_handler("c2s_unauthed", "starttls", xmlns_starttls, c2s_starttls_handler);
-module:add_handler("s2sin_unauthed", "starttls", xmlns_starttls, s2s_starttls_handler);
+module:hook("stanza/urn:ietf:params:xml:ns:xmpp-tls:starttls", function(event)
+	local origin, stanza = event.origin, event.stanza;
+	if origin.type == "c2s_unauthed" then
+		c2s_starttls_handler(origin, stanza);
+	elseif origin.type == "s2sin_unauthed" then
+		s2s_starttls_handler(origin, stanza);
+	else
+		-- FIXME: What reply?
+		origin.log("warn", "Attempt to start TLS, but TLS is not available on this %s connection", origin.type);
+	end
+	return true;
+end);
 
 
 local starttls_attr = { xmlns = xmlns_starttls };