Comparison

plugins/mod_s2s/mod_s2s.lua @ 6690:b2e89583d6e6

Merge 0.10->trunk
author Kim Alvefur <zash@zash.se>
date Wed, 13 May 2015 22:33:40 +0200
parent 6666:42fdc8dddf04
parent 6685:3f05b255937f
child 6847:c314e9142e9d
comparison
equal deleted inserted replaced
6679:96e034508978 6690:b2e89583d6e6
167 end, -1); 167 end, -1);
168 end 168 end
169 169
170 -- Stream is authorised, and ready for normal stanzas 170 -- Stream is authorised, and ready for normal stanzas
171 function mark_connected(session) 171 function mark_connected(session)
172 local sendq, send = session.sendq, session.sends2s; 172 local sendq = session.sendq;
173 173
174 local from, to = session.from_host, session.to_host; 174 local from, to = session.from_host, session.to_host;
175 175
176 session.log("info", "%s s2s connection %s->%s complete", session.direction:gsub("^.", string.upper), from, to); 176 session.log("info", "%s s2s connection %s->%s complete", session.direction:gsub("^.", string.upper), from, to);
177 177
190 end 190 end
191 191
192 if session.direction == "outgoing" then 192 if session.direction == "outgoing" then
193 if sendq then 193 if sendq then
194 session.log("debug", "sending %d queued stanzas across new outgoing connection to %s", #sendq, session.to_host); 194 session.log("debug", "sending %d queued stanzas across new outgoing connection to %s", #sendq, session.to_host);
195 local send = session.sends2s;
195 for i, data in ipairs(sendq) do 196 for i, data in ipairs(sendq) do
196 send(data[1]); 197 send(data[1]);
197 sendq[i] = nil; 198 sendq[i] = nil;
198 end 199 end
199 session.sendq = nil; 200 session.sendq = nil;
259 local stream_callbacks = { default_ns = "jabber:server", handlestanza = core_process_stanza }; 260 local stream_callbacks = { default_ns = "jabber:server", handlestanza = core_process_stanza };
260 261
261 local xmlns_xmpp_streams = "urn:ietf:params:xml:ns:xmpp-streams"; 262 local xmlns_xmpp_streams = "urn:ietf:params:xml:ns:xmpp-streams";
262 263
263 function stream_callbacks.streamopened(session, attr) 264 function stream_callbacks.streamopened(session, attr)
264 local send = session.sends2s;
265
266 session.version = tonumber(attr.version) or 0; 265 session.version = tonumber(attr.version) or 0;
267 266
268 -- TODO: Rename session.secure to session.encrypted 267 -- TODO: Rename session.secure to session.encrypted
269 if session.secure == false then 268 if session.secure == false then
270 session.secure = true; 269 session.secure = true;
343 return; 342 return;
344 end 343 end
345 end 344 end
346 345
347 session:open_stream(session.to_host, session.from_host) 346 session:open_stream(session.to_host, session.from_host)
347 session.notopen = nil;
348 if session.version >= 1.0 then 348 if session.version >= 1.0 then
349 local features = st.stanza("stream:features"); 349 local features = st.stanza("stream:features");
350 350
351 if to then 351 if to then
352 hosts[to].events.fire_event("s2s-stream-features", { origin = session, features = features }); 352 hosts[to].events.fire_event("s2s-stream-features", { origin = session, features = features });
353 else 353 else
354 (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"); 354 (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");
355 end 355 end
356 356
357 log("debug", "Sending stream features: %s", tostring(features)); 357 log("debug", "Sending stream features: %s", tostring(features));
358 send(features); 358 session.sends2s(features);
359 end 359 end
360 session.notopen = nil;
361 elseif session.direction == "outgoing" then 360 elseif session.direction == "outgoing" then
362 session.notopen = nil; 361 session.notopen = nil;
363 if not attr.id then 362 if not attr.id then
364 log("error", "Stream response did not give us a stream id!"); 363 log("error", "Stream response did not give us a stream id!");
365 session:close({ condition = "undefined-condition", text = "Missing stream ID" }); 364 session:close({ condition = "undefined-condition", text = "Missing stream ID" });