I am currently using an older version of Kamailio in production. I want to be able to write some custom logic, and v5 allows me to do that in Python using the KEMI interpreter - so I'm interested in upgrading. However I'm encountering something I've never seen before..
The example script on the Kamailio website shows this sample .py script:
import sys
import KSR as KSR
def dumpObj(obj):
for attr in dir(obj):
KSR.info("obj.%s = %s\n" % (attr, getattr(obj, attr)))
def mod_init():
KSR.info("===== from Python mod init\n")
# dumpObj(KSR)
return kamailio()
class kamailio:
def __init__(self):
KSR.info('===== kamailio.__init__\n')
def child_init(self, rank):
KSR.info('===== kamailio.child_init(%d)\n' % rank)
return 0
def ksr_request_route(self, msg):
KSR.info("===== request - from kamailio python script\n")
KSR.setdsturi("sip:alice@127.0.0.1:5080")
KSR.tm.t_on_branch("ksr_branch_route_one")
KSR.tm.t_on_reply("ksr_onreply_route_one")
KSR.tm.t_on_failure("ksr_failure_route_one")
KSR.sl.send_reply(100, "Trying")
if KSR.tm.t_relay() < 0 :
KSR.sl.send_reply(500, "Server error")
return 1
def ksr_reply_route(self, msg):
KSR.info("===== response - from kamailio python script\n")
return 1
def ksr_onsend_route(self, msg):
KSR.info("===== onsend route - from kamailio python script\n")
return 1
def ksr_branch_route_one(self, msg):
KSR.info("===== branch route - from kamailio python script\n")
return 1
def ksr_onreply_route_one(self, msg):
KSR.info("===== onreply route - from kamailio python script\n")
return 1
def ksr_failure_route_one(self, msg):
KSR.info("===== failure route - from kamailio python script\n")
return 1
So my question is: Where does "KSR" come from? It almost seems like Kamailio is magically hanging that library out there for Python to import. I can't find any way to pip install it, so I'm curious to hear what the deal is, if anyone knows.
Thanks!