[SR-Users] registrar and check registered
Victor V. Kustov
coyote at bks.tv
Tue Mar 12 15:04:57 CET 2013
Hi.
I try to use Kamailio 4.1 git version as registrar and PSTN gw.
Need accept register from users. Its OK, I made it and use save()
function - from keep registrations in case of kamailio restart.
Need forward calls to gw, but only for registered users.
If I understand correctly in INVITE enough check
registered("location"), isnt it? but it's not work, i need verify auth
again.
Routing part of my config:
route {
# initial sanity checks - skip in letter
# We are registrar!
if (is_method("REGISTER"))
{
sl_send_reply("100", "Trying"); # send "Trying, dont threat on me
if(isflagset(FLT_NATS))
{
setbflag(FLB_NATB);
# uncomment next line to do SIP NAT pinging
## setbflag(FLB_NATSIPPING);
}
# we must check auth right now
# WORK: if (!www_authorize("$fd", "subscriber"))
if (!auth_check("$fd", "subscriber", "1"))
{
# WORK: www_challenge("$fd", "0");
auth_challenge("$fd", "0");
# send me requisites plz
exit;
} else
{
# ok. auth accepted, save in location
if (save("location"))
#if (save("location","0x04","$fd"))
{
xlog("L_WARN", "Save OK in location sip:$au@$fd");
} else
{
xlog("L_WARN", "Save FAIL in location sip:$au@$fd");
}
}
xlog("L_WARN", "REGISTERED method done");
exit;
}
if (is_method("INVITE"))
{
if ($si == $sel(cfg_get.pstn.gw_ip))
{
# incoming calls
xlog("L_WARN", "Incoming call");
} else
{
# outgoing calls
xlog("L_WARN", "Outgoing call");
# check auth
# we must check auth right now
if (!proxy_authorize("$fd", "subscriber"))
{
proxy_challenge("$fd", "0");
exit;
}
consume_credentials();
### THAT FUNCTIONS ALWAYS WRITE IN LOGS
# "!registered" "!lookup" for both registered and unregged users
# if (!registered("location")) xlog("L_WARN","!registered");
# if (!lookup("location")) xlog("L_WARN", "!lookup");
# number change - FIX late
# check may be used dialplan automatically?
# route
$ru = "sip:" + $rU + "@" + $sel(cfg_get.pstn.gw_ip);
xlog("L_WARN", "Rewrite to $ru, send to PSTN.");
if (!t_relay()) { sl_reply_error(); }
}
} else
{
# reply 2 keepalive and drop all
# if (!t_relay()) { sl_reply_error(); }
}
}
--
SY,
Victor V. Kustov
+7 (952) 966 76 24
JID: coyote at bks.tv
JID: coyote at bryansktel.ru
I use FREE operation system: 3.7.7-calculate GNU/Linux
More information about the sr-users
mailing list