Software /
code /
prosody-modules
Comparison
mod_tlsfail/mod_tlsfail.lua @ 4702:7009e16192fa
mod_tlsfail: Add c2s support
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sun, 03 Oct 2021 17:04:05 +0200 |
parent | 4434:f10ab82be166 |
comparison
equal
deleted
inserted
replaced
4701:efdc3e4dc5df | 4702:7009e16192fa |
---|---|
2 | 2 |
3 local xmlns_starttls = 'urn:ietf:params:xml:ns:xmpp-tls'; | 3 local xmlns_starttls = 'urn:ietf:params:xml:ns:xmpp-tls'; |
4 local starttls_attr = { xmlns = xmlns_starttls }; | 4 local starttls_attr = { xmlns = xmlns_starttls }; |
5 local s2s_feature = st.stanza("starttls", starttls_attr); | 5 local s2s_feature = st.stanza("starttls", starttls_attr); |
6 local starttls_failure = st.stanza("failure", starttls_attr); | 6 local starttls_failure = st.stanza("failure", starttls_attr); |
7 | |
8 module:hook("stream-features", function(event) | |
9 local features = event.features; | |
10 features:add_child(s2s_feature); | |
11 end); | |
7 | 12 |
8 module:hook("s2s-stream-features", function(event) | 13 module:hook("s2s-stream-features", function(event) |
9 local features = event.features; | 14 local features = event.features; |
10 features:add_child(s2s_feature); | 15 features:add_child(s2s_feature); |
11 end); | 16 end); |
12 | 17 |
13 -- Hook <starttls/> | 18 -- Hook <starttls/> |
14 module:hook("stanza/urn:ietf:params:xml:ns:xmpp-tls:starttls", function(event) | 19 module:hook("stanza/urn:ietf:params:xml:ns:xmpp-tls:starttls", function(event) |
15 local origin = event.origin; | 20 local origin = event.origin; |
16 origin.sends2s(starttls_failure); | 21 (origin.sends2s or origin.send)(starttls_failure); |
17 origin:close(); | 22 origin:close(); |
18 return true; | 23 return true; |
19 end); | 24 end); |