1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-08-01 17:38:41 +00:00

Rate-limit client connection attempts

This commit is contained in:
sfan5 2024-01-05 15:12:20 +01:00
parent 050152eb90
commit b2f0a37b18
2 changed files with 32 additions and 1 deletions

View file

@ -162,8 +162,25 @@ private:
bool reliable);
};
struct RateLimitHelper {
u64 time = 0;
int counter = 0;
bool logged = false;
void tick() {
u64 now = porting::getTimeS();
if (time != now) {
time = now;
counter = 0;
logged = false;
}
}
};
static const PacketTypeHandler packetTypeRouter[PACKET_TYPE_MAX];
Connection *m_connection = nullptr;
RateLimitHelper m_new_peer_ratelimit;
};
}