Browse Source

misc: examples kemi, don't fail if optional modules are not loaded

kamailio-basic-kemi.cfg has some define instructions that can be
removed ( WITH_MYSQL, WITH_AUTH, ...)

So lets make sure that modules are there in the lua script before
using the defined routes.
Victor Seva 5 years ago
parent
commit
661fc0193d
1 changed files with 13 additions and 1 deletions
  1. 13 1
      misc/examples/kemi/kamailio-basic-kemi-lua.lua

+ 13 - 1
misc/examples/kemi/kamailio-basic-kemi-lua.lua

@@ -240,8 +240,11 @@ end
 
 -- IP authorization and user uthentication
 function ksr_route_auth()
+	if not KSR.auth then
+		return 1;
+	end
 
-	if not KSR.is_REGISTER() then
+	if KSR.permissions and not KSR.is_REGISTER() then
 		if KSR.permissions.allow_source_address(1)>0 then
 			-- source IP allowed
 			return 1;
@@ -273,6 +276,9 @@ end
 
 -- Caller NAT detection
 function ksr_route_natdetect()
+	if not KSR.nathelper then
+		return 1;
+	end
 	KSR.force_rport();
 	if KSR.nathelper.nat_uac_test(19)>0 then
 		if KSR.is_REGISTER() then
@@ -287,6 +293,9 @@ end
 
 -- RTPProxy control
 function ksr_route_natmanage()
+	if not KSR.rtpproxy then
+		return 1;
+	end
 	if KSR.siputils.is_request()>0 then
 		if KSR.siputils.has_totag()>0 then
 			if KSR.rr.check_route_param("nat=yes")>0 then
@@ -317,6 +326,9 @@ end
 
 -- URI update for dialog requests
 function ksr_route_dlguri()
+	if not KSR.nathelper then
+		return 1;
+	end
 	if not KSR.isdsturiset() then
 		KSR.nathelper.handle_ruri_alias();
 	end