You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
lua-ngcp-kamailio/kamailio_conf.lua.tt2

79 lines
2.3 KiB

#!/usr/bin/env lua5.1
-- Kamailio Lua Config
require 'ngcp.ngcp'
ngcp = NGCP:new()
loaded_keys = {caller={real={}, peer={}}, callee={real={}, peer={}}}
-- set config
ngcp.config.db_user = "[% kamailio.proxy.dbrwuser %]"
ngcp.config.db_pass = "[% kamailio.proxy.dbrwpw %]"
ngcp.config.db_host = "[% database.dbhost %]"
ngcp.config.db_database = "[% kamailio.proxy.dbname %]"
function ngcp_test()
print = function(msg)
sr.log("info", msg)
end
require('tests.test_kamailio')
end
function ngcp_clean(vtype)
local real = ""
local peer = ""
if #loaded_keys > 0 then
sr.log('loaded_keys has values\n')
end
ngcp:clean(vtype)
local keys = loaded_keys["caller"]
if keys and keys[real] then
real = table.tostring(keys.real)
end
if keys and keys[peer] then
peer = table.tostring(keys.peer)
end
sr.log("info", string.format("caller-> real: %s peer: %s", real, peer))
keys = loaded_keys["callee"]
if keys and keys[real] then
real = table.tostring(keys.real)
end
if keys and keys[peer] then
peer = table.tostring(keys.peer)
end
sr.log("info", string.format("callee-> real: %s peer: %s", real, peer))
end
function print_loaded_prefs(vtype)
local _,v
local xavp = NGCPRealPrefs:xavp(vtype)
for _,v in pairs(loaded_keys[vtype].real) do
sr.log("info", string.format("real key:%s value:%s\n", v, xavp(v)))
end
xavp = NGCPPeerPrefs:xavp(vtype)
for _,v in pairs(loaded_keys[vtype].peer) do
sr.log("info", string.format("peer key:%s value:%s\n", v, xavp(v)))
end
end
function ngcp_load_caller_peer(peer)
ngcp_load_caller(nil, nil, peer)
end
function ngcp_load_callee_peer(peer)
ngcp_load_callee(nil, nil, peer)
end
function ngcp_load_caller(uuid, domain, peer)
loaded_keys["caller"] = ngcp:caller_load(uuid, domain, peer)
local keys = loaded_keys["caller"]
sr.log("info", string.format("real: %s peer: %s", table.tostring(keys.real), table.tostring(keys.peer)))
end
function ngcp_load_callee(uuid, domain, peer)
loaded_keys["callee"] = ngcp:caller_load(uuid, domain, peer)
local keys = loaded_keys["callee"]
sr.log("info", string.format("real: %s peer: %s", table.tostring(keys.real), table.tostring(keys.peer)))
end
--EOF