浏览代码

misc/examples/kemi: use local variable instead of many function calls for js

Daniel-Constantin Mierla 4 年之前
父节点
当前提交
b4f439301c
共有 1 个文件被更改,包括 4 次插入3 次删除
  1. 4 3
      misc/examples/kemi/kamailio-basic-kemi-jsdt.js

+ 4 - 3
misc/examples/kemi/kamailio-basic-kemi-jsdt.js

@@ -116,18 +116,19 @@ function ksr_route_relay()
 function ksr_route_reqinit()
 function ksr_route_reqinit()
 {
 {
 	if (!KSR.is_myself_srcip()) {
 	if (!KSR.is_myself_srcip()) {
+		var srcip = KSR.kx.get_srcip();
 		if (KSR.htable.sht_match_name("ipban", "eq", srcip) > 0) {
 		if (KSR.htable.sht_match_name("ipban", "eq", srcip) > 0) {
 			// ip is already blocked
 			// ip is already blocked
 			KSR.dbg("request from blocked IP - " + KSR.kx.get_method()
 			KSR.dbg("request from blocked IP - " + KSR.kx.get_method()
 					+ " from " + KSR.kx.get_furi() + " (IP:"
 					+ " from " + KSR.kx.get_furi() + " (IP:"
-					+ KSR.kx.get_srcip() + ":" + KSR.kx.get_srcport() + ")\n");
+					+ srcip + ":" + KSR.kx.get_srcport() + ")\n");
 			KSR.x.exit();
 			KSR.x.exit();
 		}
 		}
 		if (KSR.pike.pike_check_req()<0) {
 		if (KSR.pike.pike_check_req()<0) {
 			KSR.err("ALERT: pike blocking " + KSR.kx.get_method()
 			KSR.err("ALERT: pike blocking " + KSR.kx.get_method()
 					+ " from " + KSR.kx.get_furi() + " (IP:"
 					+ " from " + KSR.kx.get_furi() + " (IP:"
-					+ KSR.kx.get_srcip() + ":" + KSR.kx.get_srcport() + ")\n");
-			KSR.htable.sht_seti("ipban", KSR.kx.get_srcip(), 1);
+					+ srcip + ":" + KSR.kx.get_srcport() + ")\n");
+			KSR.htable.sht_seti("ipban", srcip, 1);
 			KSR.x.exit();
 			KSR.x.exit();
 		}
 		}
 	}
 	}