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