comparison mod_bidi/mod_bidi.lua @ 1191:1818a7f08580

mod_bidi: Add missing 'is_bidi' flag for incoming s2s
author Kim Alvefur <zash@zash.se>
date Wed, 11 Sep 2013 21:43:49 +0200
parents ae0fa4d2005d
children db2ff8f29472
comparison
equal deleted inserted replaced
1190:c99d8b666eb4 1191:1818a7f08580
32 if conflicting_session then 32 if conflicting_session then
33 conflicting_session.log("info", "We already have an outgoing connection to %s, closing it...", origin.from_host); 33 conflicting_session.log("info", "We already have an outgoing connection to %s, closing it...", origin.from_host);
34 conflicting_session:close{ condition = "conflict", text = "Replaced by bidirectional stream" } 34 conflicting_session:close{ condition = "conflict", text = "Replaced by bidirectional stream" }
35 end 35 end
36 bidi_sessions[origin.from_host] = origin; 36 bidi_sessions[origin.from_host] = origin;
37 origin.is_bidi = true;
37 elseif origin.type == "s2sout" then -- handle incoming stanzas correctly 38 elseif origin.type == "s2sout" then -- handle incoming stanzas correctly
38 local bidi_session = { 39 local bidi_session = {
39 type = "s2sin"; direction = "incoming"; 40 type = "s2sin"; direction = "incoming";
40 is_bidi = true; orig_session = origin; 41 is_bidi = true; orig_session = origin;
41 to_host = origin.from_host; 42 to_host = origin.from_host;
64 end, -2); 65 end, -2);
65 66
66 -- Incoming s2s 67 -- Incoming s2s
67 module:hook("s2s-stream-features", function(event) 68 module:hook("s2s-stream-features", function(event)
68 local origin, features = event.origin, event.features; 69 local origin, features = event.origin, event.features;
69 if not origin.is_bidi and not hosts[module.host].s2sout[origin.from_host] 70 if not origin.is_bidi and not origin.bidi_session and not origin.do_bidi
70 and (not secure_only or origin.cert_chain_status == "valid" 71 and not hosts[module.host].s2sout[origin.from_host]
71 and origin.cert_identity_status == "valid") then 72 and (not secure_only or (origin.cert_chain_status == "valid"
73 and origin.cert_identity_status == "valid")) then
72 module:log("debug", "Announcing support for bidirectional streams"); 74 module:log("debug", "Announcing support for bidirectional streams");
73 features:tag("bidi", { xmlns = xmlns_bidi_feature }):up(); 75 features:tag("bidi", { xmlns = xmlns_bidi_feature }):up();
74 end 76 end
75 end); 77 end);
76 78