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:
parent
050152eb90
commit
b2f0a37b18
2 changed files with 32 additions and 1 deletions
|
@ -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;
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue