Skip to content

Commit

Permalink
Fix maxconnectionsperhost
Browse files Browse the repository at this point in the history
It was doing the exact opposite of the intended behavior, allowing an infinite
number of connections from the same host but disallowing any new connection
once N players were connected.

Closes #1754.
  • Loading branch information
lmoureaux authored and jwrober committed Jan 22, 2023
1 parent 2464d66 commit 1d83a2a
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions server/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -468,15 +468,16 @@ void server::accept_connections()
{
// Use TolerantConversion so one connections from the same address on
// IPv4 and IPv6 are rejected as well.
if (socket->peerAddress().isEqual(
if (!socket->peerAddress().isEqual(
pconn->sock->peerAddress(),
QHostAddress::TolerantConversion)) {
continue;
}
if (++count >= game.server.maxconnectionsperhost) {
qDebug("Rejecting new connection from %s: maximum number of "
"connections for this address exceeded (%d).",
qUtf8Printable(remote), game.server.maxconnectionsperhost);
qWarning("Rejecting new connection from %s: maximum number of "
"connections for this address exceeded (%d).",
qUtf8Printable(remote),
game.server.maxconnectionsperhost);

success = false;
socket->deleteLater();
Expand Down

0 comments on commit 1d83a2a

Please sign in to comment.