Skip to content

Commit

Permalink
pyVoIP 1.5.1
Browse files Browse the repository at this point in the history
Fixed issue tayler6000#2 pointed out by rushant001.
  • Loading branch information
tayler6000 committed Dec 3, 2021
1 parent 86500f0 commit d290384
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 9 deletions.
3 changes: 3 additions & 0 deletions NOTES
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
4 changes: 2 additions & 2 deletions docs/VoIP.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.

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.

8 changes: 4 additions & 4 deletions pyVoIP/SIP.py
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,7 @@ def genRegister(self, request):
regRequest += self.username+"@"+self.myIP+":"+str(self.myPort)
regRequest += ";transport=UDP>\r\nTo: <sip:"""+self.username+"@"
regRequest += self.server+";transport=UDP>\r\nFrom: <sip:"+self.username
regRequest += "@192.168.0.102;transport=UDP>;tag="+self.genTag()
regRequest += "@"+self.server+";transport=UDP>;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"
Expand Down Expand Up @@ -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: <sip:5555555@192.168.0.102;transport=UDP>;tag=b4dbea69\r\nTo: <sip:5555555@192.168.0.102;transport=UDP>;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: <sip:5555555@127.0.0.1;transport=UDP>;tag=b4dbea69\r\nTo: <sip:5555555@127.0.0.1;transport=UDP>;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')

Expand Down Expand Up @@ -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: <sip:5555555@192.168.0.102;transport=UDP>;tag=b4dbea69\r\nTo: <sip:5555555@192.168.0.102;transport=UDP>;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: <sip:5555555@127.0.0.1;transport=UDP>;tag=b4dbea69\r\nTo: <sip:5555555@127.0.0.1;transport=UDP>;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)

Expand Down Expand Up @@ -906,4 +906,4 @@ def register(self):
raise InvalidAccountInfoError("Invalid Username or Password for SIP server "+self.server+':'+str(self.myPort))



5 changes: 3 additions & 2 deletions pyVoIP/__init__.py
Original file line number Diff line number Diff line change
@@ -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])

Expand All @@ -19,4 +19,5 @@ def debug(s, e=None):
SIPCompatibleVersions = ['SIP/2.0']

RTPCompatibleVersions = [2]
RTPCompatibleCodecs = [PayloadType.PCMU, PayloadType.PCMA, PayloadType.EVENT]
RTPCompatibleCodecs = [PayloadType.PCMU, PayloadType.PCMA, PayloadType.EVENT]

2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '[email protected]',
Expand Down

0 comments on commit d290384

Please sign in to comment.