Comparison

core/s2smanager.lua @ 2419:00d985639a06

s2smanager: Trim trailing whitespace
author Matthew Wild <mwild1@gmail.com>
date Sun, 03 Jan 2010 18:37:03 +0000
parent 2382:5e37e28a429f
child 2420:6ccd36a95a81
comparison
equal deleted inserted replaced
2418:c35deaea53b9 2419:00d985639a06
140 if session.conn ~= conn or 140 if session.conn ~= conn or
141 session.type == "s2sin" then 141 session.type == "s2sin" then
142 return; -- Ok, we're connect[ed|ing] 142 return; -- Ok, we're connect[ed|ing]
143 end 143 end
144 -- Not connected, need to close session and clean up 144 -- Not connected, need to close session and clean up
145 (session.log or log)("warn", "Destroying incomplete session %s->%s due to inactivity", 145 (session.log or log)("warn", "Destroying incomplete session %s->%s due to inactivity",
146 session.from_host or "(unknown)", session.to_host or "(unknown)"); 146 session.from_host or "(unknown)", session.to_host or "(unknown)");
147 session:close("connection-timeout"); 147 session:close("connection-timeout");
148 end); 148 end);
149 return session; 149 return session;
150 end 150 end
151 151
152 function new_outgoing(from_host, to_host) 152 function new_outgoing(from_host, to_host)
153 local host_session = { to_host = to_host, from_host = from_host, host = from_host, 153 local host_session = { to_host = to_host, from_host = from_host, host = from_host,
154 notopen = true, type = "s2sout_unauthed", direction = "outgoing" }; 154 notopen = true, type = "s2sout_unauthed", direction = "outgoing" };
155 155
156 hosts[from_host].s2sout[to_host] = host_session; 156 hosts[from_host].s2sout[to_host] = host_session;
157 157
158 local log; 158 local log;
163 end 163 end
164 164
165 -- Kick the connection attempting machine 165 -- Kick the connection attempting machine
166 attempt_connection(host_session); 166 attempt_connection(host_session);
167 167
168 if not host_session.sends2s then 168 if not host_session.sends2s then
169 -- A sends2s which buffers data (until the stream is opened) 169 -- A sends2s which buffers data (until the stream is opened)
170 -- note that data in this buffer will be sent before the stream is authed 170 -- note that data in this buffer will be sent before the stream is authed
171 -- and will not be ack'd in any way, successful or otherwise 171 -- and will not be ack'd in any way, successful or otherwise
172 local buffer; 172 local buffer;
173 function host_session.sends2s(data) 173 function host_session.sends2s(data)
293 add_task(dns_timeout, function () 293 add_task(dns_timeout, function ()
294 if handle then 294 if handle then
295 adns.cancel(handle, true); 295 adns.cancel(handle, true);
296 end 296 end
297 end); 297 end);
298 298
299 return true; 299 return true;
300 end 300 end
301 301
302 function make_connect(host_session, connect_host, connect_port) 302 function make_connect(host_session, connect_host, connect_port)
303 host_session.log("info", "Beginning new connection attempt to %s (%s:%d)", host_session.to_host, connect_host, connect_port); 303 host_session.log("info", "Beginning new connection attempt to %s (%s:%d)", host_session.to_host, connect_host, connect_port);
332 host_session.type == "s2sout" or 332 host_session.type == "s2sout" or
333 host_session.connecting then 333 host_session.connecting then
334 return; -- Ok, we're connect[ed|ing] 334 return; -- Ok, we're connect[ed|ing]
335 end 335 end
336 -- Not connected, need to close session and clean up 336 -- Not connected, need to close session and clean up
337 (host_session.log or log)("warn", "Destroying incomplete session %s->%s due to inactivity", 337 (host_session.log or log)("warn", "Destroying incomplete session %s->%s due to inactivity",
338 host_session.from_host or "(unknown)", host_session.to_host or "(unknown)"); 338 host_session.from_host or "(unknown)", host_session.to_host or "(unknown)");
339 host_session:close("connection-timeout"); 339 host_session:close("connection-timeout");
340 end); 340 end);
341 return true; 341 return true;
342 end 342 end
367 -- Attempting to connect to a host we don't serve 367 -- Attempting to connect to a host we don't serve
368 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 });
369 return; 369 return;
370 end 370 end
371 send("<?xml version='1.0'?>"); 371 send("<?xml version='1.0'?>");
372 send(stanza("stream:stream", { xmlns='jabber:server', ["xmlns:db"]='jabber:server:dialback', 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()); 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
388 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
389 session.streamid = attr.id; 389 session.streamid = attr.id;
390 390
391 -- Send unauthed buffer 391 -- Send unauthed buffer
392 -- (stanzas which are fine to send before dialback) 392 -- (stanzas which are fine to send before dialback)
393 -- Note that this is *not* the stanza queue (which 393 -- Note that this is *not* the stanza queue (which
394 -- we can only send if auth succeeds) :) 394 -- we can only send if auth succeeds) :)
395 local send_buffer = session.send_buffer; 395 local send_buffer = session.send_buffer;
396 if send_buffer and #send_buffer > 0 then 396 if send_buffer and #send_buffer > 0 then
397 log("debug", "Sending s2s send_buffer now..."); 397 log("debug", "Sending s2s send_buffer now...");
398 for i, data in ipairs(send_buffer) do 398 for i, data in ipairs(send_buffer) do