annotate mod_bidi/mod_bidi.lua @ 5160:8474a3b80200

mod_firewall: Fix 'is_admin' internal dependency rule #1797 (thanks diane) Looks like the boolean logic was inverted here. Instead, for now, simply check if is_admin is there. It is deprecated in trunk and was briefly removed before being brought back with a 'deprecated' warning as part of the new roles and permissions work. Making this dependency conditioned on the existence of the underlying function should make it work until it actually goes away for real.
author Kim Alvefur <zash@zash.se>
date Fri, 27 Jan 2023 23:06:25 +0100
parents c96a53bf67b3
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
892
148865199003 mod_bidi: Initial commit of XEP-0288 implementation
Kim Alvefur <zash@zash.se>
parents:
diff changeset
1 -- Bidirectional Server-to-Server Connections
148865199003 mod_bidi: Initial commit of XEP-0288 implementation
Kim Alvefur <zash@zash.se>
parents:
diff changeset
2 -- http://xmpp.org/extensions/xep-0288.html
148865199003 mod_bidi: Initial commit of XEP-0288 implementation
Kim Alvefur <zash@zash.se>
parents:
diff changeset
3 -- Copyright (C) 2013 Kim Alvefur
148865199003 mod_bidi: Initial commit of XEP-0288 implementation
Kim Alvefur <zash@zash.se>
parents:
diff changeset
4 --
148865199003 mod_bidi: Initial commit of XEP-0288 implementation
Kim Alvefur <zash@zash.se>
parents:
diff changeset
5 -- This file is MIT/X11 licensed.
148865199003 mod_bidi: Initial commit of XEP-0288 implementation
Kim Alvefur <zash@zash.se>
parents:
diff changeset
6 --
148865199003 mod_bidi: Initial commit of XEP-0288 implementation
Kim Alvefur <zash@zash.se>
parents:
diff changeset
7 local add_filter = require "util.filters".add_filter;
148865199003 mod_bidi: Initial commit of XEP-0288 implementation
Kim Alvefur <zash@zash.se>
parents:
diff changeset
8 local st = require "util.stanza";
148865199003 mod_bidi: Initial commit of XEP-0288 implementation
Kim Alvefur <zash@zash.se>
parents:
diff changeset
9 local jid_split = require"util.jid".prepped_split;
1121
c714ed7de4ee mod_bidi: Clean up and use 0.9+ routing APIs
Kim Alvefur <zash@zash.se>
parents: 932
diff changeset
10 local core_process_stanza = prosody.core_process_stanza;
c714ed7de4ee mod_bidi: Clean up and use 0.9+ routing APIs
Kim Alvefur <zash@zash.se>
parents: 932
diff changeset
11 local traceback = debug.traceback;
c714ed7de4ee mod_bidi: Clean up and use 0.9+ routing APIs
Kim Alvefur <zash@zash.se>
parents: 932
diff changeset
12 local hosts = hosts;
892
148865199003 mod_bidi: Initial commit of XEP-0288 implementation
Kim Alvefur <zash@zash.se>
parents:
diff changeset
13 local xmlns_bidi_feature = "urn:xmpp:features:bidi"
148865199003 mod_bidi: Initial commit of XEP-0288 implementation
Kim Alvefur <zash@zash.se>
parents:
diff changeset
14 local xmlns_bidi = "urn:xmpp:bidi";
1123
0e16e5e2f410 mod_bidi: Only allow or offer bidi on secure connections, with an option to revert to previous behaviour
Kim Alvefur <zash@zash.se>
parents: 1122
diff changeset
15 local secure_only = module:get_option_boolean("secure_bidi_only", true);
1387
db2ff8f29472 mod_bidi: Add option for selectively not doing bidi with some hosts
Kim Alvefur <zash@zash.se>
parents: 1191
diff changeset
16 local disable_bidi_for = module:get_option_set("no_bidi_with", { });
1127
38e56be11584 mod_bidi: Make sessions table weak
Kim Alvefur <zash@zash.se>
parents: 1126
diff changeset
17 local bidi_sessions = module:shared"sessions-cache";
892
148865199003 mod_bidi: Initial commit of XEP-0288 implementation
Kim Alvefur <zash@zash.se>
parents:
diff changeset
18
148865199003 mod_bidi: Initial commit of XEP-0288 implementation
Kim Alvefur <zash@zash.se>
parents:
diff changeset
19 local function handleerr(err) log("error", "Traceback[s2s]: %s: %s", tostring(err), traceback()); end
148865199003 mod_bidi: Initial commit of XEP-0288 implementation
Kim Alvefur <zash@zash.se>
parents:
diff changeset
20 local function handlestanza(session, stanza)
148865199003 mod_bidi: Initial commit of XEP-0288 implementation
Kim Alvefur <zash@zash.se>
parents:
diff changeset
21 if stanza.attr.xmlns == "jabber:client" then --COMPAT: Prosody pre-0.6.2 may send jabber:client
148865199003 mod_bidi: Initial commit of XEP-0288 implementation
Kim Alvefur <zash@zash.se>
parents:
diff changeset
22 stanza.attr.xmlns = nil;
148865199003 mod_bidi: Initial commit of XEP-0288 implementation
Kim Alvefur <zash@zash.se>
parents:
diff changeset
23 end
148865199003 mod_bidi: Initial commit of XEP-0288 implementation
Kim Alvefur <zash@zash.se>
parents:
diff changeset
24 -- stanza = session.filter("stanzas/in", stanza);
148865199003 mod_bidi: Initial commit of XEP-0288 implementation
Kim Alvefur <zash@zash.se>
parents:
diff changeset
25 if stanza then
148865199003 mod_bidi: Initial commit of XEP-0288 implementation
Kim Alvefur <zash@zash.se>
parents:
diff changeset
26 return xpcall(function () return core_process_stanza(session, stanza) end, handleerr);
148865199003 mod_bidi: Initial commit of XEP-0288 implementation
Kim Alvefur <zash@zash.se>
parents:
diff changeset
27 end
148865199003 mod_bidi: Initial commit of XEP-0288 implementation
Kim Alvefur <zash@zash.se>
parents:
diff changeset
28 end
148865199003 mod_bidi: Initial commit of XEP-0288 implementation
Kim Alvefur <zash@zash.se>
parents:
diff changeset
29
148865199003 mod_bidi: Initial commit of XEP-0288 implementation
Kim Alvefur <zash@zash.se>
parents:
diff changeset
30 local function new_bidi(origin)
1121
c714ed7de4ee mod_bidi: Clean up and use 0.9+ routing APIs
Kim Alvefur <zash@zash.se>
parents: 932
diff changeset
31 if origin.type == "s2sin" then -- then we create an "outgoing" bidirectional session
893
602e4c509095 mod_bidi: Close conflicting outgoing sessions when bidi is initiated, not requested.
Kim Alvefur <zash@zash.se>
parents: 892
diff changeset
32 local conflicting_session = hosts[origin.to_host].s2sout[origin.from_host]
602e4c509095 mod_bidi: Close conflicting outgoing sessions when bidi is initiated, not requested.
Kim Alvefur <zash@zash.se>
parents: 892
diff changeset
33 if conflicting_session then
894
d066987e00b7 mod_bidi: Lower severity of notice about outgoing stream being replaced by bidi
Kim Alvefur <zash@zash.se>
parents: 893
diff changeset
34 conflicting_session.log("info", "We already have an outgoing connection to %s, closing it...", origin.from_host);
893
602e4c509095 mod_bidi: Close conflicting outgoing sessions when bidi is initiated, not requested.
Kim Alvefur <zash@zash.se>
parents: 892
diff changeset
35 conflicting_session:close{ condition = "conflict", text = "Replaced by bidirectional stream" }
602e4c509095 mod_bidi: Close conflicting outgoing sessions when bidi is initiated, not requested.
Kim Alvefur <zash@zash.se>
parents: 892
diff changeset
36 end
1121
c714ed7de4ee mod_bidi: Clean up and use 0.9+ routing APIs
Kim Alvefur <zash@zash.se>
parents: 932
diff changeset
37 bidi_sessions[origin.from_host] = origin;
1191
1818a7f08580 mod_bidi: Add missing 'is_bidi' flag for incoming s2s
Kim Alvefur <zash@zash.se>
parents: 1129
diff changeset
38 origin.is_bidi = true;
3720
8e7d400d4db3 mod_bidi: Make compatible Prosody after rev b36765ab0ae3 (fixes #1450)
Kim Alvefur <zash@zash.se>
parents: 1387
diff changeset
39 origin.outgoing = true;
1121
c714ed7de4ee mod_bidi: Clean up and use 0.9+ routing APIs
Kim Alvefur <zash@zash.se>
parents: 932
diff changeset
40 elseif origin.type == "s2sout" then -- handle incoming stanzas correctly
c714ed7de4ee mod_bidi: Clean up and use 0.9+ routing APIs
Kim Alvefur <zash@zash.se>
parents: 932
diff changeset
41 local bidi_session = {
1124
689e69df1cc4 mod_bidi: Make sure context for stanzas coming from bidi-enabled s2sout connections have the correct direction attribute
Kim Alvefur <zash@zash.se>
parents: 1123
diff changeset
42 type = "s2sin"; direction = "incoming";
3720
8e7d400d4db3 mod_bidi: Make compatible Prosody after rev b36765ab0ae3 (fixes #1450)
Kim Alvefur <zash@zash.se>
parents: 1387
diff changeset
43 incoming = true;
1121
c714ed7de4ee mod_bidi: Clean up and use 0.9+ routing APIs
Kim Alvefur <zash@zash.se>
parents: 932
diff changeset
44 is_bidi = true; orig_session = origin;
c714ed7de4ee mod_bidi: Clean up and use 0.9+ routing APIs
Kim Alvefur <zash@zash.se>
parents: 932
diff changeset
45 to_host = origin.from_host;
c714ed7de4ee mod_bidi: Clean up and use 0.9+ routing APIs
Kim Alvefur <zash@zash.se>
parents: 932
diff changeset
46 from_host = origin.to_host;
c714ed7de4ee mod_bidi: Clean up and use 0.9+ routing APIs
Kim Alvefur <zash@zash.se>
parents: 932
diff changeset
47 hosts = {};
c714ed7de4ee mod_bidi: Clean up and use 0.9+ routing APIs
Kim Alvefur <zash@zash.se>
parents: 932
diff changeset
48 }
c714ed7de4ee mod_bidi: Clean up and use 0.9+ routing APIs
Kim Alvefur <zash@zash.se>
parents: 932
diff changeset
49 origin.bidi_session = bidi_session;
c714ed7de4ee mod_bidi: Clean up and use 0.9+ routing APIs
Kim Alvefur <zash@zash.se>
parents: 932
diff changeset
50 setmetatable(bidi_session, { __index = origin });
c714ed7de4ee mod_bidi: Clean up and use 0.9+ routing APIs
Kim Alvefur <zash@zash.se>
parents: 932
diff changeset
51 module:fire_event("s2s-authenticated", { session = bidi_session, host = origin.to_host });
1125
901e361af918 mod_bidi: Fix accidentally module-global value
Kim Alvefur <zash@zash.se>
parents: 1124
diff changeset
52 local remote_host = origin.to_host;
892
148865199003 mod_bidi: Initial commit of XEP-0288 implementation
Kim Alvefur <zash@zash.se>
parents:
diff changeset
53 add_filter(origin, "stanzas/in", function(stanza)
148865199003 mod_bidi: Initial commit of XEP-0288 implementation
Kim Alvefur <zash@zash.se>
parents:
diff changeset
54 if stanza.attr.xmlns ~= nil then return stanza end
148865199003 mod_bidi: Initial commit of XEP-0288 implementation
Kim Alvefur <zash@zash.se>
parents:
diff changeset
55 local _, host = jid_split(stanza.attr.from);
148865199003 mod_bidi: Initial commit of XEP-0288 implementation
Kim Alvefur <zash@zash.se>
parents:
diff changeset
56 if host ~= remote_host then return stanza end
148865199003 mod_bidi: Initial commit of XEP-0288 implementation
Kim Alvefur <zash@zash.se>
parents:
diff changeset
57 handlestanza(bidi_session, stanza);
148865199003 mod_bidi: Initial commit of XEP-0288 implementation
Kim Alvefur <zash@zash.se>
parents:
diff changeset
58 end, 1);
148865199003 mod_bidi: Initial commit of XEP-0288 implementation
Kim Alvefur <zash@zash.se>
parents:
diff changeset
59 end
1121
c714ed7de4ee mod_bidi: Clean up and use 0.9+ routing APIs
Kim Alvefur <zash@zash.se>
parents: 932
diff changeset
60 end
892
148865199003 mod_bidi: Initial commit of XEP-0288 implementation
Kim Alvefur <zash@zash.se>
parents:
diff changeset
61
1121
c714ed7de4ee mod_bidi: Clean up and use 0.9+ routing APIs
Kim Alvefur <zash@zash.se>
parents: 932
diff changeset
62 module:hook("route/remote", function(event)
c714ed7de4ee mod_bidi: Clean up and use 0.9+ routing APIs
Kim Alvefur <zash@zash.se>
parents: 932
diff changeset
63 local from_host, to_host, stanza = event.from_host, event.to_host, event.stanza;
c714ed7de4ee mod_bidi: Clean up and use 0.9+ routing APIs
Kim Alvefur <zash@zash.se>
parents: 932
diff changeset
64 if from_host ~= module.host then return end
1128
6b344b7e4781 mod_bidi: Allow route/remote event to continue if we couldn't send a stanza (in case the session was destroyed)
Kim Alvefur <zash@zash.se>
parents: 1127
diff changeset
65 local to_session = bidi_sessions[to_host];
1126
6fd328b8e136 mod_bidi: Don't try to send on destroyed sessions
Kim Alvefur <zash@zash.se>
parents: 1125
diff changeset
66 if not to_session or to_session.type ~= "s2sin" then return end
1129
ae0fa4d2005d mod_bidi: Revert to sends2s (Go to sleep zash, you're too tired to code)
Kim Alvefur <zash@zash.se>
parents: 1128
diff changeset
67 if to_session.sends2s(stanza) then return true end
1121
c714ed7de4ee mod_bidi: Clean up and use 0.9+ routing APIs
Kim Alvefur <zash@zash.se>
parents: 932
diff changeset
68 end, -2);
892
148865199003 mod_bidi: Initial commit of XEP-0288 implementation
Kim Alvefur <zash@zash.se>
parents:
diff changeset
69
148865199003 mod_bidi: Initial commit of XEP-0288 implementation
Kim Alvefur <zash@zash.se>
parents:
diff changeset
70 -- Incoming s2s
148865199003 mod_bidi: Initial commit of XEP-0288 implementation
Kim Alvefur <zash@zash.se>
parents:
diff changeset
71 module:hook("s2s-stream-features", function(event)
148865199003 mod_bidi: Initial commit of XEP-0288 implementation
Kim Alvefur <zash@zash.se>
parents:
diff changeset
72 local origin, features = event.origin, event.features;
1191
1818a7f08580 mod_bidi: Add missing 'is_bidi' flag for incoming s2s
Kim Alvefur <zash@zash.se>
parents: 1129
diff changeset
73 if not origin.is_bidi and not origin.bidi_session and not origin.do_bidi
1818a7f08580 mod_bidi: Add missing 'is_bidi' flag for incoming s2s
Kim Alvefur <zash@zash.se>
parents: 1129
diff changeset
74 and not hosts[module.host].s2sout[origin.from_host]
1387
db2ff8f29472 mod_bidi: Add option for selectively not doing bidi with some hosts
Kim Alvefur <zash@zash.se>
parents: 1191
diff changeset
75 and not disable_bidi_for:contains(origin.from_host)
1191
1818a7f08580 mod_bidi: Add missing 'is_bidi' flag for incoming s2s
Kim Alvefur <zash@zash.se>
parents: 1129
diff changeset
76 and (not secure_only or (origin.cert_chain_status == "valid"
1818a7f08580 mod_bidi: Add missing 'is_bidi' flag for incoming s2s
Kim Alvefur <zash@zash.se>
parents: 1129
diff changeset
77 and origin.cert_identity_status == "valid")) then
3721
c96a53bf67b3 mod_bidi: Recommend switching to native module on Prosody trunk
Kim Alvefur <zash@zash.se>
parents: 3720
diff changeset
78 if origin.incoming == true then
c96a53bf67b3 mod_bidi: Recommend switching to native module on Prosody trunk
Kim Alvefur <zash@zash.se>
parents: 3720
diff changeset
79 module:log("warn", "This module can now be replaced by mod_s2s_bidi which is included with Prosody");
c96a53bf67b3 mod_bidi: Recommend switching to native module on Prosody trunk
Kim Alvefur <zash@zash.se>
parents: 3720
diff changeset
80 end
892
148865199003 mod_bidi: Initial commit of XEP-0288 implementation
Kim Alvefur <zash@zash.se>
parents:
diff changeset
81 module:log("debug", "Announcing support for bidirectional streams");
148865199003 mod_bidi: Initial commit of XEP-0288 implementation
Kim Alvefur <zash@zash.se>
parents:
diff changeset
82 features:tag("bidi", { xmlns = xmlns_bidi_feature }):up();
148865199003 mod_bidi: Initial commit of XEP-0288 implementation
Kim Alvefur <zash@zash.se>
parents:
diff changeset
83 end
148865199003 mod_bidi: Initial commit of XEP-0288 implementation
Kim Alvefur <zash@zash.se>
parents:
diff changeset
84 end);
148865199003 mod_bidi: Initial commit of XEP-0288 implementation
Kim Alvefur <zash@zash.se>
parents:
diff changeset
85
148865199003 mod_bidi: Initial commit of XEP-0288 implementation
Kim Alvefur <zash@zash.se>
parents:
diff changeset
86 module:hook("stanza/urn:xmpp:bidi:bidi", function(event)
148865199003 mod_bidi: Initial commit of XEP-0288 implementation
Kim Alvefur <zash@zash.se>
parents:
diff changeset
87 local origin = event.session or event.origin;
1123
0e16e5e2f410 mod_bidi: Only allow or offer bidi on secure connections, with an option to revert to previous behaviour
Kim Alvefur <zash@zash.se>
parents: 1122
diff changeset
88 if not origin.is_bidi and not origin.bidi_session
1387
db2ff8f29472 mod_bidi: Add option for selectively not doing bidi with some hosts
Kim Alvefur <zash@zash.se>
parents: 1191
diff changeset
89 and not disable_bidi_for:contains(origin.from_host)
1123
0e16e5e2f410 mod_bidi: Only allow or offer bidi on secure connections, with an option to revert to previous behaviour
Kim Alvefur <zash@zash.se>
parents: 1122
diff changeset
90 and (not secure_only or origin.cert_chain_status == "valid"
0e16e5e2f410 mod_bidi: Only allow or offer bidi on secure connections, with an option to revert to previous behaviour
Kim Alvefur <zash@zash.se>
parents: 1122
diff changeset
91 and origin.cert_identity_status == "valid") then
892
148865199003 mod_bidi: Initial commit of XEP-0288 implementation
Kim Alvefur <zash@zash.se>
parents:
diff changeset
92 module:log("debug", "%s requested bidirectional stream", origin.from_host);
148865199003 mod_bidi: Initial commit of XEP-0288 implementation
Kim Alvefur <zash@zash.se>
parents:
diff changeset
93 origin.do_bidi = true;
148865199003 mod_bidi: Initial commit of XEP-0288 implementation
Kim Alvefur <zash@zash.se>
parents:
diff changeset
94 return true;
148865199003 mod_bidi: Initial commit of XEP-0288 implementation
Kim Alvefur <zash@zash.se>
parents:
diff changeset
95 end
148865199003 mod_bidi: Initial commit of XEP-0288 implementation
Kim Alvefur <zash@zash.se>
parents:
diff changeset
96 end);
148865199003 mod_bidi: Initial commit of XEP-0288 implementation
Kim Alvefur <zash@zash.se>
parents:
diff changeset
97
148865199003 mod_bidi: Initial commit of XEP-0288 implementation
Kim Alvefur <zash@zash.se>
parents:
diff changeset
98 -- Outgoing s2s
148865199003 mod_bidi: Initial commit of XEP-0288 implementation
Kim Alvefur <zash@zash.se>
parents:
diff changeset
99 module:hook("stanza/http://etherx.jabber.org/streams:features", function(event)
148865199003 mod_bidi: Initial commit of XEP-0288 implementation
Kim Alvefur <zash@zash.se>
parents:
diff changeset
100 local origin = event.session or event.origin;
148865199003 mod_bidi: Initial commit of XEP-0288 implementation
Kim Alvefur <zash@zash.se>
parents:
diff changeset
101 if not ( origin.bidi_session or origin.is_bidi or origin.do_bidi)
1387
db2ff8f29472 mod_bidi: Add option for selectively not doing bidi with some hosts
Kim Alvefur <zash@zash.se>
parents: 1191
diff changeset
102 and not disable_bidi_for:contains(origin.to_host)
1123
0e16e5e2f410 mod_bidi: Only allow or offer bidi on secure connections, with an option to revert to previous behaviour
Kim Alvefur <zash@zash.se>
parents: 1122
diff changeset
103 and event.stanza:get_child("bidi", xmlns_bidi_feature)
0e16e5e2f410 mod_bidi: Only allow or offer bidi on secure connections, with an option to revert to previous behaviour
Kim Alvefur <zash@zash.se>
parents: 1122
diff changeset
104 and (not secure_only or origin.cert_chain_status == "valid"
0e16e5e2f410 mod_bidi: Only allow or offer bidi on secure connections, with an option to revert to previous behaviour
Kim Alvefur <zash@zash.se>
parents: 1122
diff changeset
105 and origin.cert_identity_status == "valid") then
3721
c96a53bf67b3 mod_bidi: Recommend switching to native module on Prosody trunk
Kim Alvefur <zash@zash.se>
parents: 3720
diff changeset
106 if origin.outgoing == true then
c96a53bf67b3 mod_bidi: Recommend switching to native module on Prosody trunk
Kim Alvefur <zash@zash.se>
parents: 3720
diff changeset
107 module:log("warn", "This module can now be replaced by mod_s2s_bidi which is included with Prosody");
c96a53bf67b3 mod_bidi: Recommend switching to native module on Prosody trunk
Kim Alvefur <zash@zash.se>
parents: 3720
diff changeset
108 end
892
148865199003 mod_bidi: Initial commit of XEP-0288 implementation
Kim Alvefur <zash@zash.se>
parents:
diff changeset
109 module:log("debug", "%s supports bidirectional streams", origin.to_host);
148865199003 mod_bidi: Initial commit of XEP-0288 implementation
Kim Alvefur <zash@zash.se>
parents:
diff changeset
110 origin.sends2s(st.stanza("bidi", { xmlns = xmlns_bidi }));
148865199003 mod_bidi: Initial commit of XEP-0288 implementation
Kim Alvefur <zash@zash.se>
parents:
diff changeset
111 origin.do_bidi = true;
148865199003 mod_bidi: Initial commit of XEP-0288 implementation
Kim Alvefur <zash@zash.se>
parents:
diff changeset
112 end
148865199003 mod_bidi: Initial commit of XEP-0288 implementation
Kim Alvefur <zash@zash.se>
parents:
diff changeset
113 end, 160);
148865199003 mod_bidi: Initial commit of XEP-0288 implementation
Kim Alvefur <zash@zash.se>
parents:
diff changeset
114
148865199003 mod_bidi: Initial commit of XEP-0288 implementation
Kim Alvefur <zash@zash.se>
parents:
diff changeset
115 function enable_bidi(event)
148865199003 mod_bidi: Initial commit of XEP-0288 implementation
Kim Alvefur <zash@zash.se>
parents:
diff changeset
116 local session = event.session;
148865199003 mod_bidi: Initial commit of XEP-0288 implementation
Kim Alvefur <zash@zash.se>
parents:
diff changeset
117 if session.do_bidi and not ( session.is_bidi or session.bidi_session ) then
148865199003 mod_bidi: Initial commit of XEP-0288 implementation
Kim Alvefur <zash@zash.se>
parents:
diff changeset
118 session.do_bidi = nil;
148865199003 mod_bidi: Initial commit of XEP-0288 implementation
Kim Alvefur <zash@zash.se>
parents:
diff changeset
119 new_bidi(session);
148865199003 mod_bidi: Initial commit of XEP-0288 implementation
Kim Alvefur <zash@zash.se>
parents:
diff changeset
120 end
148865199003 mod_bidi: Initial commit of XEP-0288 implementation
Kim Alvefur <zash@zash.se>
parents:
diff changeset
121 end
148865199003 mod_bidi: Initial commit of XEP-0288 implementation
Kim Alvefur <zash@zash.se>
parents:
diff changeset
122
148865199003 mod_bidi: Initial commit of XEP-0288 implementation
Kim Alvefur <zash@zash.se>
parents:
diff changeset
123 module:hook("s2sin-established", enable_bidi);
148865199003 mod_bidi: Initial commit of XEP-0288 implementation
Kim Alvefur <zash@zash.se>
parents:
diff changeset
124 module:hook("s2sout-established", enable_bidi);
148865199003 mod_bidi: Initial commit of XEP-0288 implementation
Kim Alvefur <zash@zash.se>
parents:
diff changeset
125
148865199003 mod_bidi: Initial commit of XEP-0288 implementation
Kim Alvefur <zash@zash.se>
parents:
diff changeset
126 function disable_bidi(event)
148865199003 mod_bidi: Initial commit of XEP-0288 implementation
Kim Alvefur <zash@zash.se>
parents:
diff changeset
127 local session = event.session;
1122
6094d57c5387 mod_bidi: Minor cleanup
Kim Alvefur <zash@zash.se>
parents: 1121
diff changeset
128 if session.type == "s2sin" then
1121
c714ed7de4ee mod_bidi: Clean up and use 0.9+ routing APIs
Kim Alvefur <zash@zash.se>
parents: 932
diff changeset
129 bidi_sessions[session.from_host] = nil;
892
148865199003 mod_bidi: Initial commit of XEP-0288 implementation
Kim Alvefur <zash@zash.se>
parents:
diff changeset
130 end
148865199003 mod_bidi: Initial commit of XEP-0288 implementation
Kim Alvefur <zash@zash.se>
parents:
diff changeset
131 end
148865199003 mod_bidi: Initial commit of XEP-0288 implementation
Kim Alvefur <zash@zash.se>
parents:
diff changeset
132
148865199003 mod_bidi: Initial commit of XEP-0288 implementation
Kim Alvefur <zash@zash.se>
parents:
diff changeset
133 module:hook("s2sin-destroyed", disable_bidi);
148865199003 mod_bidi: Initial commit of XEP-0288 implementation
Kim Alvefur <zash@zash.se>
parents:
diff changeset
134 module:hook("s2sout-destroyed", disable_bidi);
148865199003 mod_bidi: Initial commit of XEP-0288 implementation
Kim Alvefur <zash@zash.se>
parents:
diff changeset
135