diff --git a/fstream-server.py b/fstream-server.py index 60c7e0d..62f300d 100644 --- a/fstream-server.py +++ b/fstream-server.py @@ -88,8 +88,8 @@ class outThread(threading.Thread): if str(self.threadId) in connections: try: connections[str(self.threadId)][0].close() - except: - print("warning, closing connection failed") + except Exception as e: + print("Warning, closing connection failed: " +str(e)) del connections[str(self.threadId)] def getConnection(self): @@ -116,6 +116,7 @@ class outThread(threading.Thread): self.closeThread() except: self.closeThread() + print("Thread closed - Exception:") raise class inThread(threading.Thread): @@ -154,6 +155,7 @@ class inThread(threading.Thread): data = self.getConnection()[0].recv(1000) if data == b"": self.closeThread() + print("Thread closed - Client disconnected.") return data = data.decode("utf-8") while data[-1] == " ": data = data[:-1] @@ -170,6 +172,7 @@ class inThread(threading.Thread): with fileLock: if not os.path.isfile(userPath): self.closeThread() + print("Thread closed - Invalid user given: " +user) return config = configparser.ConfigParser() @@ -178,6 +181,7 @@ class inThread(threading.Thread): if cmd == "watch": if cmd in config and "pass" in config[cmd] and config[cmd]["pass"] != "" and config[cmd]["pass"] != password: self.closeThread() + print("Thread closed - Invalid password given for user: " +user) return with threadsLock: @@ -191,6 +195,7 @@ class inThread(threading.Thread): if cmd == "broadcast": if cmd in config and "pass" in config[cmd] and config[cmd]["pass"] != "" and config[cmd]["pass"] != password: self.closeThread() + print("Thread closed - Invalid password given for user: " +user) return with threadsLock: @@ -209,6 +214,7 @@ class inThread(threading.Thread): data = self.getConnection()[0].recv(bufferSize) if data == b"": self.closeThread() + print("Thread closed - Client disconnected.") return with threadsLock: @@ -220,6 +226,7 @@ class inThread(threading.Thread): thread.ignore = True thread.queue.put((thread.closeThread,[],{})) thread.closeConnection() + print("Thread closed - Too much accumulated data.") else: thread.queue.put(data) @@ -240,6 +247,7 @@ class inThread(threading.Thread): self.closeThread() return except: + print("Thread closed - Exception:") self.closeThread() raise @@ -311,6 +319,7 @@ def main(): ipClientCount += 1 if clientCount + 1 > maxClients or ipClientCount + 1 > maxClientsPerIP: + print("Connection closed - same IP connected too many times.") connection.close() continue