Software /
code /
prosody
Changeset
2133:5c1758ccf8b9
Merge with trunk
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Sun, 22 Nov 2009 04:50:42 +0000 |
parents | 2131:72411e239221 (diff) 2132:20a52cfda988 (current diff) |
children | 2134:9044e7cfefc2 |
files | core/s2smanager.lua |
diffstat | 15 files changed, 107 insertions(+), 93 deletions(-) [+] |
line wrap: on
line diff
--- a/core/s2smanager.lua Sun Nov 22 04:46:48 2009 +0000 +++ b/core/s2smanager.lua Sun Nov 22 04:50:42 2009 +0000 @@ -128,7 +128,7 @@ open_sessions = open_sessions + 1; local w, log = conn.write, logger_init("s2sin"..tostring(conn):match("[a-f0-9]+$")); session.log = log; - session.sends2s = function (t) log("debug", "sending: %s", (t.top_tag and t:top_tag()) or t:match("^([^>]*>?)")); w(tostring(t)); end + session.sends2s = function (t) log("debug", "sending: %s", (t.top_tag and t:top_tag()) or t:match("^([^>]*>?)"); w(conn, tostring(t)); end incoming_s2s[session] = true; add_task(connect_timeout, function () if session.conn ~= conn or @@ -317,9 +317,9 @@ cl.register_outgoing(conn, host_session); local w, log = conn.write, host_session.log; - host_session.sends2s = function (t) log("debug", "sending: %s", (t.top_tag and t:top_tag()) or t:match("^[^>]*>?")); w(tostring(t)); end + host_session.sends2s = function (t) log("debug", "sending: %s", (t.top_tag and t:top_tag()) or t:match("^[^>]*>?")); w(conn, tostring(t)); end - conn.write(format([[<stream:stream xmlns='jabber:server' xmlns:db='jabber:server:dialback' xmlns:stream='http://etherx.jabber.org/streams' from='%s' to='%s' version='1.0' xml:lang='en'>]], from_host, to_host)); + conn:write(format([[<stream:stream xmlns='jabber:server' xmlns:db='jabber:server:dialback' xmlns:stream='http://etherx.jabber.org/streams' from='%s' to='%s' version='1.0' xml:lang='en'>]], from_host, to_host)); log("debug", "Connection attempt in progress..."); add_task(connect_timeout, function () if host_session.conn ~= conn or @@ -391,7 +391,7 @@ if send_buffer and #send_buffer > 0 then log("debug", "Sending s2s send_buffer now..."); for i, data in ipairs(send_buffer) do - session.sends2s(data); + session.sends2s(tostring(data)); send_buffer[i] = nil; end end
--- a/core/sessionmanager.lua Sun Nov 22 04:46:48 2009 +0000 +++ b/core/sessionmanager.lua Sun Nov 22 04:50:42 2009 +0000 @@ -50,8 +50,8 @@ open_sessions = open_sessions + 1; log("debug", "open sessions now: ".. open_sessions); local w = conn.write; - session.send = function (t) w(tostring(t)); end - session.ip = conn.ip(); + session.send = function (t) w(conn, tostring(t)); end + session.ip = conn:ip(); local conn_name = "c2s"..tostring(conn):match("[a-f0-9]+$"); session.log = logger.init(conn_name);
--- a/net/adns.lua Sun Nov 22 04:46:48 2009 +0000 +++ b/net/adns.lua Sun Nov 22 04:50:42 2009 +0000 @@ -45,10 +45,10 @@ function new_async_socket(sock, resolver) local newconn, peername = {}, "<unknown>"; local listener = {}; - function listener.incoming(conn, data) + function listener.onincoming(conn, data) dns.feed(sock, data); end - function listener.disconnect(conn, err) + function listener.ondisconnect(conn, err) log("warn", "DNS socket for %s disconnected: %s", peername, err); local servers = resolver.server; if resolver.socketset[newconn.handler] == resolver.best_server and resolver.best_server == #servers then @@ -68,7 +68,7 @@ newconn.handler.setsockname = function (_, ...) return sock:setsockname(...); end newconn.handler.setpeername = function (_, ...) peername = (...); local ret = sock:setpeername(...); _.setsend(sock.send); return ret; end newconn.handler.connect = function (_, ...) return sock:connect(...) end - newconn.handler.send = function (_, data) _.write(data); return _.sendbuffer(); end + newconn.handler.send = function (_, data) _.write(_, data); return _.sendbuffer(); end return newconn.handler; end
--- a/net/connlisteners.lua Sun Nov 22 04:46:48 2009 +0000 +++ b/net/connlisteners.lua Sun Nov 22 04:50:42 2009 +0000 @@ -61,9 +61,14 @@ end end - return server.addserver(h, - (udata and udata.port) or h.default_port or error("Can't start listener "..name.." because no port was specified, and it has no default port", 0), - (udata and udata.interface) or h.default_interface or "*", (udata and udata.mode) or h.default_mode or 1, (udata and udata.ssl) or nil, 99999999, udata and udata.type == "ssl"); + local interface = (udata and udata.interface) or h.default_interface or "*"; + local port = (udata and udata.port) or h.default_port or error("Can't start listener "..name.." because no port was specified, and it has no default port", 0); + local mode = (udata and udata.mode) or h.default_mode or 1; + local ssl = (udata and udata.ssl) or nil; + local maxclients = 99999999; + local autossl = udata and udata.type == "ssl"; + + return server.addserver(interface, port, h, mode, ssl, autossl); end return _M;
--- a/net/http.lua Sun Nov 22 04:46:48 2009 +0000 +++ b/net/http.lua Sun Nov 22 04:50:42 2009 +0000 @@ -152,7 +152,7 @@ end req.handler, req.conn = server.wrapclient(socket.tcp(), req.host, req.port or 80, listener, "*a"); - req.write = req.handler.write; + req.write = function (...) return req.handler:write(...); end req.conn:settimeout(0); local ok, err = req.conn:connect(req.host, req.port or 80); if not ok and err ~= "timeout" then @@ -200,7 +200,7 @@ function destroy_request(request) if request.conn then request.handler.close() - listener.disconnect(request.conn, "closed"); + listener.ondisconnect(request.conn, "closed"); end end
--- a/net/httpclient_listener.lua Sun Nov 22 04:46:48 2009 +0000 +++ b/net/httpclient_listener.lua Sun Nov 22 04:50:42 2009 +0000 @@ -15,7 +15,7 @@ local httpclient = { default_port = 80, default_mode = "*a" }; -function httpclient.listener(conn, data) +function httpclient.onincoming(conn, data) local request = requests[conn]; if not request then @@ -28,7 +28,7 @@ end end -function httpclient.disconnect(conn, err) +function httpclient.ondisconnect(conn, err) local request = requests[conn]; if request then request:reader(nil);
--- a/net/httpserver.lua Sun Nov 22 04:46:48 2009 +0000 +++ b/net/httpserver.lua Sun Nov 22 04:50:42 2009 +0000 @@ -209,7 +209,7 @@ function new_request(handler) return { handler = handler, conn = handler.socket, - write = handler.write, state = "request", + write = function (...) return handler:write(...); end, state = "request", server = http_servers[handler.serverport()], send = send_response, destroy = destroy_request, @@ -230,7 +230,7 @@ end request.handler.close() if request.conn then - listener.disconnect(request.handler, "closed"); + listener.ondisconnect(request.handler, "closed"); end end end
--- a/net/httpserver_listener.lua Sun Nov 22 04:46:48 2009 +0000 +++ b/net/httpserver_listener.lua Sun Nov 22 04:50:42 2009 +0000 @@ -16,7 +16,7 @@ local httpserver = { default_port = 80, default_mode = "*a" }; -function httpserver.listener(conn, data) +function httpserver.onincoming(conn, data) local request = requests[conn]; if not request then @@ -34,7 +34,7 @@ end end -function httpserver.disconnect(conn, err) +function httpserver.ondisconnect(conn, err) local request = requests[conn]; if request and not request.destroyed then request.conn = nil;
--- a/net/server.lua Sun Nov 22 04:46:48 2009 +0000 +++ b/net/server.lua Sun Nov 22 04:50:42 2009 +0000 @@ -9,7 +9,7 @@ -- Backwards compatibility for timers, addtimer -- called a function roughly every second - local add_task = require "util.timer"; + local add_task = require "util.timer".add_task; function server.addtimer(f) return add_task(1, function (...) f(...); return 1; end); end
--- a/net/server_event.lua Sun Nov 22 04:46:48 2009 +0000 +++ b/net/server_event.lua Sun Nov 22 04:50:42 2009 +0000 @@ -52,6 +52,7 @@ local function debug(...) return log("debug", ("%s "):rep(select('#', ...)), ...) end +local vdebug = debug; local bitor = ( function( ) -- thx Rici Lake local hasbit = function( x, p ) @@ -139,14 +140,14 @@ self.fatalerror = "connection timeout" self.listener.ontimeout( self ) -- call timeout listener self:_close() - debug( "new connection failed. id:", self, "error:", self.fatalerror ) + debug( "new connection failed. id:", self.id, "error:", self.fatalerror ) else if plainssl then -- start ssl session self:_start_ssl( self.listener.onconnect ) else -- normal connection self:_start_session( self.listener.onconnect ) end - debug( "new connection established. id:", self ) + debug( "new connection established. id:", self.id ) end self.eventconnect = nil return -1 @@ -158,28 +159,28 @@ if self.type == "client" then local callback = function( ) self:_lock( false, false, false ) - --vdebug( "start listening on client socket with id:", self ) + --vdebug( "start listening on client socket with id:", self.id ) self.eventread = addevent( base, self.conn, EV_READ, self.readcallback, cfg.READ_TIMEOUT ) -- register callback - onconnect( self ) + self:onconnect() self.eventsession = nil return -1 end self.eventsession = addevent( base, nil, EV_TIMEOUT, callback, 0 ) else self:_lock( false ) - --vdebug( "start listening on server socket with id:", self ) + --vdebug( "start listening on server socket with id:", self.id ) self.eventread = addevent( base, self.conn, EV_READ, self.readcallback ) -- register callback end return true end function interface_mt:_start_ssl(arg) -- old socket will be destroyed, therefore we have to close read/write events first - --vdebug( "starting ssl session with client id:", self ) + --vdebug( "starting ssl session with client id:", self.id ) local _ _ = self.eventread and self.eventread:close( ) -- close events; this must be called outside of the event callbacks! _ = self.eventwrite and self.eventwrite:close( ) self.eventread, self.eventwrite = nil, nil local err - self.conn, err = ssl.wrap( self.conn, self.sslctx ) + self.conn, err = ssl.wrap( self.conn, self._sslctx ) if err then self.fatalerror = err self.conn = nil -- cannot be used anymore @@ -198,7 +199,7 @@ local maxattempt = cfg.MAX_HANDSHAKE_ATTEMPS while attempt < 1000 do -- no endless loop attempt = attempt + 1 - debug( "ssl handshake of client with id:", self, "attemp:", attempt ) + debug( "ssl handshake of client with id:"..tostring(self).."attemp:"..attempt ) if attempt > maxattempt then self.fatalerror = "max handshake attemps exceeded" elseif EV_TIMEOUT == event then @@ -211,16 +212,16 @@ self.receive = self.conn.receive local onsomething if "onconnect" == arg then -- trigger listener - onsomething = self.listener.onconnect + onsomething = self.onconnect else - onsomething = self.listener.onsslconnection + onsomething = self.onsslconnection end self:_start_session( onsomething ) debug( "ssl handshake done" ) self.eventhandshake = nil return -1 end - debug( "error during ssl handshake:", err ) + debug( "error during ssl handshake:", err ) if err == "wantwrite" then event = EV_WRITE elseif err == "wantread" then @@ -248,7 +249,7 @@ return true end function interface_mt:_destroy() -- close this interface + events and call last listener - debug( "closing client with id:", self ) + debug( "closing client with id:", self.id ) self:_lock( true, true, true ) -- first of all, lock the interface to avoid further actions local _ _ = self.eventread and self.eventread:close( ) -- close events; this must be called outside of the event callbacks! @@ -274,6 +275,7 @@ interfacelist( "delete", self ) return true end + function interface_mt:_lock(nointerface, noreading, nowriting) -- lock or unlock this interface or events self.nointerface, self.noreading, self.nowriting = nointerface, noreading, nowriting return nointerface, noreading, nowriting @@ -288,7 +290,8 @@ -- Public methods function interface_mt:write(data) - --vdebug( "try to send data to client, id/data:", self, data ) + if self.nowriting then return nil, "locked" end + --vdebug( "try to send data to client, id/data:", self.id, data ) data = tostring( data ) local len = string_len( data ) local total = len + self.writebufferlen @@ -306,7 +309,8 @@ return true end function interface_mt:close(now) - debug( "try to close client connection with id:", self ) + if self.nointerface then return nil, "locked"; end + debug( "try to close client connection with id:", self.id ) if self.type == "client" then self.fatalerror = "client to close" if ( not self.eventwrite ) or now then -- try to close immediately @@ -319,7 +323,7 @@ return nil, "writebuffer not empty, waiting" end else - debug( "try to close server with id:", self, "args:", now ) + debug( "try to close server with id:", self.id, "args:", now ) self.fatalerror = "server to close" self:_lock( true ) local count = 0 @@ -353,7 +357,7 @@ end function interface_mt:ssl() - return self.usingssl + return self._usingssl end function interface_mt:type() @@ -368,22 +372,25 @@ return self.addr end - + function interface_mt:set_sslctx(sslctx) + self._sslctx = sslctx; + end function interface_mt:starttls() - debug( "try to start ssl at client id:", self ) + debug( "try to start ssl at client id:", self.id ) local err - if not self.sslctx then -- no ssl available + if not self._sslctx then -- no ssl available err = "no ssl context available" - elseif self.usingssl then -- startssl was already called + elseif self._usingssl then -- startssl was already called err = "ssl already active" end if err then debug( "error:", err ) return nil, err end - self.usingssl = true + self._usingssl = true self.startsslcallback = function( ) -- we have to start the handshake outside of a read/write event + self.startsslcallback = nil self:_start_ssl(); self.eventstarthandshake = nil return -1 @@ -443,6 +450,7 @@ _sslctx = sslctx; -- parameters _usingssl = false; -- client is using ssl; } + interface.id = tostring(interface):match("%x+$"); interface.writecallback = function( event ) -- called on write events --vdebug( "new client write event, id/ip/port:", interface, ip, port ) if interface.nowriting or ( interface.fatalerror and ( "client to close" ~= interface.fatalerror ) ) then -- leave this event @@ -457,7 +465,7 @@ interface.eventwrite = false return -1 else -- can write :) - if interface.usingssl then -- handle luasec + if interface._usingssl then -- handle luasec if interface.eventreadtimeout then -- we have to read first local ret = interface.readcallback( ) -- call readcallback --vdebug( "tried to read in writecallback, result:", ret ) @@ -467,7 +475,7 @@ interface.eventwritetimeout = false end end - local succ, err, byte = interface.send( interface.conn, interface.writebuffer, 1, interface.writebufferlen ) + local succ, err, byte = interface.conn:send( interface.writebuffer, 1, interface.writebufferlen ) --vdebug( "write data:", interface.writebuffer, "error:", err, "part:", byte ) if succ then -- writing succesful interface.writebuffer = "" @@ -508,7 +516,7 @@ end end end - local usingssl, receive = interface._usingssl, interface.receive; + interface.readcallback = function( event ) -- called on read events --vdebug( "new client read event, id/ip/port:", interface, ip, port ) if interface.noreading or interface.fatalerror then -- leave this event @@ -523,7 +531,7 @@ interface.eventread = nil return -1 else -- can read - if usingssl then -- handle luasec + if interface._usingssl then -- handle luasec if interface.eventwritetimeout then -- ok, in the past writecallback was regged local ret = interface.writecallback( ) -- call it --vdebug( "tried to write in readcallback, result:", ret ) @@ -533,8 +541,8 @@ interface.eventreadtimeout = nil end end - local buffer, err, part = receive( client, pattern ) -- receive buffer with "pattern" - --vdebug( "read data:", buffer, "error:", err, "part:", part ) + local buffer, err, part = interface.conn:receive( pattern ) -- receive buffer with "pattern" + --vdebug( "read data:", tostring(buffer), "error:", tostring(err), "part:", tostring(part) ) buffer = buffer or part or "" local len = string_len( buffer ) if len > cfg.MAX_READ_LENGTH then -- check buffer length @@ -544,7 +552,7 @@ interface.eventread = nil return -1 end - if err and ( "timeout" ~= err ) then + if err and ( err ~= "timeout" and err ~= "wantread" ) then if "wantwrite" == err then -- need to read on write event if not interface.eventwrite then -- register new write event if needed interface.eventwrite = addevent( base, interface.conn, EV_WRITE, interface.writecallback, cfg.WRITE_TIMEOUT ) @@ -591,6 +599,7 @@ fatalerror = false; -- error message nointerface = true; -- lock/unlock parameter } + interface.id = tostring(interface):match("%x+$"); interface.readcallback = function( event ) -- server handler, called on incoming connections --vdebug( "server can accept, id/addr/port:", interface, addr, port ) if interface.fatalerror then @@ -639,9 +648,9 @@ end local addserver = ( function( ) - return function( addr, port, listener, pattern, backlog, sslcfg, startssl ) -- TODO: check arguments + return function( addr, port, listener, pattern, sslcfg, startssl ) -- TODO: check arguments --vdebug( "creating new tcp server with following parameters:", addr or "nil", port or "nil", sslcfg or "nil", startssl or "nil") - local server, err = socket.bind( addr, port, backlog ) -- create server socket + local server, err = socket.bind( addr, port, cfg.ACCEPT_QUEUE ) -- create server socket if not server then debug( "creating server socket failed because:", err ) return nil, err
--- a/net/server_select.lua Sun Nov 22 04:46:48 2009 +0000 +++ b/net/server_select.lua Sun Nov 22 04:50:42 2009 +0000 @@ -166,7 +166,7 @@ local connections = 0 - local dispatch, disconnect = listeners.incoming or listeners.listener, listeners.disconnect + local dispatch, disconnect = listeners.onincoming, listeners.ondisconnect local err @@ -241,7 +241,7 @@ for _, handler in pairs( _socketlist ) do if handler.serverport == serverport then handler.disconnect( handler, "server closed" ) - handler.close( true ) + handler:close( true ) end end socket:close( ) @@ -300,9 +300,9 @@ local ssl - local dispatch = listeners.incoming or listeners.listener + local dispatch = listeners.onincoming local status = listeners.status - local disconnect = listeners.disconnect + local disconnect = listeners.ondisconnect local bufferqueue = { } -- buffer array local bufferqueuelen = 0 -- end of buffer array @@ -331,9 +331,9 @@ handler.disconnect = function( ) return disconnect end - handler.setlistener = function( listeners ) - dispatch = listeners.incoming - disconnect = listeners.disconnect + handler.setlistener = function( self, listeners ) + dispatch = listeners.onincoming + disconnect = listeners.ondisconnect end handler.getstats = function( ) return readtraffic, sendtraffic @@ -400,7 +400,7 @@ handler.clientport = function( ) return clientport end - local write = function( data ) + local write = function( self, data ) bufferlen = bufferlen + string_len( data ) if bufferlen > maxsendlen then _closelist[ handler ] = "send buffer exceeded" -- cannot close the client at the moment, have to wait to the end of the cycle @@ -417,26 +417,26 @@ return true end handler.write = write - handler.bufferqueue = function( ) + handler.bufferqueue = function( self ) return bufferqueue end - handler.socket = function( ) + handler.socket = function( self ) return socket end - handler.pattern = function( new ) + handler.pattern = function( self, new ) pattern = new or pattern return pattern end - handler.setsend = function ( newsend ) + handler.setsend = function ( self, newsend ) send = newsend or send return send end - handler.bufferlen = function( readlen, sendlen ) + handler.bufferlen = function( self, readlen, sendlen ) maxsendlen = sendlen or maxsendlen maxreadlen = readlen or maxreadlen return maxreadlen, maxsendlen end - handler.lock = function( switch ) + handler.lock = function( self, switch ) if switch == true then handler.write = idfalse local tmp = _sendlistlen @@ -507,7 +507,7 @@ bufferqueuelen = 0 bufferlen = 0 _sendlistlen = removesocket( _sendlist, socket, _sendlistlen ) -- delete socket from writelist - _ = needtls and handler.starttls(true) + _ = needtls and handler:starttls(true) _writetimes[ handler ] = nil _ = toclose and handler.close( ) return true @@ -529,7 +529,7 @@ -- Set the sslctx local handshake; - function handler.set_sslctx(new_sslctx) + function handler.set_sslctx(self, new_sslctx) ssl = true sslctx = new_sslctx; local wrote @@ -564,13 +564,13 @@ end end disconnect( handler, "ssl handshake failed" ) - _ = handler and handler.close( true ) -- forced disconnect + _ = handler and handler:close( true ) -- forced disconnect return false -- handshake failed end ) end if sslctx then -- ssl? - handler.set_sslctx(sslctx); + handler:set_sslctx(sslctx); if startssl then -- ssl now? --out_put("server.lua: ", "starting ssl handshake") local err @@ -590,7 +590,7 @@ else -- We're not automatically doing SSL, so we're not secure (yet) ssl = false - handler.starttls = function( now ) + handler.starttls = function( self, now ) if not now then --out_put "server.lua: we need to do tls, but delaying until later" needtls = true @@ -692,7 +692,7 @@ ----------------------------------// PUBLIC //-- -addserver = function( listeners, port, addr, pattern, sslctx, maxconnections, startssl ) -- this function provides a way for other scripts to reg a server +addserver = function( addr, port, listeners, pattern, sslctx, startssl ) -- this function provides a way for other scripts to reg a server local err --out_put("server.lua: autossl on ", port, " is ", startssl) if type( listeners ) ~= "table" then @@ -715,7 +715,7 @@ out_error( "server.lua, port ", port, ": ", err ) return nil, err end - local handler, err = wrapserver( listeners, server, addr, port, pattern, sslctx, maxconnections, startssl ) -- wrap new server socket + local handler, err = wrapserver( listeners, server, addr, port, pattern, sslctx, _maxclientsperserver, startssl ) -- wrap new server socket if not handler then server:close( ) return nil, err @@ -737,14 +737,14 @@ if not handler then return nil, "no server found on port '" .. tostring( port ) .. "'" end - handler.close( ) + handler:close( ) _server[ port ] = nil return true end closeall = function( ) for _, handler in pairs( _socketlist ) do - handler.close( ) + handler:close( ) _socketlist[ _ ] = nil end _readlistlen = 0 @@ -822,7 +822,7 @@ end for handler, err in pairs( _closelist ) do handler.disconnect( )( handler, err ) - handler.close( true ) -- forced disconnect + handler:close( true ) -- forced disconnect end clean( _closelist ) _currenttime = os_time( ) @@ -880,14 +880,14 @@ if os_difftime( _currenttime - timestamp ) > _sendtimeout then --_writetimes[ handler ] = nil handler.disconnect( )( handler, "send timeout" ) - handler.close( true ) -- forced disconnect + handler:close( true ) -- forced disconnect end end for handler, timestamp in pairs( _readtimes ) do if os_difftime( _currenttime - timestamp ) > _readtimeout then --_readtimes[ handler ] = nil handler.disconnect( )( handler, "read timeout" ) - handler.close( ) -- forced disconnect? + handler:close( ) -- forced disconnect? end end end
--- a/net/xmppclient_listener.lua Sun Nov 22 04:46:48 2009 +0000 +++ b/net/xmppclient_listener.lua Sun Nov 22 04:50:42 2009 +0000 @@ -100,15 +100,15 @@ end end session.send("</stream:stream>"); - session.conn.close(); - xmppclient.disconnect(session.conn, (reason and (reason.text or reason.condition)) or reason or "session closed"); + session.conn:close(); + xmppclient.ondisconnect(session.conn, (reason and (reason.text or reason.condition)) or reason or "session closed"); end end -- End of session methods -- -function xmppclient.listener(conn, data) +function xmppclient.onincoming(conn, data) local session = sessions[conn]; if not session then session = sm_new_session(conn); @@ -117,7 +117,7 @@ session.log("info", "Client connected"); -- Client is using legacy SSL (otherwise mod_tls sets this flag) - if conn.ssl() then + if conn:ssl() then session.secure = true; end @@ -133,7 +133,7 @@ end end -function xmppclient.disconnect(conn, err) +function xmppclient.ondisconnect(conn, err) local session = sessions[conn]; if session then (session.log or log)("info", "Client disconnected: %s", err);
--- a/net/xmppcomponent_listener.lua Sun Nov 22 04:46:48 2009 +0000 +++ b/net/xmppcomponent_listener.lua Sun Nov 22 04:50:42 2009 +0000 @@ -118,12 +118,12 @@ end session.send("</stream:stream>"); session.conn.close(); - component_listener.disconnect(session.conn, "stream error"); + component_listener.ondisconnect(session.conn, "stream error"); end end --- Component connlistener -function component_listener.listener(conn, data) +function component_listener.onincoming(conn, data) local session = sessions[conn]; if not session then local _send = conn.write; @@ -157,7 +157,7 @@ end end -function component_listener.disconnect(conn, err) +function component_listener.ondisconnect(conn, err) local session = sessions[conn]; if session then (session.log or log)("info", "component disconnected: %s (%s)", tostring(session.host), tostring(err));
--- a/net/xmppserver_listener.lua Sun Nov 22 04:46:48 2009 +0000 +++ b/net/xmppserver_listener.lua Sun Nov 22 04:50:42 2009 +0000 @@ -104,14 +104,14 @@ session.conn.close(true); -- Force FIXME: timer? end session.conn.close(); - xmppserver.disconnect(session.conn, "stream error"); + xmppserver.ondisconnect(session.conn, "stream error"); end end -- End of session methods -- -function xmppserver.listener(conn, data) +function xmppserver.onincoming(conn, data) local session = sessions[conn]; if not session then session = s2s_new_incoming(conn); @@ -148,7 +148,7 @@ end end -function xmppserver.disconnect(conn, err) +function xmppserver.ondisconnect(conn, err) local session = sessions[conn]; if session then if err and err ~= "closed" and session.srv_hosts then
--- a/plugins/mod_tls.lua Sun Nov 22 04:46:48 2009 +0000 +++ b/plugins/mod_tls.lua Sun Nov 22 04:50:42 2009 +0000 @@ -20,9 +20,9 @@ session.send(st.stanza("proceed", { xmlns = xmlns_starttls })); session:reset_stream(); if session.host and hosts[session.host].ssl_ctx_in then - session.conn.set_sslctx(hosts[session.host].ssl_ctx_in); + session.conn:set_sslctx(hosts[session.host].ssl_ctx_in); end - session.conn.starttls(); + session.conn:starttls(); session.log("info", "TLS negotiation started..."); session.secure = false; else @@ -37,9 +37,9 @@ session.sends2s(st.stanza("proceed", { xmlns = xmlns_starttls })); session:reset_stream(); if session.to_host and hosts[session.to_host].ssl_ctx_in then - session.conn.set_sslctx(hosts[session.to_host].ssl_ctx_in); + session.conn:set_sslctx(hosts[session.to_host].ssl_ctx_in); end - session.conn.starttls(); + session.conn:starttls(); session.log("info", "TLS negotiation started for incoming s2s..."); session.secure = false; else @@ -91,7 +91,7 @@ module:log("debug", "Proceeding with TLS on s2sout..."); local format, to_host, from_host = string.format, session.to_host, session.from_host; session:reset_stream(); - session.conn.starttls(true); + session.conn:starttls(true); session.secure = false; return true; end);