669 if interface._connections >= cfg.MAX_CONNECTIONS then |
669 if interface._connections >= cfg.MAX_CONNECTIONS then |
670 client:close( ) -- refuse connection |
670 client:close( ) -- refuse connection |
671 debug( "maximal connections reached, refuse client connection; accept delay:", delay ) |
671 debug( "maximal connections reached, refuse client connection; accept delay:", delay ) |
672 return EV_TIMEOUT, delay -- delay for next accept attemp |
672 return EV_TIMEOUT, delay -- delay for next accept attemp |
673 end |
673 end |
674 local ip, port = client:getpeername( ) |
674 local client_ip, client_port = client:getpeername( ) |
675 interface._connections = interface._connections + 1 -- increase connection count |
675 interface._connections = interface._connections + 1 -- increase connection count |
676 local clientinterface = handleclient( client, ip, port, interface, pattern, listener, nil, sslctx ) |
676 local clientinterface = handleclient( client, client_ip, client_port, interface, pattern, listener, nil, sslctx ) |
677 --vdebug( "client id:", clientinterface, "startssl:", startssl ) |
677 --vdebug( "client id:", clientinterface, "startssl:", startssl ) |
678 if ssl and sslctx then |
678 if ssl and sslctx then |
679 clientinterface:starttls(sslctx) |
679 clientinterface:starttls(sslctx) |
680 else |
680 else |
681 clientinterface:_start_session( clientinterface.onconnect ) |
681 clientinterface:_start_session( clientinterface.onconnect ) |
682 end |
682 end |
683 debug( "accepted incoming client connection from:", ip, port ) |
683 debug( "accepted incoming client connection from:", client_ip or "<unknown IP>", client_port or "<unknown port>", "to", port or "<unknown port>"); |
684 |
684 |
685 client, err = server:accept() -- try to accept again |
685 client, err = server:accept() -- try to accept again |
686 end |
686 end |
687 return EV_READ |
687 return EV_READ |
688 end |
688 end |