|
|
|
@ -2,6 +2,15 @@ |
|
|
|
#!trydef REGISTRAR_NAT_PING_WORKERS 5 |
|
|
|
#!trydef REGISTRAR_MIN_EXPIRES 300 |
|
|
|
#!trydef REGISTRAR_MAX_EXPIRES 3600 |
|
|
|
#!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 ######## |
|
|
|
modparam("htable", "htable", "auth_cache=>size=16;autoexpire=7200;") |
|
|
|
@ -30,6 +39,8 @@ modparam("usrloc", "timer_interval", 30) |
|
|
|
modparam("usrloc", "timer_procs", 1) |
|
|
|
modparam("usrloc", "db_timer_clean", 1) |
|
|
|
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 ######## |
|
|
|
#!ifdef NAT_TRAVERSAL_ROLE |
|
|
|
@ -54,6 +65,13 @@ modparam("registrar", "path_mode", 1) |
|
|
|
modparam("registrar", "use_path", 1) |
|
|
|
modparam("registrar", "received_param", "") |
|
|
|
##modparam("registrar", "xavp_rcd", "ulrcd") |
|
|
|
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 ######## |
|
|
|
route[HANDLE_REGISTER] |
|
|
|
@ -69,8 +87,8 @@ route[HANDLE_REGISTER] |
|
|
|
|
|
|
|
## KAZOO-1846: Cisco SPA8000 freaks out on options pings |
|
|
|
if (!($ua =~ "Linksys/SPA8000" |
|
|
|
|| $ua =~ "OpenBTS" |
|
|
|
|| $ua =~ "SIPp" |
|
|
|
|| $ua =~ "OpenBTS" |
|
|
|
|| $ua =~ "SIPp" |
|
|
|
|| (af==INET6) |
|
|
|
)) { |
|
|
|
setbflag(FLB_NATB); |
|
|
|
@ -108,6 +126,9 @@ route[AUTHORIZATION_CHECK] |
|
|
|
|
|
|
|
route[ATTEMPT_AUTHORIZATION] |
|
|
|
{ |
|
|
|
#!ifdef PUSHER_ROLE |
|
|
|
route(PUSHER_ATTEMPT_REGISTRATION); |
|
|
|
#!endif |
|
|
|
|
|
|
|
$var(nonce) = $(uuid(g){s.rm,-}); |
|
|
|
#!ifdef OPENBTS_AUTH_ROLE |
|
|
|
@ -190,33 +211,27 @@ route[KAZOO_AUTHORIZATION_ERROR] |
|
|
|
|
|
|
|
route[CHECK_AUTHORIZATION] |
|
|
|
{ |
|
|
|
|
|
|
|
if($ua =~ "OpenBTS") { |
|
|
|
xlog("L_INFO", "$ci|end|OPENBTS attempt for $Au $si:$sp\n"); |
|
|
|
} else { |
|
|
|
|
|
|
|
if($var(password) == $null || $var(password) == "") { |
|
|
|
auth_challenge("$fd", "0"); |
|
|
|
xlog("L_INFO", "$ci|end|issued auth challenge to registration attempt for $Au $si:$sp\n"); |
|
|
|
exit; |
|
|
|
} |
|
|
|
|
|
|
|
if (!pv_auth_check("$fd", "$var(password)", "0", "0")) { |
|
|
|
#!ifdef ANTIFLOOD_ROLE |
|
|
|
route(ANITFLOOD_FAILED_AUTH); |
|
|
|
#!endif |
|
|
|
if($var(password) == $null || $var(password) == "") { |
|
|
|
auth_challenge("$fd", "0"); |
|
|
|
xlog("L_INFO", "$ci|end|issued auth challenge to registration attempt for $Au $si:$sp\n"); |
|
|
|
exit; |
|
|
|
} |
|
|
|
|
|
|
|
auth_challenge("$fd", "0"); |
|
|
|
xlog("L_WARNING", "$ci|end|issued auth challenge to failed registration attempt for $Au from IP $si:$sp\n"); |
|
|
|
exit; |
|
|
|
} |
|
|
|
if (!pv_auth_check("$fd", "$var(password)", "0", "0")) { |
|
|
|
#!ifdef ANTIFLOOD_ROLE |
|
|
|
route(ANITFLOOD_FAILED_AUTH); |
|
|
|
#!endif |
|
|
|
|
|
|
|
auth_challenge("$fd", "0"); |
|
|
|
xlog("L_WARNING", "$ci|end|issued auth challenge to failed registration attempt for $Au from IP $si:$sp\n"); |
|
|
|
exit; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#!ifdef ANTIFLOOD_ROLE |
|
|
|
route(ANTIFLOOD_SUCCESSFUL_AUTH); |
|
|
|
#!endif |
|
|
|
@ -230,7 +245,6 @@ route[CHECK_AUTHORIZATION] |
|
|
|
|
|
|
|
route[SAVE_LOCATION] |
|
|
|
{ |
|
|
|
|
|
|
|
if ($sht(auth_cache=>$Au) == $null) { |
|
|
|
xlog("L_INFO", "$ci|log|caching sip credentials for $Au\n"); |
|
|
|
}; |
|
|
|
@ -254,7 +268,7 @@ route[SAVE_LOCATION] |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if(@hf_value_exists.contact.expires == "1") { |
|
|
|
if((int)@contact.expires) { |
|
|
|
$var(expires) = @contact.expires; |
|
|
|
} else { |
|
|
|
if(is_present_hf("Expires")) { |
|
|
|
@ -264,6 +278,14 @@ route[SAVE_LOCATION] |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
## this is what we should be using |
|
|
|
## but ulrcd seems to have a weird leak |
|
|
|
## if($var(save_result) == 3) { |
|
|
|
## $var(expires) = 0; |
|
|
|
## } else { |
|
|
|
## $var(expires) = $xavp(ulrcd=>expires); |
|
|
|
## } |
|
|
|
|
|
|
|
if($var(expires) == 0) { |
|
|
|
xlog("L_INFO", "$ci|end|unregister request from $Au $si:$sp\n"); |
|
|
|
$var(Status) = "Unregistered"; |
|
|
|
@ -281,13 +303,43 @@ route[SAVE_LOCATION] |
|
|
|
$var(ip) = "[" + $Ri + "]"; |
|
|
|
} |
|
|
|
|
|
|
|
$var(port) = $Rp; |
|
|
|
# allow port redirection on registration |
|
|
|
switch($proto) |
|
|
|
{ |
|
|
|
#!ifdef KZ_WEBSOCKETS_REGISTRAR_PORT |
|
|
|
case "ws": |
|
|
|
case "wss": |
|
|
|
$var(port) = KZ_WEBSOCKETS_REGISTRAR_PORT; |
|
|
|
break; |
|
|
|
#!endif |
|
|
|
|
|
|
|
#!ifdef KZ_TLS_REGISTRAR_PORT |
|
|
|
case "tls": |
|
|
|
$var(port) = KZ_TLS_REGISTRAR_PORT; |
|
|
|
break; |
|
|
|
#!endif |
|
|
|
|
|
|
|
#!ifdef KZ_UDP_REGISTRAR_PORT |
|
|
|
case "udp": |
|
|
|
$var(port) = KZ_UDP_REGISTRAR_PORT; |
|
|
|
break; |
|
|
|
#!endif |
|
|
|
|
|
|
|
#!ifdef KZ_TCP_REGISTRAR_PORT |
|
|
|
case "tcp": |
|
|
|
$var(port) = KZ_TCP_REGISTRAR_PORT; |
|
|
|
break; |
|
|
|
#!endif |
|
|
|
|
|
|
|
default: |
|
|
|
$var(port) = $Rp; |
|
|
|
} |
|
|
|
|
|
|
|
$var(AdvIP) = $RAi; |
|
|
|
if(af==INET6) { |
|
|
|
$var(AdvIP) = "[" + $RAi + "]"; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$var(amqp_payload_request) = $_s({"Event-Category" : "directory", "Event-Name" : "reg_success", "Status" : "$var(Status)", "Event-Timestamp" : $TS, "Expires" : $(var(expires){s.int}), "First-Registration" : $var(new_reg), "Contact" : "$(ct{s.escape.common}{s.replace,\','}{s.replace,$$,})", "Call-ID" : "$ci", "Realm" : "$fd", "Username" : "$fU", "From-User" : "$fU", "From-Host" : "$fd", "To-User" : "$tU", "To-Host" : "$td", "User-Agent" : "$(ua{s.escape.common}{s.replace,\','}{s.replace,$$,})" , "Custom-Channel-Vars" : $xavp(ulattrs=>custom_channel_vars), "Proxy-Path" : "sip:$var(ip):$var(port)", "Proxy-Protocol" : "$proto", "Proxy-IP" : "$var(AdvIP)", "Proxy-Port" : "$RAp", "Source-IP": "$si", "Source-Port": "$sp" }); |
|
|
|
$var(amqp_routing_key) = "registration.success." + $(fd{kz.encode}) + "." + $(fU{kz.encode}); |
|
|
|
@ -320,22 +372,74 @@ event_route[kazoo:consumer-event-directory-reg-flush] |
|
|
|
} |
|
|
|
reg_free_contacts("caller"); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#!ifdef ANTIFLOOD_ROLE |
|
|
|
route(ANTIFLOOD_RESET_AUTH); |
|
|
|
#!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] |
|
|
|
{ |
|
|
|
#!import_file "registrar-custom-bindings.cfg" |
|
|
|
|
|
|
|
#!ifndef REGISTRAR_CUSTOM_BINDINGS |
|
|
|
|
|
|
|
#!ifndef REGISTRAR_CUSTOM_BINDINGS |
|
|
|
|
|
|
|
$var(payload) = "{ 'exchange' : 'registrar' , 'type' : 'topic', 'queue' : 'registrar-flush-MY_HOSTNAME', 'routing' : 'registration.flush.*', 'federate' : 1 }"; |
|
|
|
kazoo_subscribe("$var(payload)"); |
|
|
|
|
|
|
|
|
|
|
|
#!endif |
|
|
|
|
|
|
|
#!ifdef REGISTRAR_SYNC_ROLE |
|
|
|
|