[asterisk-commits] sip to pjsip: Write local net, contact acl, contact deny, an... (asterisk[master])

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


Joshua Colp has submitted this change and it was merged.

Change subject: sip_to_pjsip: Write local_net, contact_acl, contact_deny, and contact_permit.
......................................................................


sip_to_pjsip: Write local_net, contact_acl, contact_deny, and contact_permit.

When using the migration script sip_to_pjsip.py, those keys got missing. These
keys might appear several times and the function "merge_value" tried to collect
those. However, because these keys have different names in sip.conf and
pjsip.conf, "merge_value" was not able to find the new key name in sip.conf.
This change lets "merge_value" search with the old key name in sip.conf and
write with the new key name in pjsip.conf.

ASTERISK-22374

Change-Id: Ie53c5278ae6f1cb8fa7e96c5289877d46981d9d2
---
M contrib/scripts/sip_to_pjsip/sip_to_pjsip.py
1 file changed, 10 insertions(+), 23 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..22c749e 100755
--- a/contrib/scripts/sip_to_pjsip/sip_to_pjsip.py
+++ b/contrib/scripts/sip_to_pjsip/sip_to_pjsip.py
@@ -54,10 +54,11 @@
 
 
 def merge_value(key=None, val=None, section=None, pjsip=None,
-                nmapped=None, type='endpoint', section_to=None):
+                nmapped=None, type='endpoint', section_to=None,
+                key_to=None):
     """Merge values from the given section with those from the default."""
     def _merge_value(k, v, s, r, n):
-        merge_value(key if key else k, v, s, r, n, type, section_to)
+        merge_value(key if key else k, v, s, r, n, type, section_to, key_to)
 
     # if no value or section return the merge_value
     # function with the enclosed key and type
@@ -71,7 +72,8 @@
         sect = sip.default(section)[0]
     # for each merged value add it to pjsip.conf
     for i in sect.get_merged(key):
-        set_value(key, i, section_to if section_to else section,
+        set_value(key_to if key_to else key, i,
+                  section_to if section_to else section,
                   pjsip, nmapped, type)
 
 
@@ -454,9 +456,9 @@
     ['permit',             merge_value(type='acl', section_to='acl')],
     ['deny',               merge_value(type='acl', section_to='acl')],
     ['acl',                merge_value(type='acl', section_to='acl')],
-    ['contactpermit',      merge_value('contact_permit', type='acl', section_to='acl')],
-    ['contactdeny',        merge_value('contact_deny', type='acl', section_to='acl')],
-    ['contactacl',         merge_value('contact_acl', type='acl', section_to='acl')],
+    ['contactpermit',      merge_value(type='acl', section_to='acl', key_to='contact_permit')],
+    ['contactdeny',        merge_value(type='acl', section_to='acl', key_to='contact_deny')],
+    ['contactacl',         merge_value(type='acl', section_to='acl', key_to='contact_acl')],
 
 ########################### maps to transport #################################
 #        type = transport
@@ -499,21 +501,6 @@
 ]
 
 
-def add_localnet(section, pjsip, nmapped):
-    """
-    Adds localnet values from sip.conf's general section to a transport in
-    pjsip.conf. Ideally, we would have just created a template with the
-    localnet sections, but because this is a script, it's not hard to add
-    the same thing on to every transport.
-    """
-    try:
-        merge_value('local_net', sip.get('general', 'localnet')[0], 'general',
-                    pjsip, nmapped, 'transport', section)
-    except LookupError:
-        # No localnet options configured. No biggie!
-        pass
-
-
 def set_transport_common(section, pjsip, nmapped):
     """
     sip.conf has several global settings that in pjsip.conf apply to individual
@@ -527,8 +514,8 @@
     """
 
     try:
-        merge_value('local_net', sip.get('general', 'localnet')[0], 'general',
-                    pjsip, nmapped, 'transport', section)
+        merge_value('localnet', sip.get('general', 'localnet')[0], 'general',
+                    pjsip, nmapped, 'transport', section, "local_net")
     except LookupError:
         # No localnet options configured. Move on.
         pass

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ie53c5278ae6f1cb8fa7e96c5289877d46981d9d2
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: master
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