# HG changeset patch # User Matthew Wild # Date 1219766220 -3600 # Node ID 6885fd2cf51f279dd47a554e2b9de750cf94ff08 # Parent 65622bf34afc9dc6dab2c6d211ae0f72572e10e3 Remove some debugging messages Connection now closed on error Removed version='1.0' to keep it working with non-SASL diff -r 65622bf34afc -r 6885fd2cf51f core/xmlhandlers.lua --- a/core/xmlhandlers.lua Tue Aug 26 13:15:06 2008 +0100 +++ b/core/xmlhandlers.lua Tue Aug 26 16:57:00 2008 +0100 @@ -42,7 +42,7 @@ session.streamid = m_random(1000000, 99999999); print(session, session.host, "Client opened stream"); send(""); - send(format("", session.streamid, session.host)); + send(format("", session.streamid, session.host)); --send(""); --send("PLAIN"); --send [[ ]] diff -r 65622bf34afc -r 6885fd2cf51f main.lua --- a/main.lua Tue Aug 26 13:15:06 2008 +0100 +++ b/main.lua Tue Aug 26 16:57:00 2008 +0100 @@ -10,7 +10,7 @@ end require "core.stanza_dispatch" -local init_xmlhandlers = require "core.xmlhandlers" +require "core.xmlhandlers" require "core.rostermanager" require "core.offlinemessage" require "core.usermanager" @@ -24,6 +24,7 @@ local m_random = math.random; local format = string.format; local st = stanza; +local init_xmlhandlers = xmlhandlers.init_xmlhandlers; ------------------------------ sessions = {}; @@ -165,15 +166,13 @@ sessions[conn].disconnect(err); end -print("ssl_ctx:", type(ssl_ctx)); - setmetatable(_G, { __index = function (t, k) print("WARNING: ATTEMPT TO READ A NIL GLOBAL!!!", k); error("Attempt to read a non-existent global. Naughty boy.", 2); end, __newindex = function (t, k, v) print("ATTEMPT TO SET A GLOBAL!!!!", tostring(k).." = "..tostring(v)); error("Attempt to set a global. Naughty boy.", 2); end }) --]][][[]][]; -local protected_handler = function (...) local success, ret = pcall(handler, ...); if not success then print("ERROR on "..tostring((select(1, ...)))..": "..ret); end end; -local protected_disconnect = function (...) local success, ret = pcall(disconnect, ...); if not success then print("ERROR on "..tostring((select(1, ...))).." disconnect: "..ret); end end; +local protected_handler = function (conn, data, err) local success, ret = pcall(handler, conn, data, err); if not success then print("ERROR on "..tostring(conn)..": "..ret); conn:close(); end end; +local protected_disconnect = function (conn, err) local success, ret = pcall(disconnect, conn, err); if not success then print("ERROR on "..tostring(conn).." disconnect: "..ret); conn:close(); end end; -print( server.add( { listener = protected_handler, disconnect = protected_disconnect }, 5222, "*", 1, nil ) ) -- server.add will send a status message -print( server.add( { listener = protected_handler, disconnect = protected_disconnect }, 5223, "*", 1, ssl_ctx ) ) -- server.add will send a status message +server.add( { listener = protected_handler, disconnect = protected_disconnect }, 5222, "*", 1, nil ) -- server.add will send a status message +server.add( { listener = protected_handler, disconnect = protected_disconnect }, 5223, "*", 1, ssl_ctx ) -- server.add will send a status message server.loop();