Software /
code /
prosody
Comparison
plugins/mod_tls.lua @ 2600:1e6f3002e04f
mod_tls: Inlined some code.
author | Waqas Hussain <waqas20@gmail.com> |
---|---|
date | Fri, 12 Feb 2010 02:32:27 +0500 |
parent | 2596:187cd90860cb |
child | 2601:e64c6a4aa50b |
comparison
equal
deleted
inserted
replaced
2596:187cd90860cb | 2600:1e6f3002e04f |
---|---|
14 local secure_auth_only = module:get_option("c2s_require_encryption") or module:get_option("require_encryption"); | 14 local secure_auth_only = module:get_option("c2s_require_encryption") or module:get_option("require_encryption"); |
15 local secure_s2s_only = module:get_option("s2s_require_encryption"); | 15 local secure_s2s_only = module:get_option("s2s_require_encryption"); |
16 | 16 |
17 local global_ssl_ctx = prosody.global_ssl_ctx; | 17 local global_ssl_ctx = prosody.global_ssl_ctx; |
18 | 18 |
19 function starttls_handler(session, stanza) | 19 module:hook("stanza/urn:ietf:params:xml:ns:xmpp-tls:starttls", function(event) |
20 if session.conn.starttls then | 20 local origin = event.origin; |
21 (session.sends2s or session.send)(st.stanza("proceed", { xmlns = xmlns_starttls })); | 21 if origin.conn.starttls and origin.type == "c2s_unauthed" or origin.type == "s2sin_unauthed" then |
22 session:reset_stream(); | 22 (origin.sends2s or origin.send)(st.stanza("proceed", { xmlns = xmlns_starttls })); |
23 local host = session.to_host or session.host; | 23 origin:reset_stream(); |
24 local host = origin.to_host or origin.host; | |
24 local ssl_ctx = host and hosts[host].ssl_ctx_in or global_ssl_ctx; | 25 local ssl_ctx = host and hosts[host].ssl_ctx_in or global_ssl_ctx; |
25 session.conn:starttls(ssl_ctx); | 26 origin.conn:starttls(ssl_ctx); |
26 session.log("info", "TLS negotiation started for %s...", session.type); | 27 origin.log("info", "TLS negotiation started for %s...", origin.type); |
27 session.secure = false; | 28 origin.secure = false; |
28 else | |
29 -- FIXME: What reply? | |
30 session.log("warn", "Attempt to start TLS, but TLS is not available on this %s connection", session.type); | |
31 end | |
32 end | |
33 | |
34 module:hook("stanza/urn:ietf:params:xml:ns:xmpp-tls:starttls", function(event) | |
35 local origin, stanza = event.origin, event.stanza; | |
36 if origin.type == "c2s_unauthed" or origin.type == "s2sin_unauthed" then | |
37 starttls_handler(origin, stanza); | |
38 else | 29 else |
39 -- FIXME: What reply? | 30 -- FIXME: What reply? |
40 origin.log("warn", "Attempt to start TLS, but TLS is not available on this %s connection", origin.type); | 31 origin.log("warn", "Attempt to start TLS, but TLS is not available on this %s connection", origin.type); |
41 end | 32 end |
42 return true; | 33 return true; |