From db0d4b1cd6e7efdc47899a8ac2f30da0e14f549f Mon Sep 17 00:00:00 2001 From: juanjp600 Date: Wed, 31 Aug 2016 21:11:27 -0300 Subject: [PATCH] Fixed server kicking clients who request auth after validation --- Subsurface/Source/Networking/GameServerLogin.cs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/Subsurface/Source/Networking/GameServerLogin.cs b/Subsurface/Source/Networking/GameServerLogin.cs index 277944267..411b763fb 100644 --- a/Subsurface/Source/Networking/GameServerLogin.cs +++ b/Subsurface/Source/Networking/GameServerLogin.cs @@ -35,22 +35,23 @@ namespace Barotrauma.Networking private void ClientAuthRequest(NetConnection conn) { //client wants to know if server requires password - - if (ConnectedClients.Count >= MaxPlayers) - { - //server is full, can't allow new connection - conn.Disconnect("Server full"); - } - if (ConnectedClients.Find(c => c.Connection == conn) != null) { //this client has already been authenticated return; } + UnauthenticatedClient unauthClient = unauthenticatedClients.Find(uc => uc.Connection == conn); if (unauthClient == null) { //new client, generate nonce and add to unauth queue + if (ConnectedClients.Count >= MaxPlayers) + { + //server is full, can't allow new connection + conn.Disconnect("Server full"); + return; + } + int nonce = CryptoRandom.Instance.Next(); unauthClient = new UnauthenticatedClient(conn, nonce); unauthenticatedClients.Add(unauthClient);