Skip to content

Commit 6caacee

Browse files
committed
fix: don't allow connection on dead socket
1 parent 4b3825f commit 6caacee

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

GhostServer/networkmanager.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,10 @@ bool NetworkManager::ShouldBlockConnection(const sf::IpAddress& ip)
279279
return true;
280280
}
281281

282+
if (ip == sf::IpAddress::None) {
283+
return true;
284+
}
285+
282286
if (this->bannedIps.find(ip) != this->bannedIps.end()) {
283287
return true;
284288
}
@@ -298,18 +302,18 @@ void NetworkManager::CheckConnection()
298302
client.IP = client.tcpSocket->getRemoteAddress();
299303

300304
if (this->ShouldBlockConnection(client.IP)) {
301-
GHOST_LOG("Refused connection from " + client.IP.toString() + " - banned or IP already connected");
305+
GHOST_LOG("Refused connection from " + client.IP.toString() + " - blocked");
302306
return;
303307
}
304308

305-
sf::Packet connection_packet;
306309
sf::SocketSelector conn_selector;
307310
conn_selector.add(*client.tcpSocket);
308311
if (!conn_selector.wait(sf::milliseconds(CONNECT_TIMEOUT))) {
309312
GHOST_LOG("Connection timeout from " + client.IP.toString());
310313
return;
311314
}
312-
315+
316+
sf::Packet connection_packet;
313317
client.tcpSocket->receive(connection_packet);
314318

315319
HEADER header;

0 commit comments

Comments
 (0)