summaryrefslogtreecommitdiff
path: root/utils.py
diff options
context:
space:
mode:
authorJesusaves <cpntb1@ymail.com>2020-12-17 15:17:31 -0300
committerJesusaves <cpntb1@ymail.com>2020-12-17 15:17:31 -0300
commitae57d4024596e3e26381b14bd556574c9a69ce1e (patch)
tree41ba04a9e28605e81b91a4c493d246fff4576e91 /utils.py
parent0f001ee4db66e8154c0405eb2cf4434803fbde1c (diff)
downloadserver-ae57d4024596e3e26381b14bd556574c9a69ce1e.tar.gz
server-ae57d4024596e3e26381b14bd556574c9a69ce1e.tar.bz2
server-ae57d4024596e3e26381b14bd556574c9a69ce1e.tar.xz
server-ae57d4024596e3e26381b14bd556574c9a69ce1e.zip
New function: security.score()
Whenever a bad packet is received or something, it adds a "score" to the conn. If it exceeds a certain threshold (5 for unauthed, 30 for authed users), the connection is killed and IP is blacklisted for BAN_TIME (default: 3 mins)
Diffstat (limited to 'utils.py')
-rw-r--r--utils.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/utils.py b/utils.py
index b6b60f4..9625e1f 100644
--- a/utils.py
+++ b/utils.py
@@ -30,6 +30,12 @@ for l in s:
salt=l
s.close()
+def ifte(ifs, then, elses):
+ if (ifs):
+ return then
+ else:
+ return elses
+
def md5(string):
return hashlib.md5(string.encode()).hexdigest()