diff options
author | Jesusaves <cpntb1@ymail.com> | 2020-12-17 14:56:21 -0300 |
---|---|---|
committer | Jesusaves <cpntb1@ymail.com> | 2020-12-17 14:56:21 -0300 |
commit | 0f001ee4db66e8154c0405eb2cf4434803fbde1c (patch) | |
tree | f9bf72f51505b6ecf81e391ec4c6dd0566441fa5 /server.py | |
parent | 4da1730136fdca575bf403e5f54736853325c3d2 (diff) | |
download | server-0f001ee4db66e8154c0405eb2cf4434803fbde1c.tar.gz server-0f001ee4db66e8154c0405eb2cf4434803fbde1c.tar.bz2 server-0f001ee4db66e8154c0405eb2cf4434803fbde1c.tar.xz server-0f001ee4db66e8154c0405eb2cf4434803fbde1c.zip |
Move blacklist functions to security.py
Diffstat (limited to 'server.py')
-rwxr-xr-x | server.py | 44 |
1 files changed, 3 insertions, 41 deletions
@@ -10,9 +10,8 @@ from websock import WebSocketServer, WebSocket ## Local Modules from utils import stdout as stdout from utils import now as now -from utils import dl_search as dl_search from consts import * -import sql, protocol +import sql, protocol, security ############################################################### # Configuration @@ -23,39 +22,6 @@ f.close() PORT=p["PORT"] SECURE=p["SSL"] clients = [] -blacklist = [] - -############################################################### -# Import K-Line, G-Line and Z-Line -try: - f=open("Z-Line.txt", "r") - for ip in f: - blacklist.append([ip.replace("\n", ""), INT_MAX]) - f.close() -except: - stdout("No Z-Line.txt config file found") - pass - -try: - f=open("G-Line.txt", "r") - for ip in f: - blacklist.append([ip.replace("\n", ""), INT_MAX]) - f.close() -except: - stdout("No G-Line.txt config file found") - pass - -try: - f=open("K-Line.txt", "r") - for ip in f: - blacklist.append([ip.replace("\n", ""), INT_MAX]) - f.close() -except: - stdout("No K-Line.txt config file found") - pass - -# Inform what is current blacklist -stdout("Blacklist configuration:\n%s\n\n" % str(blacklist)) ############################################################### # Main Class @@ -96,14 +62,10 @@ class WebSocketConn(WebSocket): # client.send_message(self.address[0] + u' - connected') stdout(self.address[0] + u' - connected') - print("Searching on blacklist") - bl=dl_search(blacklist, 0, self.address[0]) - print("Look finished") - print("Result: %s" % str(bl)) # Blacklisted - if (bl != "ERROR"): + if (security.is_banned(self.address[0])): stdout("Found in K-Line, connection was dropped.") - self.close(self, status=1000, reason="Server error: K-Lined") + self.close(self, status=1000, reason="K-Lined") # TODO: Drop OLD connections when same ID tries to connect if (False): |