Fixed server kicking clients who request auth after validation

This commit is contained in:
juanjp600
2016-08-31 21:11:27 -03:00
parent 3d1cb65330
commit db0d4b1cd6
@@ -35,22 +35,23 @@ namespace Barotrauma.Networking
private void ClientAuthRequest(NetConnection conn) private void ClientAuthRequest(NetConnection conn)
{ {
//client wants to know if server requires password //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) if (ConnectedClients.Find(c => c.Connection == conn) != null)
{ {
//this client has already been authenticated //this client has already been authenticated
return; return;
} }
UnauthenticatedClient unauthClient = unauthenticatedClients.Find(uc => uc.Connection == conn); UnauthenticatedClient unauthClient = unauthenticatedClients.Find(uc => uc.Connection == conn);
if (unauthClient == null) if (unauthClient == null)
{ {
//new client, generate nonce and add to unauth queue //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(); int nonce = CryptoRandom.Instance.Next();
unauthClient = new UnauthenticatedClient(conn, nonce); unauthClient = new UnauthenticatedClient(conn, nonce);
unauthenticatedClients.Add(unauthClient); unauthenticatedClients.Add(unauthClient);