fix a bit

This commit is contained in:
JJTech0130 2023-09-02 19:20:46 -04:00
parent e72cfbf72c
commit b5e9a1c4db
No known key found for this signature in database
GPG key ID: 23C92EBCCF8F93D6
2 changed files with 9 additions and 4 deletions

View file

@ -281,4 +281,9 @@ if __name__ == "__main__":
parser.add_argument("--gateway", type=str, help="Override the gateway phone number")
args = parser.parse_args()
if not args.pdu.startswith("REG-RESP"):
print("Invalid REG-RESP PDU")
exit(1)
trio.run(main, args)

View file

@ -21,7 +21,7 @@ def register(push_token: bytes, no_parse = False, gateway = GATEWAY) -> tuple[st
if no_parse:
print("Now do the next part and rerun with --pdu")
exit()
parse_pdu(r, req_id)
parse_pdu(r.text, req_id)
# if r.text.split("?")[0] != "REG-RESP":
# raise Exception(f"Failed to register: {r.text}")
@ -37,10 +37,10 @@ def register(push_token: bytes, no_parse = False, gateway = GATEWAY) -> tuple[st
# return resp_params["n"], signature
def parse_pdu(r: str, req_id: int | None = None):
if r.text.split("?")[0] != "REG-RESP":
raise Exception(f"Failed to register: {r.text}")
if r.split("?")[0] != "REG-RESP":
raise Exception(f"Failed to register: {r}")
#assert r.text.split("?")[0] == "REG-RESP"
resp_params = r.text.split("?")[1]
resp_params = r.split("?")[1]
resp_params = resp_params.split(";")
resp_params = {param.split("=")[0]: param.split("=")[1] for param in resp_params}
assert resp_params["v"] == "3"