aboutsummaryrefslogtreecommitdiffstats
path: root/net/server.lua
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2008-12-27 21:20:09 +0000
committerMatthew Wild <mwild1@gmail.com>2008-12-27 21:20:09 +0000
commitb97b1db2a0fb9d14bb8a61e72bfddb103e4e53cb (patch)
tree154f9c164833f7dd446a8b6c422485d436d83c98 /net/server.lua
parent89eb3c5d00a0da8a72d303e898ecfd2f63f9eb2b (diff)
downloadprosody-b97b1db2a0fb9d14bb8a61e72bfddb103e4e53cb.tar.gz
prosody-b97b1db2a0fb9d14bb8a61e72bfddb103e4e53cb.zip
Fix specifying ports in config, and SSL support
Diffstat (limited to 'net/server.lua')
-rw-r--r--net/server.lua17
1 files changed, 11 insertions, 6 deletions
diff --git a/net/server.lua b/net/server.lua
index 8ec2bcfd..ff599419 100644
--- a/net/server.lua
+++ b/net/server.lua
@@ -94,14 +94,14 @@ stats = function( )
return receivestat, sendstat
end
-wrapserver = function( listener, socket, ip, serverport, mode, sslctx ) -- this function wraps a server
+wrapserver = function( listener, socket, ip, serverport, mode, sslctx, wrapper_function ) -- this function wraps a server
local dispatch, disconnect = listener.listener, listener.disconnect -- dangerous
local wrapclient, err
out_put("Starting a new server on "..tostring(serverport).." with ssl: "..tostring(sslctx));
-
+ out_put(traceback())
if sslctx then
if not ssl_newcontext then
return nil, "luasec not found"
@@ -116,12 +116,16 @@ wrapserver = function( listener, socket, ip, serverport, mode, sslctx ) -- th
out_error( "server.lua: ", err )
return nil, err
end
+ end
+
+ if wrapper_function then
+ wrapclient = wrapper_function
+ elseif sslctx then
wrapclient = wrapsslclient
- wrapclient = wraptlsclient
else
wrapclient = wraptcpclient
end
-
+
local accept = socket.accept
local close = socket.close
@@ -768,7 +772,7 @@ firetimer = function( listener )
end
end
-addserver = function( listeners, port, addr, mode, sslctx ) -- this function provides a way for other scripts to reg a server
+addserver = function( listeners, port, addr, mode, sslctx, wrapper_function ) -- this function provides a way for other scripts to reg a server
local err
if type( listeners ) ~= "table" then
err = "invalid listener table"
@@ -797,7 +801,7 @@ addserver = function( listeners, port, addr, mode, sslctx ) -- this function
out_error( "server.lua: ", err )
return nil, err
end
- local handler, err = wrapserver( listeners, server, addr, port, mode, sslctx ) -- wrap new server socket
+ local handler, err = wrapserver( listeners, server, addr, port, mode, sslctx, wrapper_function ) -- wrap new server socket
if not handler then
server:close( )
return nil, err
@@ -877,5 +881,6 @@ return {
closeall = closeall,
addtimer = addtimer,
wraptcpclient = wraptcpclient,
+ wrapsslclient = wrapsslclient,
wraptlsclient = wraptlsclient,
}