[sr-dev] git:master:6e541feb: misc/examples/kemi: use kx functions instead of pv

Daniel-Constantin Mierla miconda at gmail.com
Tue Jan 12 10:00:42 CET 2021


Module: kamailio
Branch: master
Commit: 6e541feb9184e193f9c486c8f97d73360c69250d
URL: https://github.com/kamailio/kamailio/commit/6e541feb9184e193f9c486c8f97d73360c69250d

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2021-01-12T09:52:31+01:00

misc/examples/kemi: use kx functions instead of pv

---

Modified: misc/examples/kemi/kamailio-basic-kemi-jsdt.js

---

Diff:  https://github.com/kamailio/kamailio/commit/6e541feb9184e193f9c486c8f97d73360c69250d.diff
Patch: https://github.com/kamailio/kamailio/commit/6e541feb9184e193f9c486c8f97d73360c69250d.patch

---

diff --git a/misc/examples/kemi/kamailio-basic-kemi-jsdt.js b/misc/examples/kemi/kamailio-basic-kemi-jsdt.js
index ab3799fdc9..cedbf098b0 100644
--- a/misc/examples/kemi/kamailio-basic-kemi-jsdt.js
+++ b/misc/examples/kemi/kamailio-basic-kemi-jsdt.js
@@ -116,23 +116,23 @@ function ksr_route_relay()
 function ksr_route_reqinit()
 {
 	if (!KSR.is_myself_srcip()) {
-		if (!KSR.pv.is_null("$sht(ipban=>$si)")) {
+		if (KSR.htable.sht_match_name("ipban", "eq", srcip) > 0) {
 			// ip is already blocked
-			KSR.dbg("request from blocked IP - " + KSR.pv.get("$rm")
-					+ " from " + KSR.pv.get("$fu") + " (IP:"
-					+ KSR.pv.get("$si") + ":" + KSR.pv.get("$sp") + ")\n");
+			KSR.dbg("request from blocked IP - " + KSR.kx.get_method()
+					+ " from " + KSR.kx.get_furi() + " (IP:"
+					+ KSR.kx.get_srcip() + ":" + KSR.kx.get_srcport() + ")\n");
 			KSR.x.exit();
 		}
 		if (KSR.pike.pike_check_req()<0) {
-			KSR.err("ALERT: pike blocking " + KSR.pv.get("$rm")
-					+ " from " + KSR.pv.get("$fu") + " (IP:"
-					+ KSR.pv.get("$si") + ":" + KSR.pv.get("$sp") + ")\n");
-			KSR.pv.seti("$sht(ipban=>$si)", 1);
+			KSR.err("ALERT: pike blocking " + KSR.kx.get_method()
+					+ " 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);
 			KSR.x.exit();
 		}
 	}
 	if (KSR.corex.has_user_agent()>0) {
-		var UA = KSR.pv.gete("$ua");
+		var UA = KSR.kx.gete_ua();
 		if (UA.indexOf("friendly")>=0 || UA.indexOf("scanner")>=0
 				|| UA.indexOf("sipcli")>=0 || UA.indexOf("sipvicious")>=0) {
 			KSR.sl.sl_send_reply(200, "OK");
@@ -154,7 +154,7 @@ function ksr_route_reqinit()
 
 	if (KSR.sanity.sanity_check(1511, 7)<0) {
 		KSR.err("Malformed SIP message from "
-				+ KSR.pv.get("$si") + ":" + KSR.pv.get("$sp") + "\n");
+				+ KSR.kx.get_srcip() + ":" + KSR.kx.get_srcport() + "\n");
 		KSR.x.exit();
 	}
 }
@@ -238,7 +238,7 @@ function ksr_route_location()
 }
 
 
-// IP authorization and user uthentication
+// IP authorization and user authentication
 function ksr_route_auth()
 {
 	if (!KSR.is_REGISTER()) {
@@ -250,8 +250,8 @@ function ksr_route_auth()
 
 	if (KSR.is_REGISTER() || KSR.is_myself_furi()) {
 		// authenticate requests
-		if (KSR.auth_db.auth_check(KSR.pv.get("$fd"), "subscriber", 1)<0) {
-			KSR.auth.auth_challenge(KSR.pv.get("$fd"), 0);
+		if (KSR.auth_db.auth_check(KSR.kx.gete_fhost(), "subscriber", 1)<0) {
+			KSR.auth.auth_challenge(KSR.kx.gete_fhost(), 0);
 			KSR.x.exit();
 		}
 		// user authenticated - remove auth header
@@ -340,8 +340,8 @@ function ksr_route_sipout()
 // equivalent of branch_route[...]{}
 function ksr_branch_manage()
 {
-	KSR.dbg("new branch [" + KSR.pv.get("$T_branch_idx")
-				+ "] to " + KSR.pv.get("$ru") + "\n");
+	KSR.dbg("new branch [" + KSR.tm.t_get_branch_index()
+				+ "] to " + KSR.kx.get_ruri() + "\n");
 	ksr_route_natmanage();
 	return;
 }
@@ -351,7 +351,7 @@ function ksr_branch_manage()
 function ksr_onreply_manage()
 {
 	KSR.dbg("incoming reply\n");
-	var scode = KSR.pv.get("$rs");
+	var scode = KSR.kx.gets_status();
 	if (scode>100 && scode<=299) {
 		ksr_route_natmanage();
 	}




More information about the sr-dev mailing list