Comparison

core/s2smanager.lua @ 2380:1c7839fbbe9d

s2smanager: Send reply stream header only after checking we serve this host (sorry darkrain... :) )
author Matthew Wild <mwild1@gmail.com>
date Thu, 17 Dec 2009 21:36:31 +0000
parent 2379:66ba153d3f09
child 2381:7926f513816b
comparison
equal deleted inserted replaced
2379:66ba153d3f09 2380:1c7839fbbe9d
361 session.to_host = attr.to and nameprep(attr.to); 361 session.to_host = attr.to and nameprep(attr.to);
362 session.from_host = attr.from and nameprep(attr.from); 362 session.from_host = attr.from and nameprep(attr.from);
363 363
364 session.streamid = uuid_gen(); 364 session.streamid = uuid_gen();
365 (session.log or log)("debug", "incoming s2s received <stream:stream>"); 365 (session.log or log)("debug", "incoming s2s received <stream:stream>");
366 send("<?xml version='1.0'?>");
367 send(stanza("stream:stream", { xmlns='jabber:server', ["xmlns:db"]='jabber:server:dialback',
368 ["xmlns:stream"]='http://etherx.jabber.org/streams', id=session.streamid, from=session.to_host, version=(session.version > 0 and "1.0" or nil) }):top_tag());
369 if session.to_host and not hosts[session.to_host] then 366 if session.to_host and not hosts[session.to_host] then
370 -- Attempting to connect to a host we don't serve 367 -- Attempting to connect to a host we don't serve
371 session:close({ condition = "host-unknown"; text = "This host does not serve "..session.to_host }); 368 session:close({ condition = "host-unknown"; text = "This host does not serve "..session.to_host });
372 return; 369 return;
373 end 370 end
371 send("<?xml version='1.0'?>");
372 send(stanza("stream:stream", { xmlns='jabber:server', ["xmlns:db"]='jabber:server:dialback',
373 ["xmlns:stream"]='http://etherx.jabber.org/streams', id=session.streamid, from=session.to_host, version=(session.version > 0 and "1.0" or nil) }):top_tag());
374 if session.version >= 1.0 then 374 if session.version >= 1.0 then
375 local features = st.stanza("stream:features"); 375 local features = st.stanza("stream:features");
376 376
377 if session.to_host then 377 if session.to_host then
378 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 });
379 else 379 else
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"); 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");
381 end 381 end