From a706cdb228cecab8cb19707b13edb06f4d387a89 Mon Sep 17 00:00:00 2001 From: Robinson Date: Tue, 12 Dec 2023 13:24:33 +0100 Subject: [PATCH] If we have "max connections" specified, then obey the limit --- src/dorkbox/network/handshake/ServerHandshake.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dorkbox/network/handshake/ServerHandshake.kt b/src/dorkbox/network/handshake/ServerHandshake.kt index 79d74d29..9ee5c9a4 100644 --- a/src/dorkbox/network/handshake/ServerHandshake.kt +++ b/src/dorkbox/network/handshake/ServerHandshake.kt @@ -199,7 +199,7 @@ internal class ServerHandshake( // VALIDATE:: we are now connected to the client and are going to create a new connection. val currentCountForIp = connectionsPerIpCounts.get(clientAddress) - if (currentCountForIp >= config.maxConnectionsPerIpAddress) { + if (config.maxConnectionsPerIpAddress in 1..currentCountForIp) { // decrement it now, since we aren't going to permit this connection (take the extra decrement hit on failure, instead of always) connectionsPerIpCounts.decrement(clientAddress, currentCountForIp)