aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/mod_s2s_bidi.lua
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2019-11-16 16:52:31 +0100
committerKim Alvefur <zash@zash.se>2019-11-16 16:52:31 +0100
commit908f5b61c55e4cba39e61ac415b0fca384a1095d (patch)
tree6e391ff6608608f181e42c92ee6dfd7c534da255 /plugins/mod_s2s_bidi.lua
parentc4c38d2f01d5f2711b527c7c2412250ed6c58738 (diff)
parentfd9ccf20d5b652dbad1f37cecd540661f4642ee6 (diff)
downloadprosody-908f5b61c55e4cba39e61ac415b0fca384a1095d.tar.gz
prosody-908f5b61c55e4cba39e61ac415b0fca384a1095d.zip
Merge 0.11->trunk
Diffstat (limited to 'plugins/mod_s2s_bidi.lua')
-rw-r--r--plugins/mod_s2s_bidi.lua38
1 files changed, 38 insertions, 0 deletions
diff --git a/plugins/mod_s2s_bidi.lua b/plugins/mod_s2s_bidi.lua
new file mode 100644
index 00000000..67a48d8d
--- /dev/null
+++ b/plugins/mod_s2s_bidi.lua
@@ -0,0 +1,38 @@
+-- Prosody IM
+-- Copyright (C) 2019 Kim Alvefur
+--
+-- This project is MIT/X11 licensed. Please see the
+-- COPYING file in the source package for more information.
+--
+
+local st = require "util.stanza";
+
+local xmlns_bidi_feature = "urn:xmpp:features:bidi"
+local xmlns_bidi = "urn:xmpp:bidi";
+
+module:hook("s2s-stream-features", function(event)
+ local origin, features = event.origin, event.features;
+ if origin.type == "s2sin_unauthed" then
+ features:tag("bidi", { xmlns = xmlns_bidi_feature }):up();
+ end
+end);
+
+module:hook_tag("http://etherx.jabber.org/streams", "features", function (session, stanza)
+ if session.type == "s2sout_unauthed" then
+ local bidi = stanza:get_child("bidi", xmlns_bidi_feature);
+ if bidi then
+ session.incoming = true;
+ session.log("debug", "Requesting bidirectional stream");
+ session.sends2s(st.stanza("bidi", { xmlns = xmlns_bidi }));
+ end
+ end
+end, 200);
+
+module:hook_tag("urn:xmpp:bidi", "bidi", function(session)
+ if session.type == "s2sin_unauthed" then
+ session.log("debug", "Requested bidirectional stream");
+ session.outgoing = true;
+ return true;
+ end
+end);
+