Browse Source

Merge pull request #83 from 2600hz/handle-expired-contacts

handle expired contacts
drop_requests
bitbashing 8 years ago
committed by GitHub
parent
commit
574c224fd4
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 68 additions and 0 deletions
  1. +68
    -0
      kamailio/registrar-role.cfg

+ 68
- 0
kamailio/registrar-role.cfg View File

@ -4,6 +4,14 @@
#!trydef REGISTRAR_MAX_EXPIRES 3600 #!trydef REGISTRAR_MAX_EXPIRES 3600
#!trydef REGISTRAR_CONTACT_MAX_SIZE 2048 #!trydef REGISTRAR_CONTACT_MAX_SIZE 2048
#!trydef REGISTRAR_HANDLE_LOST_TCP 1
#!trydef REGISTRAR_CLOSE_EXPIRED_TCP 1
#!trydef REGISTRAR_HANDLE_EXPIRED_TCP 1
#!trydef REGISTRAR_HANDLE_EXPIRED_UDP 0
#!trydef REGISTRAR_HANDLE_EXPIRED_TLS 1
#!trydef REGISTRAR_HANDLE_EXPIRED_WS 1
######## Generic Hash Table container in shared memory ######## ######## Generic Hash Table container in shared memory ########
modparam("htable", "htable", "auth_cache=>size=16;autoexpire=7200;") modparam("htable", "htable", "auth_cache=>size=16;autoexpire=7200;")
@ -31,6 +39,8 @@ modparam("usrloc", "timer_interval", 30)
modparam("usrloc", "timer_procs", 1) modparam("usrloc", "timer_procs", 1)
modparam("usrloc", "db_timer_clean", 1) modparam("usrloc", "db_timer_clean", 1)
modparam("usrloc", "fetch_rows", 400) modparam("usrloc", "fetch_rows", 400)
modparam("usrloc", "handle_lost_tcp", REGISTRAR_HANDLE_LOST_TCP)
modparam("usrloc", "close_expired_tcp", REGISTRAR_CLOSE_EXPIRED_TCP)
######## NAT Traversal module - signaling functions ######## ######## NAT Traversal module - signaling functions ########
#!ifdef NAT_TRAVERSAL_ROLE #!ifdef NAT_TRAVERSAL_ROLE
@ -57,6 +67,12 @@ modparam("registrar", "received_param", "")
##modparam("registrar", "xavp_rcd", "ulrcd") ##modparam("registrar", "xavp_rcd", "ulrcd")
modparam("registrar", "contact_max_size", REGISTRAR_CONTACT_MAX_SIZE) modparam("registrar", "contact_max_size", REGISTRAR_CONTACT_MAX_SIZE)
##### handle expired registrations realtime params #####
kazoo.registrar_handle_expired_tcp = REGISTRAR_HANDLE_EXPIRED_TCP descr "handles expired tcp registrations"
kazoo.registrar_handle_expired_udp = REGISTRAR_HANDLE_EXPIRED_UDP descr "handles expired udp registrations"
kazoo.registrar_handle_expired_tls = REGISTRAR_HANDLE_EXPIRED_TLS descr "handles expired tls registrations"
kazoo.registrar_handle_expired_ws = REGISTRAR_HANDLE_EXPIRED_WS descr "handles expired ws registrations"
####### Registrar Logic ######## ####### Registrar Logic ########
route[HANDLE_REGISTER] route[HANDLE_REGISTER]
{ {
@ -367,6 +383,58 @@ event_route[kazoo:consumer-event-directory-reg-flush]
#!endif #!endif
} }
event_route[usrloc:contact-expired]
{
$var(transport) = $(ulc(exp=>received){uri.transport});
$var(proto) = $(ulc(exp=>socket){re.subst,/^([^:]*):(.*)/\1/});
if($var(proto) == "tls" && $var(transport) == "ws") {
$var(proto) = "wss";
}
$var(handle) = 0;
switch($var(proto))
{
case "ws":
case "wss":
if(@cfg_get.kazoo.registrar_handle_expired_ws == 1) {
$var(handle) = 1;
}
break;
case "tls":
if(@cfg_get.kazoo.registrar_handle_expired_tls == 1) {
$var(handle) = 1;
}
break;
case "tcp":
if(@cfg_get.kazoo.registrar_handle_expired_tcp == 1) {
$var(handle) = 1;
}
break;
case "udp":
if(@cfg_get.kazoo.registrar_handle_expired_udp == 1) {
$var(handle) = 1;
}
break;
default:
break;
}
if($var(handle) == 1) {
$var(aor) = $_s(sip:$ulc(exp=>aor));
$var(username) = $(var(aor){uri.user});
$var(domain) = $(var(aor){uri.host});
$var(amqp_payload_request) = $_s({"Event-Category" : "directory", "Event-Name" : "reg_success", "Status" : "Unregistered", "Event-Timestamp" : $TS, "Expires" : 0, "First-Registration" : false, "Contact" : "$(ulc(exp=>addr){s.escape.common}{s.replace,\','}{s.replace,$$,})", "Call-ID" : "$ulc(exp=>callid)", "Realm" : "$var(domain)", "Username" : "$var(username)", "From-User" : "$var(username)", "From-Host" : "$var(domain)", "To-User" : "$var(username)", "To-Host" : "$var(domain)", "Proxy-Path" : "$ulc(exp=>socket)", "User-Agent" : "$(ulc(exp=>user_agent){s.escape.common}{s.replace,\','}{s.replace,$$,})"});
$var(amqp_routing_key) = "registration.success." + $(var(domain){kz.encode}) + "." + $(var(username){kz.encode});
kazoo_publish("registrar", $var(amqp_routing_key), $var(amqp_payload_request));
xlog("L_INFO", "$ulc(exp=>callid)|expired|notified kazoo about removed registration with contact : $ulc(exp=>addr)\n");
} else {
xlog("L_INFO", "$ulc(exp=>callid)|expired|removed registration with contact : $ulc(exp=>addr)\n");
}
}
route[REGISTRAR_BINDINGS] route[REGISTRAR_BINDINGS]
{ {
#!import_file "registrar-custom-bindings.cfg" #!import_file "registrar-custom-bindings.cfg"


Loading…
Cancel
Save