changeset 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 0e3f5f70a51d
children a620bf249e63
files mod_tlsfail/mod_tlsfail.lua
diffstat 1 files changed, 19 insertions(+), 0 deletions(-) [+]
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);