Comparison

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
comparison
equal deleted inserted replaced
1218:8e02c10c9e60 1219:f14e08a0ae7f
9 9
10 10
11 local st = require "util.stanza"; 11 local st = require "util.stanza";
12 12
13 local xmlns_starttls ='urn:ietf:params:xml:ns:xmpp-tls'; 13 local xmlns_starttls ='urn:ietf:params:xml:ns:xmpp-tls';
14
15 local config = require "core.configmanager";
16 local secure_auth_only = config.get("*", "core", "require_encryption");
14 17
15 module:add_handler("c2s_unauthed", "starttls", xmlns_starttls, 18 module:add_handler("c2s_unauthed", "starttls", xmlns_starttls,
16 function (session, stanza) 19 function (session, stanza)
17 if session.conn.starttls then 20 if session.conn.starttls then
18 session.send(st.stanza("proceed", { xmlns = xmlns_starttls })); 21 session.send(st.stanza("proceed", { xmlns = xmlns_starttls }));
28 31
29 local starttls_attr = { xmlns = xmlns_starttls }; 32 local starttls_attr = { xmlns = xmlns_starttls };
30 module:add_event_hook("stream-features", 33 module:add_event_hook("stream-features",
31 function (session, features) 34 function (session, features)
32 if session.conn.starttls then 35 if session.conn.starttls then
33 features:tag("starttls", starttls_attr):up(); 36 features:tag("starttls", starttls_attr);
37 if secure_auth_only then
38 features:tag("required"):up():up();
39 else
40 features:up();
41 end
34 end 42 end
35 end); 43 end);