Comparison

plugins/mod_s2s/mod_s2s.lua @ 6685:3f05b255937f

Merge 0.9->0.10
author Kim Alvefur <zash@zash.se>
date Wed, 13 May 2015 22:31:59 +0200
parent 6658:65563530375b
parent 6684:53635a91c95c
child 6690:b2e89583d6e6
child 6846:7eb166fa1f26
comparison
equal deleted inserted replaced
6678:343ca80ceb36 6685:3f05b255937f
164 end, -1); 164 end, -1);
165 end 165 end
166 166
167 -- Stream is authorised, and ready for normal stanzas 167 -- Stream is authorised, and ready for normal stanzas
168 function mark_connected(session) 168 function mark_connected(session)
169 local sendq, send = session.sendq, session.sends2s; 169 local sendq = session.sendq;
170 170
171 local from, to = session.from_host, session.to_host; 171 local from, to = session.from_host, session.to_host;
172 172
173 session.log("info", "%s s2s connection %s->%s complete", session.direction:gsub("^.", string.upper), from, to); 173 session.log("info", "%s s2s connection %s->%s complete", session.direction:gsub("^.", string.upper), from, to);
174 174
187 end 187 end
188 188
189 if session.direction == "outgoing" then 189 if session.direction == "outgoing" then
190 if sendq then 190 if sendq then
191 session.log("debug", "sending %d queued stanzas across new outgoing connection to %s", #sendq, session.to_host); 191 session.log("debug", "sending %d queued stanzas across new outgoing connection to %s", #sendq, session.to_host);
192 local send = session.sends2s;
192 for i, data in ipairs(sendq) do 193 for i, data in ipairs(sendq) do
193 send(data[1]); 194 send(data[1]);
194 sendq[i] = nil; 195 sendq[i] = nil;
195 end 196 end
196 session.sendq = nil; 197 session.sendq = nil;
256 local stream_callbacks = { default_ns = "jabber:server", handlestanza = core_process_stanza }; 257 local stream_callbacks = { default_ns = "jabber:server", handlestanza = core_process_stanza };
257 258
258 local xmlns_xmpp_streams = "urn:ietf:params:xml:ns:xmpp-streams"; 259 local xmlns_xmpp_streams = "urn:ietf:params:xml:ns:xmpp-streams";
259 260
260 function stream_callbacks.streamopened(session, attr) 261 function stream_callbacks.streamopened(session, attr)
261 local send = session.sends2s;
262
263 session.version = tonumber(attr.version) or 0; 262 session.version = tonumber(attr.version) or 0;
264 263
265 -- TODO: Rename session.secure to session.encrypted 264 -- TODO: Rename session.secure to session.encrypted
266 if session.secure == false then 265 if session.secure == false then
267 session.secure = true; 266 session.secure = true;
340 return; 339 return;
341 end 340 end
342 end 341 end
343 342
344 session:open_stream(session.to_host, session.from_host) 343 session:open_stream(session.to_host, session.from_host)
344 session.notopen = nil;
345 if session.version >= 1.0 then 345 if session.version >= 1.0 then
346 local features = st.stanza("stream:features"); 346 local features = st.stanza("stream:features");
347 347
348 if to then 348 if to then
349 hosts[to].events.fire_event("s2s-stream-features", { origin = session, features = features }); 349 hosts[to].events.fire_event("s2s-stream-features", { origin = session, features = features });
350 else 350 else
351 (session.log or log)("warn", "No 'to' on stream header from %s means we can't offer any features", from or session.ip or "unknown host"); 351 (session.log or log)("warn", "No 'to' on stream header from %s means we can't offer any features", from or session.ip or "unknown host");
352 end 352 end
353 353
354 log("debug", "Sending stream features: %s", tostring(features)); 354 log("debug", "Sending stream features: %s", tostring(features));
355 send(features); 355 session.sends2s(features);
356 end 356 end
357 session.notopen = nil;
358 elseif session.direction == "outgoing" then 357 elseif session.direction == "outgoing" then
359 session.notopen = nil; 358 session.notopen = nil;
360 if not attr.id then 359 if not attr.id then
361 log("error", "Stream response did not give us a stream id!"); 360 log("error", "Stream response did not give us a stream id!");
362 session:close({ condition = "undefined-condition", text = "Missing stream ID" }); 361 session:close({ condition = "undefined-condition", text = "Missing stream ID" });