From a8febf49e714ac29d1cbdca5a3cc5f77a6ef37df Mon Sep 17 00:00:00 2001 From: TJ Porter <taylerporter@gmail.com> Date: Wed, 14 Feb 2024 09:37:43 -0600 Subject: [PATCH] Fixed SIPStatus to be ResponseCode Removed previous elifs catching a 407 response. --- pyVoIP/SIP/client.py | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/pyVoIP/SIP/client.py b/pyVoIP/SIP/client.py index 1d92f90..0490ae8 100644 --- a/pyVoIP/SIP/client.py +++ b/pyVoIP/SIP/client.py @@ -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 @@ -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. @@ -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( @@ -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 @@ -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. @@ -1406,11 +1401,6 @@ 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.") @@ -1418,7 +1408,7 @@ def __register(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