This commit is contained in:
parent
8737f98d5a
commit
eab9300695
1 changed files with 12 additions and 15 deletions
27
server.py
27
server.py
|
@ -38,29 +38,26 @@ def getident(hostt:str, clientport:int, ssll:bool):
|
||||||
serverport = "6697" if ssll else "6667"
|
serverport = "6697" if ssll else "6667"
|
||||||
try:
|
try:
|
||||||
identsender.sendall(bytes(f"{clientport}, {serverport}\r\n", "UTF-8"))
|
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)
|
print(responsee)
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
return {"success": False, "response": f"Could not send packets to your server: {ex}"}
|
return {"success": False, "response": f"Could not send packets to your server: {ex}"}
|
||||||
if "ERROR : NO-USER" in responsee:
|
if "ERROR:NO-USER" in responsee:
|
||||||
return {"success": False, "response": "No user was found by the server."}
|
return {"success": False, "response": "No user was found by the server."}
|
||||||
elif "ERROR :" in responsee:
|
elif "ERROR:" in responsee:
|
||||||
return {"success": False, "response": "The ident server had an error"}
|
return {"success": False, "response": "The ident server had an error"}
|
||||||
elif responsee == "":
|
elif responsee == "":
|
||||||
return {"success": False, "response": "The connection was closed."}
|
return {"success": False, "response": "The connection was closed."}
|
||||||
else:
|
else:
|
||||||
for i, v in enumerate(responsee.split(" ")):
|
print(responsee.split(",")[0])
|
||||||
print(v)
|
print(responsee.split(",")[1].split(":")[0])
|
||||||
if i == 0 and v[:-1] != str({clientport}):
|
|
||||||
return {"success": False, "response": "The ident server sent an invalid client port."}
|
if responsee.split(",")[0] != str({clientport}):
|
||||||
elif i == 1 and v != serverport:
|
return {"success": False, "response": "The ident server sent an invalid client port."}
|
||||||
return {"success": False, "response": "The ident server doesn't know what the server port is."}
|
elif responsee.split(",")[1].split(":")[0] != serverport:
|
||||||
elif i == 2 and v != ":":
|
return {"success": False, "response": "The ident server doesn't know what the server port is."}
|
||||||
return {"success": False, "response": "The ident server sent an invalid response."}
|
else:
|
||||||
elif i == 4 and v != ":":
|
return {"success": True, "response": responsee.split(",")[1].split(":")[3]}
|
||||||
return {"success": False, "response": "The ident server sent an invalid response."}
|
|
||||||
elif i == 5:
|
|
||||||
return {"success": True, "response": v}
|
|
||||||
return {"success": False, "response": "Unknown error."}
|
return {"success": False, "response": "Unknown error."}
|
||||||
except:
|
except:
|
||||||
print(traceback.format_exc())
|
print(traceback.format_exc())
|
||||||
|
|
Loading…
Add table
Reference in a new issue