Hey @wedhornsipgate,
I have implement these extra KEMI functions in https://github.com/xkaraman/kamailio/tree/htable_kemi. You can have a look and try it your self and give any feedback.
Here is how i am using it with KEMI Python engine
KSR.htable.sht_setxs("ipban", "pattern1", "value",50)
KSR.htable.sht_setxs("ipban", "pattern2", "value1",50)
KSR.htable.sht_setxs("ipban", "nopatter23", "value52",50)
KSR.htable.sht_setxs("ipban", "abcd2", "empty1",50)
# KSR.htable.sht_print()
exact="pattern1"
count_exact = KSR.htable.shtcn_match("ipban", exact, 0)
KSR.info("Exact match count for pattern [%s]: %d\n" % (exact, count_exact))
count_exact = KSR.htable.shtcn_exact("ipban", exact)
KSR.info("Exact match count (exact) for pattern [%s]: %d\n" % (exact, count_exact))
startwith="pattern"
count_startwith = KSR.htable.shtcn_match("ipban", startwith, 1)
KSR.info("Startwith match count for pattern [%s]: %d\n" % (startwith, count_startwith))
count_startwith = KSR.htable.shtcn_prefix("ipban", startwith)
KSR.info("Startwith match count (prefix) for pattern [%s]: %d\n" % (startwith, count_startwith))
endwith="2"
count_endwith = KSR.htable.shtcn_match("ipban", endwith, 2)
KSR.info("Endwith match count for pattern [%s]: %d\n" % (endwith, count_endwith))
count_endwith = KSR.htable.shtcn_suffix("ipban", endwith)
KSR.info("Endwith match count (suffix) for pattern [%s]: %d\n" % (endwith, count_endwith))
regex="^pat.*2$"
count_regex = KSR.htable.shtcn_match("ipban", regex, 3)
KSR.info("Regex match count for pattern [%s]: %d\n" % (regex, count_regex))
count_regex = KSR.htable.shtcn_regex("ipban", regex)
KSR.info("Regex match count (regex) for pattern [%s]: %d\n" % (regex, count_regex))and the respective output logs:
Nov 5 11:00:18 app01 sbin/kamailio[3338583]: INFO: {1 2426 REGISTER u30SqMAHWR} <core> [core/kemi.c:109]: sr_kemi_core_info(): ===== request - from kamailio python script
Nov 5 11:00:18 app01 sbin/kamailio[3338583]: INFO: {1 2426 REGISTER u30SqMAHWR} <core> [core/kemi.c:109]: sr_kemi_core_info(): Exact match count for pattern [pattern1]: 1
Nov 5 11:00:18 app01 sbin/kamailio[3338583]: INFO: {1 2426 REGISTER u30SqMAHWR} <core> [core/kemi.c:109]: sr_kemi_core_info(): Exact match count (exact) for pattern [pattern1]: 1
Nov 5 11:00:18 app01 sbin/kamailio[3338583]: INFO: {1 2426 REGISTER u30SqMAHWR} <core> [core/kemi.c:109]: sr_kemi_core_info(): Startwith match count for pattern [pattern]: 2
Nov 5 11:00:18 app01 sbin/kamailio[3338583]: INFO: {1 2426 REGISTER u30SqMAHWR} <core> [core/kemi.c:109]: sr_kemi_core_info(): Startwith match count (prefix) for pattern [pattern]: 2
Nov 5 11:00:18 app01 sbin/kamailio[3338583]: INFO: {1 2426 REGISTER u30SqMAHWR} <core> [core/kemi.c:109]: sr_kemi_core_info(): Endwith match count for pattern [2]: 2
Nov 5 11:00:18 app01 sbin/kamailio[3338583]: INFO: {1 2426 REGISTER u30SqMAHWR} <core> [core/kemi.c:109]: sr_kemi_core_info(): Endwith match count (suffix) for pattern [2]: 2
Nov 5 11:00:18 app01 sbin/kamailio[3338583]: INFO: {1 2426 REGISTER u30SqMAHWR} <core> [core/kemi.c:109]: sr_kemi_core_info(): Regex match count for pattern [^pat.*2$]: 1
Nov 5 11:00:18 app01 sbin/kamailio[3338583]: INFO: {1 2426 REGISTER u30SqMAHWR} <core> [core/kemi.c:109]: sr_kemi_core_info(): Regex match count (regex) for pattern [^pat.*2$]: 1—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()