Skip to content

Commit

Permalink
Fixed SIPStatus to be ResponseCode
Browse files Browse the repository at this point in the history
Removed previous elifs catching a 407 response.
  • Loading branch information
tayler6000 authored Feb 14, 2024
1 parent 3d65ba1 commit a8febf4
Showing 1 changed file with 5 additions and 15 deletions.
20 changes: 5 additions & 15 deletions pyVoIP/SIP/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1237,7 +1237,7 @@ def bye(self, request: SIPMessage) -> None:
),
)
response = SIPMessage.from_bytes(conn.recv(8192))
if response.status == SIPStatus(401) or response.status == SIPStatus(
if response.status == ResponseCode(401) or response.status == ResponseCode(
407
):
# Requires password
Expand Down Expand Up @@ -1285,7 +1285,7 @@ def __deregister(self) -> bool:
first_response = response
conn.close() # Regardless of the response, the dialog is over

if response.status == SIPStatus(401) or response.status == SIPStatus(
if response.status == ResponseCode(401) or response.status == ResponseCode(
407
):
# Unauthorized, likely due to being password protected.
Expand All @@ -1301,11 +1301,6 @@ def __deregister(self) -> bool:
# with new urn:uuid or reply with expire 0
self._handle_bad_request()

elif response.status == ResponseCode(407):
# Proxy Authentication Required
# TODO: implement
debug("Proxy auth required")

elif response.status == ResponseCode(500):
# We raise so the calling function can sleep and try again
raise RetryRequiredError(
Expand All @@ -1315,7 +1310,7 @@ def __deregister(self) -> bool:
elif response.status == ResponseCode.OK:
return True

elif response.status == SIPStatus(401) or response.status == SIPStatus(
elif response.status == ResponseCode(401) or response.status == ResponseCode(
407
):
# At this point, it's reasonable to assume that
Expand Down Expand Up @@ -1390,7 +1385,7 @@ def __register(self) -> bool:
first_response = response
conn.close() # Regardless of the response, the dialog is over

if response.status == SIPStatus(401) or response.status == SIPStatus(
if response.status == ResponseCode(401) or response.status == ResponseCode(
407
):
# Unauthorized, likely due to being password protected.
Expand All @@ -1406,19 +1401,14 @@ def __register(self) -> bool:
# with new urn:uuid or reply with expire 0
self._handle_bad_request()

elif response.status == ResponseCode(407):
# Proxy Authentication Required
# TODO: implement
debug("Proxy auth required")

elif response.status == ResponseCode(500):
# We raise so the calling function can sleep and try again
raise RetryRequiredError("Received a 500 error when registering.")

elif response.status == ResponseCode.OK:
return True

elif response.status == SIPStatus(401) or response.status == SIPStatus(
elif response.status == ResponseCode(401) or response.status == ResponseCode(
407
):
# At this point, it's reasonable to assume that
Expand Down

0 comments on commit a8febf4

Please sign in to comment.