Update server.py
All checks were successful
/ check (push) Successful in 16s

This commit is contained in:
Nova Cat 2025-01-25 22:44:24 -08:00
parent 8737f98d5a
commit eab9300695

View file

@ -38,7 +38,7 @@ def getident(hostt:str, clientport:int, ssll:bool):
serverport = "6697" if ssll else "6667"
try:
identsender.sendall(bytes(f"{clientport}, {serverport}\r\n", "UTF-8"))
responsee = identsender.recv(2048).decode()
responsee = identsender.recv(2048).decode().replace(" ", "").replace("\r", "").replace("\n", "")
print(responsee)
except Exception as ex:
return {"success": False, "response": f"Could not send packets to your server: {ex}"}
@ -49,18 +49,15 @@ def getident(hostt:str, clientport:int, ssll:bool):
elif responsee == "":
return {"success": False, "response": "The connection was closed."}
else:
for i, v in enumerate(responsee.split(" ")):
print(v)
if i == 0 and v[:-1] != str({clientport}):
print(responsee.split(",")[0])
print(responsee.split(",")[1].split(":")[0])
if responsee.split(",")[0] != str({clientport}):
return {"success": False, "response": "The ident server sent an invalid client port."}
elif i == 1 and v != serverport:
elif responsee.split(",")[1].split(":")[0] != serverport:
return {"success": False, "response": "The ident server doesn't know what the server port is."}
elif i == 2 and v != ":":
return {"success": False, "response": "The ident server sent an invalid response."}
elif i == 4 and v != ":":
return {"success": False, "response": "The ident server sent an invalid response."}
elif i == 5:
return {"success": True, "response": v}
else:
return {"success": True, "response": responsee.split(",")[1].split(":")[3]}
return {"success": False, "response": "Unknown error."}
except:
print(traceback.format_exc())