diff options
author | Jesusaves <cpntb1@ymail.com> | 2020-12-31 11:30:44 -0300 |
---|---|---|
committer | Jesusaves <cpntb1@ymail.com> | 2020-12-31 11:30:44 -0300 |
commit | 1ad90327b221063dab82ad0ac1252c0007e921cf (patch) | |
tree | f96faac1f286a04080e1502d6cd0e1ec75412751 | |
parent | b480856e3a4d4667860fe996b4bd6fbe08d1be02 (diff) | |
download | server-1ad90327b221063dab82ad0ac1252c0007e921cf.tar.gz server-1ad90327b221063dab82ad0ac1252c0007e921cf.tar.bz2 server-1ad90327b221063dab82ad0ac1252c0007e921cf.tar.xz server-1ad90327b221063dab82ad0ac1252c0007e921cf.zip |
In case of a successful DDoS, prevent wasting resources evaluating blacklist
and other stuff as the server is full. This is done this way, not to save
the game server from the DDoS, but to save the remainder of the VM.
-rwxr-xr-x | server.py | 18 |
1 files changed, 9 insertions, 9 deletions
@@ -82,6 +82,15 @@ class WebSocketConn(WebSocket): # client.send_message(self.address[0] + u' - connected') stdout(self.address[0] + u' - connected') + # Keep only a "sane" amount of clients connected to the server. + # This program must not, under any circumstances, interfer + # on the operation of Moubootaur Legends, which has total priority + # over the VM resources + if (len(clients) > MAX_CLIENTS): + self.close(self, status=1000, reason='Server is full') + else: + clients.append(self) + # Blacklisted if (security.is_banned(self.address[0])): stdout("Found in K-Line, connection was dropped.") @@ -92,15 +101,6 @@ class WebSocketConn(WebSocket): # TODO: Either auto-ban or limit to <= 3 connections from same IP at once # TODO: Also, inheir the previous connection MS score and MS Auth - # By last, keep a "sane" amount of clients connected - # This program must not, under any circumstances, interfer - # on the operation of Moubootaur Legends, which has total priority - # over the VM resources - if (len(clients) > MAX_CLIENTS): - self.close(self, status=1000, reason='Server is full') - else: - clients.append(self) - # Extend self class self.MS_score = 0 self.MS_auth = False |