diff --git a/kamailio/defs.cfg b/kamailio/defs.cfg index 70e7535..32af2ce 100644 --- a/kamailio/defs.cfg +++ b/kamailio/defs.cfg @@ -119,14 +119,6 @@ kazoo.reserved_headers = KZ_RESERVED_HEADERS descr "headers that are removed" #!trydef RR_DOUBLE_RR 1 #!trydef RR_FORCE_SOCKET 1 -#!ifndef KZ_DISABLE_WEBSOCKETS_REGISTRAR_PORT -#!trydef KZ_WEBSOCKETS_REGISTRAR_PORT 7000 -#!endif - -#!ifndef KZ_DISABLE_TLS_REGISTRAR_PORT -#!trydef KZ_TLS_REGISTRAR_PORT 7000 -#!endif - #!trydef KZ_MULTI_HOMED 0 #!trydef KZ_LOG_PREFIX_MODE 1 diff --git a/kamailio/pusher-role.cfg b/kamailio/pusher-role.cfg index 42ac63f..1f912c5 100644 --- a/kamailio/pusher-role.cfg +++ b/kamailio/pusher-role.cfg @@ -119,11 +119,9 @@ route[PUSHER_SEND_PUSH_NOTIFICATION] kazoo_publish("pushes", $avp(push_routing_key), $avp(push_payload)); } -route[PUSHER_ATTEMPT_REGISTRATION] +route[HANDLE_REGISTER_PUSHER] { - if (!is_method("REGISTER")) { - return; - } + if (!is_method("REGISTER")) return; if($hdr(X-Token-Reg) != $null) { if($sht(push_cache=>$hdr(X-Token-Reg)) != $null) { @@ -165,7 +163,7 @@ route[PUSHER_ATTEMPT_REGISTRATION] } } -route[PUSHER_ON_REGISTRATION] +route[ON_REGISTRATION_PUSHER] { if( ( $(xavp(ulattrs=>x_token_reg){s.len}) > 0 || $(xavp(ulattrs=>custom_channel_vars){kz.json,Pusher-Application}{s.len}) > 0) && diff --git a/kamailio/registrar-role.cfg b/kamailio/registrar-role.cfg index 7af930f..5389350 100644 --- a/kamailio/registrar-role.cfg +++ b/kamailio/registrar-role.cfg @@ -8,6 +8,31 @@ #!trydef REGISTRAR_NAT_PING_WORKERS 5 ##### + +#!ifndef KZ_DISABLE_WEBSOCKETS_REGISTRAR_PORT +#!trydef KZ_WEBSOCKETS_REGISTRAR_PORT 7000 +#!endif + +#!ifndef KZ_DISABLE_TLS_REGISTRAR_PORT +#!trydef KZ_TLS_REGISTRAR_PORT 7000 +#!endif + +#!ifndef KZ_DISABLE_TCP_REGISTRAR_PORT +#!trydef KZ_TCP_REGISTRAR_PORT 7000 +#!endif + +#!ifndef KZ_DISABLE_WEBSOCKETS_REGISTRAR_PROXY_PROTO +#!trydef KZ_WEBSOCKETS_REGISTRAR_PROXY_PROTO "udp" +#!endif + +#!ifndef KZ_DISABLE_TLS_REGISTRAR_PROXY_PROTO +#!trydef KZ_TLS_REGISTRAR_PROXY_PROTO "udp" +#!endif + +#!ifndef KZ_DISABLE_TCP_REGISTRAR_PROXY_PROTO +#!trydef KZ_TCP_REGISTRAR_PROXY_PROTO "udp" +#!endif + #!trydef REGISTRAR_MIN_EXPIRES 300 #!trydef REGISTRAR_MAX_EXPIRES 3600 #!trydef REGISTRAR_DEFAULT_EXPIRES 600 @@ -183,10 +208,6 @@ route[HANDLE_REGISTER] routes("HANDLE_REGISTER_"); - #!ifdef PUSHER_ROLE - route(PUSHER_ATTEMPT_REGISTRATION); - #!endif - if($sel(cfg_get.kazoo.registrar_failover) == 1) { xlog("L_INFO", "$ci|registrar|register|forcing failover\n"); update_stat("registrar:force_failover", "+1"); @@ -393,7 +414,79 @@ route[SAVE_LOCATION] $var(ip) = "[" + $Ri + "]"; } + route(REGISTRAR_PORT); + + route(REGISTRAR_PROTO); + + $var(AdvIP) = $RAi; + if(af==INET6) { + $var(AdvIP) = "[" + $RAi + "]"; + } + + #!ifdef WITH_INTERNAL_LISTENER + #!ifdef WITHOUT_REGISTRAR_PROXY_PATH_PROTO + $var(proxy_path) = $_s(sip:MY_IP_ADDRESS:$def(INTERNAL_PORT)); + #!else + $var(proxy_path) = $_s(sip:MY_IP_ADDRESS:$def(INTERNAL_PORT);transport=$def(INTERNAL_PROTO)); + #!endif + $var(proto) = $def(INTERNAL_PROTO); + #!else + #!ifdef WITHOUT_REGISTRAR_PROXY_PATH_PROTO + $var(proxy_path) = $_s(sip:MY_IP_ADDRESS:$var(port)); + #!else + $var(proxy_path) = $_s(sip:MY_IP_ADDRESS:$var(port);transport=$var(proxy_proto)); + #!endif + $var(proto) = $proto; + #!endif + + route(PUBLISH_REGISTRATION); + + routes("ON_REGISTRATION_"); + + exit; +} + +route[REGISTRAR_PROTO] +{ + # allow proto redirection on registration + + switch($proto) + { + #!ifdef KZ_WEBSOCKETS_REGISTRAR_PROXY_PROTO + case "ws": + case "wss": + $var(proxy_proto) = KZ_WEBSOCKETS_REGISTRAR_PROXY_PROTO; + break; + #!endif + + #!ifdef KZ_TLS_REGISTRAR_PROXY_PROTO + case "tls": + $var(proxy_proto) = KZ_TLS_REGISTRAR_PROXY_PROTO; + break; + #!endif + + #!ifdef KZ_UDP_REGISTRAR_PROXY_PROTO + case "udp": + $var(proxy_proto) = KZ_UDP_REGISTRAR_PROXY_PROTO; + break; + #!endif + + #!ifdef KZ_TCP_REGISTRAR_PROXY_PROTO + case "tcp": + $var(proxy_proto) = KZ_TCP_REGISTRAR_PROXY_PROTO; + break; + #!endif + + default: + $var(proxy_proto) = $proto; + } + +} + +route[REGISTRAR_PORT] +{ # allow port redirection on registration + switch($proto) { #!ifdef KZ_WEBSOCKETS_REGISTRAR_PORT @@ -424,39 +517,6 @@ route[SAVE_LOCATION] default: $var(port) = $Rp; } - - $var(AdvIP) = $RAi; - if(af==INET6) { - $var(AdvIP) = "[" + $RAi + "]"; - } - - #!ifdef WITH_INTERNAL_LISTENER - #!ifdef WITHOUT_REGISTRAR_PROXY_PATH_PROTO - $var(proxy_path) = $_s(sip:MY_IP_ADDRESS:$def(INTERNAL_PORT)); - #!else - $var(proxy_path) = $_s(sip:MY_IP_ADDRESS:$def(INTERNAL_PORT);transport=$def(INTERNAL_PROTO)); - #!endif - $var(proto) = $def(INTERNAL_PROTO); - #!else - #!ifdef WITHOUT_REGISTRAR_PROXY_PATH_PROTO - $var(proxy_path) = $_s(sip:MY_IP_ADDRESS:$var(port)); - #!else - $var(proxy_path) = $_s(sip:MY_IP_ADDRESS:$var(port);transport=$proto); - #!endif - $var(proto) = $proto; - #!endif - - route(PUBLISH_REGISTRATION); - - #!ifdef PUSHER_ROLE - route(PUSHER_ON_REGISTRATION); - #!endif - - #!ifdef KEEPALIVE_ROLE - route(KEEPALIVE_ON_REGISTRATION); - #!endif - - exit; } route[PUBLISH_REGISTRATION]