core/s2smanager.lua

changeset 2378
bc1ae371ad54
parent 2377
78c5cb163ea9
child 2381
7926f513816b
equal deleted inserted replaced
2377:78c5cb163ea9 2378:bc1ae371ad54
372 session:close({ condition = "host-unknown"; text = "This host does not serve "..session.to_host }); 372 session:close({ condition = "host-unknown"; text = "This host does not serve "..session.to_host });
373 return; 373 return;
374 end 374 end
375 if session.version >= 1.0 then 375 if session.version >= 1.0 then
376 local features = st.stanza("stream:features"); 376 local features = st.stanza("stream:features");
377
378 if session.to_host then 377 if session.to_host then
379 hosts[session.to_host].events.fire_event("s2s-stream-features", { session = session, features = features }); 378 hosts[session.to_host].events.fire_event("s2s-stream-features", { session = session, features = features });
380 else 379 else
381 (session.log or log)("warn", "No 'to' on stream header from %s means we can't offer any features", session.from_host or "unknown host"); 380 (session.log or log)("warn", "No 'to' on stream header from %s means we can't offer any features", session.from_host or "unknown host");
382 end 381 end
389 if not attr.id then error("stream response did not give us a streamid!!!"); end 388 if not attr.id then error("stream response did not give us a streamid!!!"); end
390 session.streamid = attr.id; 389 session.streamid = attr.id;
391 390
392 -- Send unauthed buffer 391 -- Send unauthed buffer
393 -- (stanzas which are fine to send before dialback) 392 -- (stanzas which are fine to send before dialback)
394 -- Note that this is *not* the stanza queue (which 393 -- Note that this is *not* the stanza queue (which
395 -- we can only send if auth succeeds) :) 394 -- we can only send if auth succeeds) :)
396 local send_buffer = session.send_buffer; 395 local send_buffer = session.send_buffer;
397 if send_buffer and #send_buffer > 0 then 396 if send_buffer and #send_buffer > 0 then
398 log("debug", "Sending s2s send_buffer now..."); 397 log("debug", "Sending s2s send_buffer now...");
399 for i, data in ipairs(send_buffer) do 398 for i, data in ipairs(send_buffer) do
477 send(data[1]); 476 send(data[1]);
478 sendq[i] = nil; 477 sendq[i] = nil;
479 end 478 end
480 session.sendq = nil; 479 session.sendq = nil;
481 end 480 end
482
483 session.srv_hosts = nil; 481 session.srv_hosts = nil;
484 end 482 end
485 end 483 end
486 484
487 function destroy_session(session, reason) 485 function destroy_session(session, reason)

mercurial