Changeset

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
parents 1218:8e02c10c9e60
children 1220:8e977f4262b4
files plugins/mod_tls.lua
diffstat 1 files changed, 9 insertions(+), 1 deletions(-) [+]
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);