# HG changeset patch # User Matthew Wild # Date 1228506556 0 # Node ID 3a49d85cafbcb510c86ffdafcef44e65739a44d0 # Parent 099d8a102deb96e57be78a563836ad90d9536f56 Backed out changeset 099d8a102deb (committed too much) diff -r 099d8a102deb -r 3a49d85cafbc core/presencemanager.lua --- a/core/presencemanager.lua Fri Dec 05 19:24:01 2008 +0000 +++ b/core/presencemanager.lua Fri Dec 05 19:49:16 2008 +0000 @@ -21,7 +21,6 @@ local log = require "util.logger".init("presencemanager") -local tostring = tostring; local require = require; local pairs, ipairs = pairs, ipairs; local t_concat = table.concat; @@ -122,14 +121,6 @@ else log("error", "presence recieved from client with no roster"); end - - if origin.conntimetotal then - local session = origin; - origin.log("BLAH", "***********\n\n\n\n\n\n****************"); - origin.send(st.stanza("message", { from = session.host, to=session.full_jid, type = "normal" }):body("Your login took "..tostring(session.conntimetotal).." seconds")); - origin.conntimetotal = nil; - end - end function send_presence_of_available_resources(user, host, jid, recipient_session, core_route_stanza) diff -r 099d8a102deb -r 3a49d85cafbc core/sessionmanager.lua --- a/core/sessionmanager.lua Fri Dec 05 19:24:01 2008 +0000 +++ b/core/sessionmanager.lua Fri Dec 05 19:49:16 2008 +0000 @@ -35,8 +35,6 @@ local rm_load_roster = require "core.rostermanager".load_roster; local config_get = require "core.configmanager".get; -local gettime = require "socket".gettime; - local st = require "util.stanza"; local newproxy = newproxy; @@ -47,7 +45,7 @@ local open_sessions = 0; function new_session(conn) - local session = { conn = conn, priority = 0, type = "c2s_unauthed", conntime = gettime() }; + local session = { conn = conn, priority = 0, type = "c2s_unauthed" }; if true then session.trace = newproxy(true); getmetatable(session.trace).__gc = function () open_sessions = open_sessions - 1; print("Session got collected, now "..open_sessions.." sessions are allocated") end; @@ -111,8 +109,6 @@ if session.resource then return nil, "cancel", "already-bound", "Cannot bind multiple resources on a single connection"; end -- We don't support binding multiple resources - session.conntimetotal = gettime()-session.conntime; - resource = resource or uuid_generate(); --FIXME: Randomly-generated resources must be unique per-user, and never conflict with existing diff -r 099d8a102deb -r 3a49d85cafbc net/server.lua --- a/net/server.lua Fri Dec 05 19:24:01 2008 +0000 +++ b/net/server.lua Fri Dec 05 19:49:16 2008 +0000 @@ -504,24 +504,13 @@ handler.starttls = function (now) if not now then out_put("server.lua: we need to do tls, but delaying until later"); handler.need_tls = true; return; end out_put( "server.lua: attempting to start tls on "..tostring(socket) ) - local oldsocket = socket; socket, err = ssl_wrap( socket, sslctx ) -- wrap socket out_put("sslwrapped socket is "..tostring(socket)); if err then out_put( "server.lua: ssl error: ", err ) return nil, nil, err -- fatal error end - socket:settimeout(0); - - -- Add the new socket to our system - socketlist[ socket ] = handler - readlen = readlen + 1 - readlist[ readlen ] = socket - - -- Remove traces of the old socket - readlen = removesocket( readlist, oldsocket, readlen ) - socketlist [ oldsocket ] = nil; - + socket:settimeout( 1 ) send = socket.send receive = socket.receive close = socket.close @@ -547,6 +536,9 @@ handler.receivedata = handler._receivedata -- when handshake is done, replace the handshake function with regular functions handler.dispatchdata = handler._dispatchdata handler.need_tls = nil + socketlist[ client ] = handler + readlen = readlen + 1 + readlist[ readlen ] = client return true; else out_put( "server.lua: error during ssl handshake: ", err ) diff -r 099d8a102deb -r 3a49d85cafbc net/xmppclient_listener.lua --- a/net/xmppclient_listener.lua Fri Dec 05 19:24:01 2008 +0000 +++ b/net/xmppclient_listener.lua Fri Dec 05 19:49:16 2008 +0000 @@ -113,7 +113,7 @@ if not session then session = sm_new_session(conn); sessions[conn] = session; - + -- Logging functions -- local mainlog, log = log; diff -r 099d8a102deb -r 3a49d85cafbc plugins/mod_console.lua --- a/plugins/mod_console.lua Fri Dec 05 19:24:01 2008 +0000 +++ b/plugins/mod_console.lua Fri Dec 05 19:49:16 2008 +0000 @@ -33,7 +33,7 @@ local w = conn.write; local session = { conn = conn; send = function (t) w(tostring(t)); end; - print = function (t) w("| "..tostring(t).."\r\n"); end; + print = function (t) w("| "..tostring(t).."\n"); end; disconnect = function () conn.close(); end; }; session.env = setmetatable({}, default_env_mt); diff -r 099d8a102deb -r 3a49d85cafbc plugins/mod_saslauth.lua --- a/plugins/mod_saslauth.lua Fri Dec 05 19:24:01 2008 +0000 +++ b/plugins/mod_saslauth.lua Fri Dec 05 19:49:16 2008 +0000 @@ -24,8 +24,6 @@ local jid local base64 = require "util.encodings".base64; -local gettime = require "socket".gettime; - local usermanager_validate_credentials = require "core.usermanager".validate_credentials; local t_concat, t_insert = table.concat, table.insert; local tostring = tostring; @@ -66,14 +64,14 @@ end end -local function password_callback(node, host, mechanism) +local function password_callback(node, host, mechanism, raw_host) local password = (datamanager.load(node, host, "accounts") or {}).password; -- FIXME handle hashed passwords local func = function(x) return x; end; if password then if mechanism == "PLAIN" then return func, password; elseif mechanism == "DIGEST-MD5" then - return func, md5(node..":"..host..":"..password); + return func, md5(node..":"..raw_host..":"..password); end end return func, nil; @@ -144,8 +142,6 @@ :tag("bind", { xmlns = xmlns_bind}) :tag("jid"):text(session.full_jid)); end - - session.log("******", "Connection took "..tostring(session.conntimetotal).." seconds"); end); module:add_iq_handler("c2s", "urn:ietf:params:xml:ns:xmpp-session",