Browse code

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

Daniel-Constantin Mierla authored on 12/01/2021 09:05:32
Showing 1 changed files
... ...
@@ -116,18 +116,19 @@ function ksr_route_relay()
116 116
 function ksr_route_reqinit()
117 117
 {
118 118
 	if (!KSR.is_myself_srcip()) {
119
+		var srcip = KSR.kx.get_srcip();
119 120
 		if (KSR.htable.sht_match_name("ipban", "eq", srcip) > 0) {
120 121
 			// ip is already blocked
121 122
 			KSR.dbg("request from blocked IP - " + KSR.kx.get_method()
122 123
 					+ " from " + KSR.kx.get_furi() + " (IP:"
123
-					+ KSR.kx.get_srcip() + ":" + KSR.kx.get_srcport() + ")\n");
124
+					+ srcip + ":" + KSR.kx.get_srcport() + ")\n");
124 125
 			KSR.x.exit();
125 126
 		}
126 127
 		if (KSR.pike.pike_check_req()<0) {
127 128
 			KSR.err("ALERT: pike blocking " + KSR.kx.get_method()
128 129
 					+ " from " + KSR.kx.get_furi() + " (IP:"
129
-					+ KSR.kx.get_srcip() + ":" + KSR.kx.get_srcport() + ")\n");
130
-			KSR.htable.sht_seti("ipban", KSR.kx.get_srcip(), 1);
130
+					+ srcip + ":" + KSR.kx.get_srcport() + ")\n");
131
+			KSR.htable.sht_seti("ipban", srcip, 1);
131 132
 			KSR.x.exit();
132 133
 		}
133 134
 	}