Mercurial > prosody-modules
diff mod_tlsfail/mod_tlsfail.lua @ 4434:f10ab82be166
mod_tlsfail: Test how servers react to starttls failure
Lines copypasted from mod_tls
Intended for use in the badxmpp.eu test suite
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Wed, 10 Feb 2021 16:02:28 +0100 |
parents | |
children | 7009e16192fa |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mod_tlsfail/mod_tlsfail.lua Wed Feb 10 16:02:28 2021 +0100 @@ -0,0 +1,19 @@ +local st = require "util.stanza"; + +local xmlns_starttls = 'urn:ietf:params:xml:ns:xmpp-tls'; +local starttls_attr = { xmlns = xmlns_starttls }; +local s2s_feature = st.stanza("starttls", starttls_attr); +local starttls_failure = st.stanza("failure", starttls_attr); + +module:hook("s2s-stream-features", function(event) + local features = event.features; + features:add_child(s2s_feature); +end); + +-- Hook <starttls/> +module:hook("stanza/urn:ietf:params:xml:ns:xmpp-tls:starttls", function(event) + local origin = event.origin; + origin.sends2s(starttls_failure); + origin:close(); + return true; +end);