summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJesusaves <cpntb1@ymail.com>2020-12-31 11:30:44 -0300
committerJesusaves <cpntb1@ymail.com>2020-12-31 11:30:44 -0300
commit1ad90327b221063dab82ad0ac1252c0007e921cf (patch)
treef96faac1f286a04080e1502d6cd0e1ec75412751
parentb480856e3a4d4667860fe996b4bd6fbe08d1be02 (diff)
downloadserver-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-xserver.py18
1 files changed, 9 insertions, 9 deletions
diff --git a/server.py b/server.py
index 2428183..2dee2ba 100755
--- a/server.py
+++ b/server.py
@@ -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