From d290384c788971155a40e47c3a035dbbbb2cafea Mon Sep 17 00:00:00 2001 From: Tayler Porter Date: Fri, 3 Dec 2021 13:28:29 -0600 Subject: [PATCH] pyVoIP 1.5.1 Fixed issue #2 pointed out by rushant001. --- NOTES | 3 +++ docs/VoIP.rst | 4 ++-- pyVoIP/SIP.py | 8 ++++---- pyVoIP/__init__.py | 5 +++-- setup.py | 2 +- 5 files changed, 13 insertions(+), 9 deletions(-) diff --git a/NOTES b/NOTES index cf2fc5b..1210823 100644 --- a/NOTES +++ b/NOTES @@ -1,3 +1,6 @@ +Fixes in v1.5.1: +Fixed issue #2 pointed out by rushant001. + New in v1.5.0: Fixed bug where pyVoIP would accept all codecs proposed by the server even if not compatible. Will now only accept PCMU, PCMA, and telephone-event. Added handling of Native Bridging tested with Asterisk 16 SIP re-invite (External RTP bridge), this seems to still have issues with Asterisk 18, but unsure if it's my hardphone. diff --git a/docs/VoIP.rst b/docs/VoIP.rst index eed09c6..c841246 100644 --- a/docs/VoIP.rst +++ b/docs/VoIP.rst @@ -135,5 +135,5 @@ The VoIPPhone class is used to manage the :ref:`SIPClient` class and create :ref This method ends all currently ongoing calls, then stops the :ref:`SIPClient` class **call**\ (number) - Originates a call using PCMU and telephone-event. The *number* argument must be a string, and it returns a :ref:`VoIPCall` class in CallState.DIALING. You should use a while loop to wait until the CallState is ANSWRED. **NOTE:** In testing with Asterisk 13, calls made this way could not hangup. This issue may exist on other PBXs as well. - \ No newline at end of file + Originates a call using PCMU and telephone-event. The *number* argument must be a string, and it returns a :ref:`VoIPCall` class in CallState.DIALING. You should use a while loop to wait until the CallState is ANSWRED. + diff --git a/pyVoIP/SIP.py b/pyVoIP/SIP.py index b734d01..382563d 100644 --- a/pyVoIP/SIP.py +++ b/pyVoIP/SIP.py @@ -626,7 +626,7 @@ def genRegister(self, request): regRequest += self.username+"@"+self.myIP+":"+str(self.myPort) regRequest += ";transport=UDP>\r\nTo: \r\nFrom: ;tag="+self.genTag() regRequest += "\r\nCall-ID: "+request.headers['Call-ID'] regRequest += "\r\nCSeq: "+str(self.registerCounter.next())+" REGISTER" regRequest +="\r\nExpires: 300\r\nAllow: "+(", ".join(pyVoIP.SIPCompatibleMethods))+"\r\nUser-Agent: pyVoIP """+pyVoIP.__version__+"\r\n" @@ -841,7 +841,7 @@ def bye(self, request): def deregister(self): self.recvLock.acquire() - fake = SIPMessage(b'SIP/2.0 401 Unauthorized\r\nVia: SIP/2.0/UDP 192.168.0.64:5060;received=192.168.0.64\r\nFrom: ;tag=b4dbea69\r\nTo: ;tag=as6845844a\r\nCall-ID: '+self.genCallID().encode('utf8')+b'\r\nCSeq: 25273 REGISTER\r\nServer: Asterisk PBX 16.2.1~dfsg-1+deb10u1\r\nAllow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE\r\nSupported: replaces, timer\r\nWWW-Authenticate: Digest algorithm=MD5, realm="asterisk", nonce="7140386d"\r\nContent-Length: 0\r\n\r\n') + fake = SIPMessage(b'SIP/2.0 401 Unauthorized\r\nVia: SIP/2.0/UDP 192.168.0.64:5060;received=192.168.0.64\r\nFrom: ;tag=b4dbea69\r\nTo: ;tag=as6845844a\r\nCall-ID: '+self.genCallID().encode('utf8')+b'\r\nCSeq: 25273 REGISTER\r\nServer: Asterisk PBX 16.2.1~dfsg-1+deb10u1\r\nAllow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE\r\nSupported: replaces, timer\r\nWWW-Authenticate: Digest algorithm=MD5, realm="asterisk", nonce="7140386d"\r\nContent-Length: 0\r\n\r\n') regRequest = self.genRegister(fake).replace('Expires: 300', 'Expires: 0') @@ -870,7 +870,7 @@ def deregister(self): def register(self): self.recvLock.acquire() - fake = SIPMessage(b'SIP/2.0 401 Unauthorized\r\nVia: SIP/2.0/UDP 192.168.0.64:5060;received=192.168.0.64\r\nFrom: ;tag=b4dbea69\r\nTo: ;tag=as6845844a\r\nCall-ID: '+self.genCallID().encode('utf8')+b'\r\nCSeq: 25273 REGISTER\r\nServer: Asterisk PBX 16.2.1~dfsg-1+deb10u1\r\nAllow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE\r\nSupported: replaces, timer\r\nWWW-Authenticate: Digest algorithm=MD5, realm="asterisk", nonce="7140386d"\r\nContent-Length: 0\r\n\r\n') + fake = SIPMessage(b'SIP/2.0 401 Unauthorized\r\nVia: SIP/2.0/UDP 192.168.0.64:5060;received=192.168.0.64\r\nFrom: ;tag=b4dbea69\r\nTo: ;tag=as6845844a\r\nCall-ID: '+self.genCallID().encode('utf8')+b'\r\nCSeq: 25273 REGISTER\r\nServer: Asterisk PBX 16.2.1~dfsg-1+deb10u1\r\nAllow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE\r\nSupported: replaces, timer\r\nWWW-Authenticate: Digest algorithm=MD5, realm="asterisk", nonce="7140386d"\r\nContent-Length: 0\r\n\r\n') regRequest = self.genRegister(fake) @@ -906,4 +906,4 @@ def register(self): raise InvalidAccountInfoError("Invalid Username or Password for SIP server "+self.server+':'+str(self.myPort)) - \ No newline at end of file + diff --git a/pyVoIP/__init__.py b/pyVoIP/__init__.py index 636f9bd..b2ff701 100644 --- a/pyVoIP/__init__.py +++ b/pyVoIP/__init__.py @@ -1,7 +1,7 @@ __all__ = ['SIP', 'RTP', 'VoIP'] -version_info = (1, 5, 0) +version_info = (1, 5, 1) __version__ = ".".join([str(x) for x in version_info]) @@ -19,4 +19,5 @@ def debug(s, e=None): SIPCompatibleVersions = ['SIP/2.0'] RTPCompatibleVersions = [2] -RTPCompatibleCodecs = [PayloadType.PCMU, PayloadType.PCMA, PayloadType.EVENT] \ No newline at end of file +RTPCompatibleCodecs = [PayloadType.PCMU, PayloadType.PCMA, PayloadType.EVENT] + diff --git a/setup.py b/setup.py index 2839d70..c61c3a7 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ setup( name = 'pyVoIP', - version = '1.5.0', + version = '1.5.1', description = 'PyVoIP is a pure python VoIP/SIP/RTP library.', author = 'Tayler Porter', author_email = 'taylerporter@gmail.com',