Skip to content

Commit

Permalink
Merge pull request #213 from key2peace/development
Browse files Browse the repository at this point in the history
Fixes #170
Fixes #69 
Fixes #183
  • Loading branch information
tayler6000 authored Feb 14, 2024
2 parents 48d846a + a8febf4 commit 8438d15
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions pyVoIP/SIP/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1237,7 +1237,9 @@ def bye(self, request: SIPMessage) -> None:
),
)
response = SIPMessage.from_bytes(conn.recv(8192))
if response.status == ResponseCode(401):
if response.status == ResponseCode(401) or response.status == ResponseCode(
407
):
# Requires password
auth = self.gen_authorization(response)
message = message.replace(
Expand Down Expand Up @@ -1283,7 +1285,9 @@ def __deregister(self) -> bool:
first_response = response
conn.close() # Regardless of the response, the dialog is over

if response.status == ResponseCode(401):
if response.status == ResponseCode(401) or response.status == ResponseCode(
407
):
# Unauthorized, likely due to being password protected.
password_request = self.gen_register(response, deregister=True)
conn = self.send(password_request)
Expand All @@ -1297,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 @@ -1311,7 +1310,9 @@ def __deregister(self) -> bool:
elif response.status == ResponseCode.OK:
return True

elif response.status == ResponseCode(401):
elif response.status == ResponseCode(401) or response.status == ResponseCode(
407
):
# At this point, it's reasonable to assume that
# this is caused by invalid credentials.
debug("=" * 50)
Expand Down Expand Up @@ -1384,7 +1385,9 @@ def __register(self) -> bool:
first_response = response
conn.close() # Regardless of the response, the dialog is over

if response.status == ResponseCode(401):
if response.status == ResponseCode(401) or response.status == ResponseCode(
407
):
# Unauthorized, likely due to being password protected.
password_request = self.gen_register(response)
conn = self.send(password_request)
Expand All @@ -1398,19 +1401,16 @@ 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 == ResponseCode(401):
elif response.status == ResponseCode(401) or response.status == ResponseCode(
407
):
# At this point, it's reasonable to assume that
# this is caused by invalid credentials.
debug("=" * 50)
Expand Down

0 comments on commit 8438d15

Please sign in to comment.