aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
Diffstat (limited to 'net')
-rw-r--r--net/httpserver.lua9
-rw-r--r--net/server.lua10
-rw-r--r--net/xmppclient_listener.lua8
-rw-r--r--net/xmppserver_listener.lua7
4 files changed, 13 insertions, 21 deletions
diff --git a/net/httpserver.lua b/net/httpserver.lua
index 57c8eede..56dfe04e 100644
--- a/net/httpserver.lua
+++ b/net/httpserver.lua
@@ -61,7 +61,7 @@ local function send_response(request, response)
end
else
-- Response we have is just a string (the body)
- log("debug", "Sending response to %s: %s", request.id or "<none>", response or "<none>");
+ log("debug", "Sending 200 response to %s", request.id or "<none>");
resp = { "HTTP/1.0 200 OK\r\n" };
t_insert(resp, "Connection: close\r\n");
@@ -89,9 +89,6 @@ local function call_callback(request, err)
end
callback = (request.server and request.server.handlers[base]) or default_handler;
- if callback == default_handler then
- log("debug", "Default callback for this request (base: "..tostring(base)..")")
- end
end
if callback then
if err then
@@ -251,6 +248,10 @@ function new(params)
end
end
+function set_default_handler(handler)
+ default_handler = handler;
+end
+
function new_from_config(ports, default_base, handle_request)
for _, options in ipairs(ports) do
local port, base, ssl, interface = 5280, default_base, false, nil;
diff --git a/net/server.lua b/net/server.lua
index 12b0aa90..65567d15 100644
--- a/net/server.lua
+++ b/net/server.lua
@@ -246,7 +246,7 @@ wrapserver = function( listeners, socket, ip, serverport, pattern, sslctx, maxco
_socketlist[ socket ] = nil
handler = nil
socket = nil
- mem_free( )
+ --mem_free( )
out_put "server.lua: closed server handler and removed sockets from list"
end
handler.ip = function( )
@@ -373,7 +373,7 @@ wrapconnection = function( server, listeners, socket, ip, serverport, clientport
handler = nil
end
socket = nil
- mem_free( )
+ --mem_free( )
if server then
server.remove( )
end
@@ -565,7 +565,7 @@ wrapconnection = function( server, listeners, socket, ip, serverport, clientport
socket, err = ssl_wrap( socket, sslctx ) -- wrap socket
if err then
out_put( "server.lua: ssl error: ", tostring(err) )
- mem_free( )
+ --mem_free( )
return nil, nil, err -- fatal error
end
socket:settimeout( 0 )
@@ -670,7 +670,7 @@ closesocket = function( socket )
_readlistlen = removesocket( _readlist, socket, _readlistlen )
_socketlist[ socket ] = nil
socket:close( )
- mem_free( )
+ --mem_free( )
end
----------------------------------// PUBLIC //--
@@ -739,7 +739,7 @@ closeall = function( )
_sendlist = { }
_timerlist = { }
_socketlist = { }
- mem_free( )
+ --mem_free( )
end
getsettings = function( )
diff --git a/net/xmppclient_listener.lua b/net/xmppclient_listener.lua
index ce7788c7..6cea43f2 100644
--- a/net/xmppclient_listener.lua
+++ b/net/xmppclient_listener.lua
@@ -61,6 +61,7 @@ local function session_reset_stream(session)
function session.data(conn, data)
local ok, err = parser:parse(data);
if ok then return; end
+ log("debug", "Received invalid XML (%s) %d bytes: %s", tostring(err), #data, data:sub(1, 300):gsub("[\r\n]+", " "));
session:close("xml-not-well-formed");
end
@@ -100,7 +101,7 @@ local function session_close(session, reason)
end
session.send("</stream:stream>");
session.conn.close();
- xmppclient.disconnect(session.conn, (reason and reason.condition) or reason or "session closed");
+ xmppclient.disconnect(session.conn, (reason and (reason.text or reason.condition)) or reason or "session closed");
end
end
@@ -113,11 +114,6 @@ function xmppclient.listener(conn, data)
session = sm_new_session(conn);
sessions[conn] = session;
- -- Logging functions --
-
- local conn_name = "c2s"..tostring(conn):match("[a-f0-9]+$");
- session.log = logger.init(conn_name);
-
session.log("info", "Client connected");
-- Client is using legacy SSL (otherwise mod_tls sets this flag)
diff --git a/net/xmppserver_listener.lua b/net/xmppserver_listener.lua
index 81d26526..6a196446 100644
--- a/net/xmppserver_listener.lua
+++ b/net/xmppserver_listener.lua
@@ -61,6 +61,7 @@ local function session_reset_stream(session)
function session.data(conn, data)
local ok, err = parser:parse(data);
if ok then return; end
+ log("debug", "Received invalid XML (%s) %d bytes: %s", tostring(err), #data, data:sub(1, 300):gsub("[\r\n]+", " "));
session:close("xml-not-well-formed");
end
@@ -113,12 +114,6 @@ function xmppserver.listener(conn, data)
session = s2s_new_incoming(conn);
sessions[conn] = session;
- -- Logging functions --
-
-
- local conn_name = "s2sin"..tostring(conn):match("[a-f0-9]+$");
- session.log = logger.init(conn_name);
-
session.log("info", "Incoming s2s connection");
session.reset_stream = session_reset_stream;