parent
e2366da77e
commit
c2b1aa3a5f
1 changed files with 10 additions and 16 deletions
26
server.py
26
server.py
|
@ -241,24 +241,10 @@ def session(connection, client, ip, isssl=False):
|
||||||
pendingCommands = "" # list of commands that were executed before verification
|
pendingCommands = "" # list of commands that were executed before verification
|
||||||
unfinished = False
|
unfinished = False
|
||||||
textt = ""
|
textt = ""
|
||||||
nonlocal last_ping
|
|
||||||
nonlocal ping_pending
|
|
||||||
last_ping = time.time()
|
last_ping = time.time()
|
||||||
ping_pending = False
|
ping_pending = False
|
||||||
pendingSend = "" # Text that should be sent to the client
|
pendingSend = "" # Text that should be sent to the client
|
||||||
IRCv3Features = [] # List of Acknowledged IRCv3 features.
|
IRCv3Features = [] # List of Acknowledged IRCv3 features.
|
||||||
def ping(): # Ping
|
|
||||||
if pending != "*":
|
|
||||||
if (time.time() - last_ping) > 30 and not ping_pending:
|
|
||||||
print(f"Sending ping msg to {pending}")
|
|
||||||
ping_pending = True
|
|
||||||
time.sleep(0.5)
|
|
||||||
connection.sendall(bytes(f"PING {server}\r\n","UTF-8"))
|
|
||||||
elif ping_pending and (time.time() - last_ping) > ping_timeout:
|
|
||||||
cause = f"Ping timeout: {ping_timeout} seconds"
|
|
||||||
print(f"{pending} timed out.")
|
|
||||||
return True
|
|
||||||
return False
|
|
||||||
def tags(): # Get IRCv3 tags
|
def tags(): # Get IRCv3 tags
|
||||||
tags = ""
|
tags = ""
|
||||||
if "server-time" in IRCv3Features:
|
if "server-time" in IRCv3Features:
|
||||||
|
@ -324,8 +310,16 @@ def session(connection, client, ip, isssl=False):
|
||||||
print("Received data: {}".format(data))
|
print("Received data: {}".format(data))
|
||||||
try:
|
try:
|
||||||
textt += data.decode()
|
textt += data.decode()
|
||||||
if ping():
|
if pending != "*":
|
||||||
break
|
if (time.time() - last_ping) > 30 and not ping_pending:
|
||||||
|
print(f"Sending ping msg to {pending}")
|
||||||
|
ping_pending = True
|
||||||
|
time.sleep(0.5)
|
||||||
|
connection.sendall(bytes(f"PING {server}\r\n","UTF-8"))
|
||||||
|
elif ping_pending and (time.time() - last_ping) > ping_timeout:
|
||||||
|
cause = f"Ping timeout: {ping_timeout} seconds"
|
||||||
|
print(f"{pending} timed out.")
|
||||||
|
break
|
||||||
if textt[-1] == "\n":
|
if textt[-1] == "\n":
|
||||||
for text in textt.replace("\r", "").split("\n"):
|
for text in textt.replace("\r", "").split("\n"):
|
||||||
for i in socketListeners:
|
for i in socketListeners:
|
||||||
|
|
Loading…
Add table
Reference in a new issue