[asterisk-commits] sip to pjsip: Parse register even with transport. (asterisk[14])

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Aug 18 11:50:21 CDT 2016


Joshua Colp has submitted this change and it was merged.

Change subject: sip_to_pjsip: Parse register even with transport.
......................................................................


sip_to_pjsip: Parse register even with transport.

When using the migration script sip_to_pjsip.py and the register string
started with a transport in sip.conf - like tls://... - register was not parsed
correctly and therefore not migrated correctly to pjsip.conf.

ASTERISK-22374

Change-Id: I44c12104eea2bd8558ada6d25d77edfecd92edd2
---
M contrib/scripts/sip_to_pjsip/sip_to_pjsip.py
1 file changed, 12 insertions(+), 5 deletions(-)

Approvals:
  George Joseph: Looks good to me, but someone else must approve
  Anonymous Coward #1000019: Verified
  Joshua Colp: Looks good to me, approved



diff --git a/contrib/scripts/sip_to_pjsip/sip_to_pjsip.py b/contrib/scripts/sip_to_pjsip/sip_to_pjsip.py
index 8909216..5eb6598 100755
--- a/contrib/scripts/sip_to_pjsip/sip_to_pjsip.py
+++ b/contrib/scripts/sip_to_pjsip/sip_to_pjsip.py
@@ -907,6 +907,17 @@
         the right of the user, then finish by using rpartition calls to remove
         everything to the left of the user.
         """
+        self.peer = ''
+        self.protocol = 'udp'
+        protocols = ['udp', 'tcp', 'tls']
+        for protocol in protocols:
+            position = user_part.find(protocol + '://')
+            if -1 < position:
+                post_transport = user_part[position + 6:]
+                self.peer, sep, self.protocol = user_part[:position + 3].rpartition('?')
+                user_part = post_transport
+                break
+
         colons = user_part.count(':')
         if (colons == 3):
             # :domainport:secret:authuser
@@ -927,11 +938,7 @@
             # Invalid setting
             raise
 
-        pre_domain, sep, self.domain = pre_auth.partition('@')
-        self.peer, sep, post_peer = pre_domain.rpartition('?')
-        transport, sep, self.user = post_peer.rpartition('://')
-
-        self.protocol = transport if transport else 'udp'
+        self.user, sep, self.domain = pre_auth.partition('@')
 
     def write(self, pjsip, nmapped):
         """

-- 
To view, visit https://gerrit.asterisk.org/3626
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I44c12104eea2bd8558ada6d25d77edfecd92edd2
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: 14
Gerrit-Owner: Alexander Traud <pabstraud at compuserve.com>
Gerrit-Reviewer: Anonymous Coward #1000019
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>



More information about the asterisk-commits mailing list