Software /
code /
prosody
Comparison
plugins/mod_tls.lua @ 6709:b6eff3ba13de
mod_tls: Build <starttls/> as a stanza instead of with string concatenation
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Mon, 18 May 2015 21:43:24 +0200 |
parent | 6526:873538f0b18c |
child | 6710:d062314446f6 |
comparison
equal
deleted
inserted
replaced
6708:d2beb98ece29 | 6709:b6eff3ba13de |
---|---|
19 s2s_require_encryption = true; | 19 s2s_require_encryption = true; |
20 end | 20 end |
21 | 21 |
22 local xmlns_starttls = 'urn:ietf:params:xml:ns:xmpp-tls'; | 22 local xmlns_starttls = 'urn:ietf:params:xml:ns:xmpp-tls'; |
23 local starttls_attr = { xmlns = xmlns_starttls }; | 23 local starttls_attr = { xmlns = xmlns_starttls }; |
24 local starttls_initiate= st.stanza("starttls", starttls_attr); | |
24 local starttls_proceed = st.stanza("proceed", starttls_attr); | 25 local starttls_proceed = st.stanza("proceed", starttls_attr); |
25 local starttls_failure = st.stanza("failure", starttls_attr); | 26 local starttls_failure = st.stanza("failure", starttls_attr); |
26 local c2s_feature = st.stanza("starttls", starttls_attr); | 27 local c2s_feature = st.stanza("starttls", starttls_attr); |
27 local s2s_feature = st.stanza("starttls", starttls_attr); | 28 local s2s_feature = st.stanza("starttls", starttls_attr); |
28 if c2s_require_encryption then c2s_feature:tag("required"):up(); end | 29 if c2s_require_encryption then c2s_feature:tag("required"):up(); end |
114 -- For s2sout connections, start TLS if we can | 115 -- For s2sout connections, start TLS if we can |
115 module:hook_stanza("http://etherx.jabber.org/streams", "features", function (session, stanza) | 116 module:hook_stanza("http://etherx.jabber.org/streams", "features", function (session, stanza) |
116 module:log("debug", "Received features element"); | 117 module:log("debug", "Received features element"); |
117 if can_do_tls(session) and stanza:get_child("starttls", xmlns_starttls) then | 118 if can_do_tls(session) and stanza:get_child("starttls", xmlns_starttls) then |
118 module:log("debug", "%s is offering TLS, taking up the offer...", session.to_host); | 119 module:log("debug", "%s is offering TLS, taking up the offer...", session.to_host); |
119 session.sends2s("<starttls xmlns='"..xmlns_starttls.."'/>"); | 120 session.sends2s(starttls_initiate); |
120 return true; | 121 return true; |
121 end | 122 end |
122 end, 500); | 123 end, 500); |
123 | 124 |
124 module:hook_stanza(xmlns_starttls, "proceed", function (session, stanza) | 125 module:hook_stanza(xmlns_starttls, "proceed", function (session, stanza) |