Diff

plugins/mod_tls.lua @ 1219:f14e08a0ae7f

mod_tls: Add <required/> to stream feature when TLS is required
author Matthew Wild <mwild1@gmail.com>
date Fri, 29 May 2009 18:17:03 +0100
parent 1213:de66fa750daf
child 1523:841d61be198f
line wrap: on
line diff
--- a/plugins/mod_tls.lua	Fri May 29 18:04:53 2009 +0100
+++ b/plugins/mod_tls.lua	Fri May 29 18:17:03 2009 +0100
@@ -12,6 +12,9 @@
 
 local xmlns_starttls ='urn:ietf:params:xml:ns:xmpp-tls';
 
+local config = require "core.configmanager";
+local secure_auth_only = config.get("*", "core", "require_encryption");
+
 module:add_handler("c2s_unauthed", "starttls", xmlns_starttls,
 		function (session, stanza)
 			if session.conn.starttls then
@@ -30,6 +33,11 @@
 module:add_event_hook("stream-features", 
 		function (session, features)												
 			if session.conn.starttls then
-				features:tag("starttls", starttls_attr):up();
+				features:tag("starttls", starttls_attr);
+				if secure_auth_only then
+					features:tag("required"):up():up();
+				else
+					features:up();
+				end
 			end
 		end);