# HG changeset patch # User Kim Alvefur # Date 1720370425 -7200 # Node ID aefbc76ac8d2192829db28059c1bcafe308f6c01 # Parent 3e6d5738ea09bcdf436fd854fd262280fd9dfc76# Parent da9be0ad4bbc136ce59be0fa243c04175b5251f5 Merge 0.12->trunk diff -r 3e6d5738ea09 -r aefbc76ac8d2 net/server_event.lua --- a/net/server_event.lua Tue Jun 18 15:08:30 2024 +0100 +++ b/net/server_event.lua Sun Jul 07 18:40:25 2024 +0200 @@ -735,7 +735,10 @@ 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 @@ 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 @@ listen = listen, addclient = addclient, wrapclient = wrapclient, + wrapserver = wrapserver, setquitting = setquitting, closeall = closeallservers, get_backend = get_backend,