Skip to content

Commit d135781

Browse files
committed
Ignore flooding concerns in the minute after server start
1 parent fcdbd8a commit d135781

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

pawn/Entities/Players/PlayerEvents.pwn

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ class PlayerEvents <playerId (MAX_PLAYERS)> {
5858
// between both connections. When the two IPs connect in rapid order, temporary block the IP.
5959
// This will result in closed connections for ingame players using the same IP address.
6060
if (!strcmp(ipAddress, m_lastConnectionAddress, true)
61-
&& (Time->currentHighResolutionTime() - m_lastConnectionTimestamp) < DefaultDelayConnection) {
61+
&& (Time->currentHighResolutionTime() - m_lastConnectionTimestamp) < DefaultDelayConnection
62+
&& GetServerUptimeMs() > 60 * 1000 /* Ignore the first minute after start **/ ) {
6263
printf("Blocking [%s] for 30 minutes due to flooding.", ipAddress);
6364
BlockIpAddress(ipAddress, BlockageDuration); // block the IP address
6465
}

pawn/Resources/Callbacks/Others/OnGameModeInit.pwn

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@
1414
// Keep track of whether the main() method has finished executing.
1515
new bool: g_mainFinishedExecuting = false;
1616

17+
// Time (in milliseconds) at which the server started.
18+
new g_serverStartTime;
19+
20+
GetServerUptimeMs() { return GetTickCount() - g_serverStartTime; }
21+
1722
public OnGameModeInit() {
1823
// Block until the main() method has finished executing completely. Race conditions can occur in
1924
// which certain information or classes are not yet initialized when we don't do this. Pawn
@@ -23,6 +28,8 @@ public OnGameModeInit() {
2328
return 1;
2429
}
2530

31+
g_serverStartTime = GetTickCount();
32+
2633
// Part of Driver.
2734
SetTimer("UpdateVehicleTrailerStatus", 1000, 1);
2835
InitializeDriftTextDraws();

0 commit comments

Comments
 (0)