## Description
Hello all, I'm migrating my Kamailio logics from legacy .cfg file to KEMI
script.
I began with Python but switched then to Lua, but there are some subclass /
functions described in KEMI documentation that seem not to be present in Lua
KSR object.
In this case, I am having trouble with the subclass "kx" described
[here](https://kamailio.org/docs/tutorials/devel/kamailio-kemi-framework/modules/#ksrkxget_srcip)
which is used in the default Lua script example
[here](https://github.com/kamailio/kamailio/blob/ca49dc0344f2ca4eae1999f6b46e0ab8c30bd1a3/misc/examples/kemi/kamailio-basic-kemi-lua.lua)
The error in the logs:
```bash
app_lua [app_lua_api.c:726]: app_lua_run_ex(): error from Lua:
/etc/kamailio/kamailio.lua:196: attempt to index field 'kx' (a nil value)
```
Referring to the following line in my Lua script:
```lua
function ksr_route_reqinit()
if not KSR.is_myself_srcip() then
local srcip = KSR.kx.get_srcip();
if KSR.htable.sht_match_name("ipban", "eq", srcip) > 0 then
-- ip is already blocked
KSR.dbg("request from blocked IP - " ..
KSR.pv.get("$rm")
.. " from " .. KSR.kex.gete_furi() .. "
(IP:"
.. srcip .. ":" ..
KSR.kex.get_srcport() .. ")\n");
KSR.x.exit();
end
if KSR.pike.pike_check_req() < 0 then
KSR.err("ALERT: pike blocking " .. KSR.pv.get("$rm")
.. " from " .. KSR.kex.gete_furi() .. "
(IP:"
.. srcip .. ":" ..
KSR.kex.get_srcport() .. ")\n");
KSR.htable.sht_seti("ipban", srcip, 1);
KSR.x.exit();
end
end
end
```
- Should this function be available through KSR object ? If yes we're talking
about an issue
Or
- Is this function not supported anymore / not with app_lua ? In this case we
should fix the documentation + the example script
### Troubleshooting
Debian Jessie
Kamailio 5.3
Lua 5.2
Reproduction
I tried different versions, all KO (Kamailio 5.2, 5.3, and last commit on
master: kamailio 5.4.0-dev3 (x86_64/linux) 5afe1e)
1. Install Debian Jessie
2. Clone Kamilio GIT
3. Build from source with make (enabling the desired modules before)
4. Insert Lua script (demo one is fine to reproduce my issue)
Debugging Data
```bash
@b:/# kamailio -V
version: kamailio 5.4.0-dev3 (x86_64/linux) 5afe1e
flags: USE_TCP, USE_TLS, USE_SCTP, TLS_HOOKS, USE_RAW_SOCKS, DISABLE_NAGLE,
USE_MCAST, DNS_IP_HACK, SHM_MMAP, PKG_MALLOC, Q_MALLOC, F_MALLOC, TLSF_MALLOC,
DBG_SR_MEMORY, USE_FUTEX, FAST_LOCK-ADAPTIVE_WAIT, USE_DNS_CACHE,
USE_DNS_FAILOVER, USE_NAPTR, USE_DST_BLACKLIST, HAVE_RESOLV_RES,
TLS_PTHREAD_MUTEX_SHARED
ADAPTIVE_WAIT_LOOPS 1024, MAX_RECV_BUFFER_SIZE 262144, MAX_URI_SIZE 1024,
BUF_SIZE 65535, DEFAULT PKG_SIZE 8MB
poll method support: poll, epoll_lt, epoll_et, sigio_rt, select.
id: 5afe1e
compiled on 14:27:15 Jan 14 2020 with gcc 6.3.0
```
Log Messages
```bash
app_lua [app_lua_api.c:726]: app_lua_run_ex(): error from Lua:
/etc/kamailio/kamailio.lua:196: attempt to index field 'kx' (a nil value)
```
SIP Traffic
Any message going through ksr_route_reqinit() function is triggering the error
Thanks !
--
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/issues/2196___
Kamailio (SER) - Development Mailing List
sr-dev@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev