diff --git a/demo.py b/demo.py index 074c4ae..dc10f1d 100644 --- a/demo.py +++ b/demo.py @@ -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) \ No newline at end of file diff --git a/sms_registration.py b/sms_registration.py index fb771b9..c11f7c9 100644 --- a/sms_registration.py +++ b/sms_registration.py @@ -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"