Mercurial > prosody-hg
comparison plugins/mod_s2s_bidi.lua @ 10411:db2a06b9ff98
Merge 0.11->trunk
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Sat, 16 Nov 2019 16:52:31 +0100 |
| parents | 1006739de449 |
| children | 602dd1e2f399 |
comparison
equal
deleted
inserted
replaced
| 10410:659b577f280c | 10411:db2a06b9ff98 |
|---|---|
| 1 -- Prosody IM | |
| 2 -- Copyright (C) 2019 Kim Alvefur | |
| 3 -- | |
| 4 -- This project is MIT/X11 licensed. Please see the | |
| 5 -- COPYING file in the source package for more information. | |
| 6 -- | |
| 7 | |
| 8 local st = require "util.stanza"; | |
| 9 | |
| 10 local xmlns_bidi_feature = "urn:xmpp:features:bidi" | |
| 11 local xmlns_bidi = "urn:xmpp:bidi"; | |
| 12 | |
| 13 module:hook("s2s-stream-features", function(event) | |
| 14 local origin, features = event.origin, event.features; | |
| 15 if origin.type == "s2sin_unauthed" then | |
| 16 features:tag("bidi", { xmlns = xmlns_bidi_feature }):up(); | |
| 17 end | |
| 18 end); | |
| 19 | |
| 20 module:hook_tag("http://etherx.jabber.org/streams", "features", function (session, stanza) | |
| 21 if session.type == "s2sout_unauthed" then | |
| 22 local bidi = stanza:get_child("bidi", xmlns_bidi_feature); | |
| 23 if bidi then | |
| 24 session.incoming = true; | |
| 25 session.log("debug", "Requesting bidirectional stream"); | |
| 26 session.sends2s(st.stanza("bidi", { xmlns = xmlns_bidi })); | |
| 27 end | |
| 28 end | |
| 29 end, 200); | |
| 30 | |
| 31 module:hook_tag("urn:xmpp:bidi", "bidi", function(session) | |
| 32 if session.type == "s2sin_unauthed" then | |
| 33 session.log("debug", "Requested bidirectional stream"); | |
| 34 session.outgoing = true; | |
| 35 return true; | |
| 36 end | |
| 37 end); | |
| 38 |
