aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2024-07-07 18:40:25 +0200
committerKim Alvefur <zash@zash.se>2024-07-07 18:40:25 +0200
commitb522fd0e05988adcef50c196be786591ac038c30 (patch)
treee17ebf447558f739389eda44944c8b00719f00a9
parent29148cfe9ce0d6b60127ad158381acb90ca9ab53 (diff)
parentca417ab7767b3ba8f62bdbdbd51f306f159375ea (diff)
downloadprosody-b522fd0e05988adcef50c196be786591ac038c30.tar.gz
prosody-b522fd0e05988adcef50c196be786591ac038c30.zip
Merge 0.12->trunk
-rw-r--r--net/server_event.lua17
1 files changed, 16 insertions, 1 deletions
diff --git a/net/server_event.lua b/net/server_event.lua
index 3bad3474..44222aa3 100644
--- a/net/server_event.lua
+++ b/net/server_event.lua
@@ -735,7 +735,10 @@ local function handleserver( server, addr, port, pattern, listener, sslctx, star
debug( "maximal connections reached, refuse client connection; accept delay:", delay )
return EV_TIMEOUT, delay -- delay for next accept attempt
end
- local client_ip, client_port = client:getpeername( )
+ local client_ip, client_port = addr, port;
+ if client.getpeername then -- Only IP sockets have this method, UNIX sockets don't
+ client_ip, client_port = client:getpeername( )
+ end
interface._connections = interface._connections + 1 -- increase connection count
local clientinterface = handleclient( client, client_ip, client_port, interface, pattern, listener, sslctx )
--vdebug( "client id:", clientinterface, "startssl:", startssl )
@@ -758,6 +761,17 @@ local function handleserver( server, addr, port, pattern, listener, sslctx, star
return interface
end
+local function wrapserver(conn, addr, port, listeners, config)
+ config = config or {}
+ if config.sslctx and not has_luasec then
+ debug "fatal error: luasec not found"
+ return nil, "luasec not found"
+ end
+ local interface = handleserver( conn, addr, port, config.read_size, listeners, config.tls_ctx, config.tls_direct) -- new server handler
+ debug( "new server created with id:", tostring(interface))
+ return interface
+end
+
local function listen(addr, port, listener, config)
config = config or {}
if config.sslctx and not has_luasec then
@@ -947,6 +961,7 @@ return {
listen = listen,
addclient = addclient,
wrapclient = wrapclient,
+ wrapserver = wrapserver,
setquitting = setquitting,
closeall = closeallservers,
get_backend = get_backend,