diff options
author | Jesusaves <cpntb1@ymail.com> | 2020-12-17 14:15:22 -0300 |
---|---|---|
committer | Jesusaves <cpntb1@ymail.com> | 2020-12-17 14:15:22 -0300 |
commit | b8d39a45db5793faa33ac940e70c04a8170a8adf (patch) | |
tree | 746a0dc3b4568613ed13e562c0a2f3aaf3b55bda /server.py | |
parent | 9afc1920fd5234bb8a19a67494dd2316585e021b (diff) | |
download | server-b8d39a45db5793faa33ac940e70c04a8170a8adf.tar.gz server-b8d39a45db5793faa33ac940e70c04a8170a8adf.tar.bz2 server-b8d39a45db5793faa33ac940e70c04a8170a8adf.tar.xz server-b8d39a45db5793faa33ac940e70c04a8170a8adf.zip |
Add support for three blacklist files
But technicially, Z-Line and G-Line should be processed before
Diffstat (limited to 'server.py')
-rwxr-xr-x | server.py | 41 |
1 files changed, 37 insertions, 4 deletions
@@ -22,6 +22,36 @@ 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, 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, 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, INT_MAX]) + f.close() +except: + stdout("No K-Line.txt config file found") + pass ############################################################### # Main Class @@ -43,9 +73,9 @@ class WebSocketConn(WebSocket): if r[0] is not True: stdout("%s - %s" % (self.address[0], r[1])) syslog.syslog(LOG_AUTH, "%s - %s" % (self.address[0], r[1])) - self.send_message("NACK") + self.send_message("NACK\n") else: - self.send_message(r[1]) + self.send_message(r[1]+"\n") print("Message sent") #stdout(self.address[0] + u' - %s' % (self.data)) @@ -56,14 +86,17 @@ class WebSocketConn(WebSocket): """ Called when a websocket client connects to the server. """ - print(self.address, 'connected') + #print(self.address, 'connected') #for client in clients: # print(repr(client)) # client.send_message(self.address[0] + u' - connected') stdout(self.address[0] + u' - connected') - # TODO: Drop OLD connections when same ID tries to connect + # Blacklisted + if (self.address[0] in blacklist): + self.close(self, status=1011, reason="Server error: K-Lined") + # TODO: Drop OLD connections when same ID tries to connect if (False): self.close(self, status=1000, reason='Unrecognized') else: |