From 8c2fa07a861cd90840db3cc8b5efbce482948e12 Mon Sep 17 00:00:00 2001 From: karl anderson Date: Thu, 4 Dec 2014 21:22:58 -0500 Subject: [PATCH 01/33] KAZOO-3176: include ctl.so as well ss the kazoo event payload to make debuging presence easier --- kamailio/default.cfg | 3 +++ kamailio/presence-role.cfg | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/kamailio/default.cfg b/kamailio/default.cfg index 2dbb4e1..04cb12e 100644 --- a/kamailio/default.cfg +++ b/kamailio/default.cfg @@ -82,6 +82,9 @@ disable_sctp = yes ####### Modules Section ######## mpath="/usr/lib64/kamailio/modules/" +######## Kamailio control connector module ######## +loadmodule "ctl.so" + ######## Kamailio core extensions module ######## loadmodule "kex.so" diff --git a/kamailio/presence-role.cfg b/kamailio/presence-role.cfg index 7589833..cc4cf00 100644 --- a/kamailio/presence-role.cfg +++ b/kamailio/presence-role.cfg @@ -82,7 +82,7 @@ route[HANDLE_PUBLISH] event_route[kazoo:consumer-event-presence-update] { - xlog("L_INFO", "received $(kzE{kz.json,Event-Package}) update for $(kzE{kz.json,From})"); + xlog("L_INFO", "received $(kzE{kz.json,Event-Package}) update for $(kzE{kz.json,From}) $kzE"); kazoo_pua_publish($kzE); pres_refresh_watchers("$(kzE{kz.json,From})", "$(kzE{kz.json,Event-Package})", 1); From cf60b5b74f03317ca4e17bea2844bf72352eda6d Mon Sep 17 00:00:00 2001 From: lazedo Date: Tue, 9 Dec 2014 01:45:55 +0000 Subject: [PATCH 02/33] fix expires --- kamailio/registrar-role.cfg | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/kamailio/registrar-role.cfg b/kamailio/registrar-role.cfg index 4cb2c41..fff5fab 100644 --- a/kamailio/registrar-role.cfg +++ b/kamailio/registrar-role.cfg @@ -107,13 +107,14 @@ route[ATTEMPT_AUTHORIZATION] consume_credentials(); save("location"); - $var(expires) = @contact.expires; - if($var(expires) == $null) { - $var(expires) = $hdr(Expires); - } - - if($var(expires) == $null) { - $var(expires) = REGISTRAR_MIN_EXPIRES; + if(@contact.expires) { + $var(expires) = @contact.expires; + } else { + if($hdr(Expires)) { + $var(expires) = $hdr(Expires); + } else { + $var(expires) = REGISTRAR_MIN_EXPIRES; + } } if($var(expires) == 0) { From 0bbe4c9ef6e001d32bb6ebbfe6f030465daa1353 Mon Sep 17 00:00:00 2001 From: lazedo Date: Wed, 10 Dec 2014 02:30:08 +0000 Subject: [PATCH 03/33] handle duplicate events handle duplicate events since dbtext doesn't support transactions --- kamailio/presence-role.cfg | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/kamailio/presence-role.cfg b/kamailio/presence-role.cfg index cc4cf00..40a3353 100644 --- a/kamailio/presence-role.cfg +++ b/kamailio/presence-role.cfg @@ -1,4 +1,6 @@ ######## Presence server module ######## +modparam("htable", "htable", "p=>size=32;autoexpire=600;") + loadmodule "presence.so" loadmodule "presence_dialoginfo.so" loadmodule "presence_mwi.so" @@ -82,10 +84,22 @@ route[HANDLE_PUBLISH] event_route[kazoo:consumer-event-presence-update] { - xlog("L_INFO", "received $(kzE{kz.json,Event-Package}) update for $(kzE{kz.json,From}) $kzE"); - kazoo_pua_publish($kzE); - pres_refresh_watchers("$(kzE{kz.json,From})", "$(kzE{kz.json,Event-Package})", 1); - + if( $(kzE{kz.json,Event-Package}) == "dialog") { + if($sht(p=>$(kzE{kz.json,Call-ID})) != $(kzE{kz.json,State})) { + xlog("L_INFO", "received $(kzE{kz.json,Event-Package}) update for $(kzE{kz.json,From}) $kzE"); + xlog("L_INFO", "payload $kzE"); + $sht(p=>$(kzE{kz.json,Call-ID})) = $(kzE{kz.json,State}); + kazoo_pua_publish($kzE); + pres_refresh_watchers("$(kzE{kz.json,From})", "$(kzE{kz.json,Event-Package})", 1); + } else { + xlog("L_INFO", "received duplicate $(kzE{kz.json,Event-Package}) update for $(kzE{kz.json,From}) $kzE"); + xlog("L_INFO", "payload $kzE"); + } + } else { + xlog("L_INFO", "received $(kzE{kz.json,Event-Package}) update for $(kzE{kz.json,From}) $kzE"); + kazoo_pua_publish($kzE); + pres_refresh_watchers("$(kzE{kz.json,From})", "$(kzE{kz.json,Event-Package})", 1); + } } # vim: tabstop=4 softtabstop=4 shiftwidth=4 expandtab From faffa468510e6f5c98366e6aa9ec20c290547189 Mon Sep 17 00:00:00 2001 From: lazedo Date: Wed, 10 Dec 2014 14:17:24 +0000 Subject: [PATCH 04/33] removed extra log --- kamailio/presence-role.cfg | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kamailio/presence-role.cfg b/kamailio/presence-role.cfg index 40a3353..be4a015 100644 --- a/kamailio/presence-role.cfg +++ b/kamailio/presence-role.cfg @@ -86,13 +86,13 @@ event_route[kazoo:consumer-event-presence-update] { if( $(kzE{kz.json,Event-Package}) == "dialog") { if($sht(p=>$(kzE{kz.json,Call-ID})) != $(kzE{kz.json,State})) { - xlog("L_INFO", "received $(kzE{kz.json,Event-Package}) update for $(kzE{kz.json,From}) $kzE"); + xlog("L_INFO", "received $(kzE{kz.json,Event-Package}) update for $(kzE{kz.json,From})"); xlog("L_INFO", "payload $kzE"); $sht(p=>$(kzE{kz.json,Call-ID})) = $(kzE{kz.json,State}); kazoo_pua_publish($kzE); pres_refresh_watchers("$(kzE{kz.json,From})", "$(kzE{kz.json,Event-Package})", 1); } else { - xlog("L_INFO", "received duplicate $(kzE{kz.json,Event-Package}) update for $(kzE{kz.json,From}) $kzE"); + xlog("L_INFO", "received duplicate $(kzE{kz.json,Event-Package}) update for $(kzE{kz.json,From})"); xlog("L_INFO", "payload $kzE"); } } else { From 55976a6cc3d2b6b85dc257b80b84f7e3c4175259 Mon Sep 17 00:00:00 2001 From: James Aimonetti Date: Tue, 13 Jan 2015 14:42:19 -0800 Subject: [PATCH 05/33] Encode SIP username When constructing reg_success routing key, realm and username need encoding before building the routing key. --- kamailio/registrar-role.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kamailio/registrar-role.cfg b/kamailio/registrar-role.cfg index fff5fab..e43cf08 100644 --- a/kamailio/registrar-role.cfg +++ b/kamailio/registrar-role.cfg @@ -146,7 +146,7 @@ route[ATTEMPT_AUTHORIZATION] $var(amqp_payload_request) = '{"Event-Category" : "directory", "Event-Name" : "reg_success", "Contact" : "' + $var(fs_contact) + '", "Call-ID" : "' + $ci + '", "Realm" : "' + $fd + '", "Username" : "' + $fU + '", "From-User" : "' + $fU + '", "From-Host" : "' + $fd + '", "To-User" : "' + $tU + '", "To-Host" : "' + $td + '", "User-Agent" : "' + $ua + '" ,' + $var(register_contants) + ' }'; - $var(amqp_routing_key) = "registration.success." + $(fd{kz.encode}) + "." + $fU; + $var(amqp_routing_key) = "registration.success." + $(fd{kz.encode}) + "." + $(fU{kz.encode}); kazoo_publish("callmgr", $var(amqp_routing_key), $var(amqp_payload_request)); From 025fe56738328e0ab29fa1d575fe7c4db4700423 Mon Sep 17 00:00:00 2001 From: karl anderson Date: Fri, 16 Jan 2015 15:03:40 -0800 Subject: [PATCH 06/33] Prepare master for 3.19 tag --- config.ini | 40 +++++----------------------------- haproxy/haproxy.cfg | 47 ++++++++++++++++++++-------------------- rabbitmq/rabbitmq.config | 4 ++-- 3 files changed, 31 insertions(+), 60 deletions(-) diff --git a/config.ini b/config.ini index c052afa..f957b5b 100644 --- a/config.ini +++ b/config.ini @@ -1,53 +1,25 @@ ; section are between [] = [section] ; key = value ; to comment add ";" in front of the line -; -; -; NOTE: You must add all your FreeSWITCH servers to the trusted ACLs -; if you are using zones! -; +[amqp] +uri = "amqp://guest:guest@127.0.0.1:5672" + [bigcouch] compact_automatically = true cookie = change_me ip = "127.0.0.1" port = 15984 -;username = "kazoo" -;password = "supermegaexcellenttelephonyplatform" +; username = "kazoo" +; password = "supermegaexcellenttelephonyplatform" admin_port = 15986 -; Define your AMQPs and zones here -[zone] -name = zone_1 -amqp_uri = "amqp://guest:guest@127.0.0.1:5672" - -;[zone] -;name = zone_2 -;amqp_uri = "amqp://guest:guest@127.0.0.2:5672" - -; Define your whistles here [whistle_apps] -;host = apps001.2600hz.com -zone = zone_1 cookie = change_me -;[whistle_apps] -;host = apps002.2600hz.com -;zone = zone_2 -;cookie = change_me - -; Define your ecallmgr's here [ecallmgr] -;host = apps001.2600hz.com -zone = zone_1 cookie = change_me -;[ecallmgr] -;host = apps002.2600hz.com -;zone = zone_2 -;cookie = change_me - [log] -syslog = debug +syslog = info console = notice file = error - diff --git a/haproxy/haproxy.cfg b/haproxy/haproxy.cfg index 3f9ece8..a2201fc 100644 --- a/haproxy/haproxy.cfg +++ b/haproxy/haproxy.cfg @@ -1,40 +1,39 @@ global - log 127.0.0.1 local0 - log 127.0.0.1 local1 notice - maxconn 4096 - user haproxy - group haproxy - stats socket /tmp/haproxy.sock mode 777 + log 127.0.0.1 local0 + log 127.0.0.1 local1 notice + maxconn 4096 + user haproxy + group haproxy + stats socket /tmp/haproxy.sock mode 777 defaults - log global - mode http - option httplog - option dontlognull - option redispatch - option httpchk GET / - option allbackups - option http-server-close - maxconn 2000 - retries 3 - timeout connect 6000ms - timeout client 120000ms - timeout server 120000ms - + log global + mode http + option httplog + option dontlognull + option redispatch + option httpchk GET / + option allbackups + maxconn 2000 + retries 3 + timeout connect 6000ms + timeout client 12000ms + timeout server 12000ms + listen bigcouch-data 127.0.0.1:15984 - balance roundrobin + balance roundrobin server db1.zone1.mydomain.com 127.0.0.1:5984 check server db2.zone1.mydomain.com 127.0.0.2:5984 check server db3.zone2.mydomain.com 127.0.0.3:5984 check backup server db4.zone2.mydomain.com 127.0.0.4:5984 check backup listen bigcouch-mgr 127.0.0.1:15986 - balance roundrobin + balance roundrobin server db1.zone1.mydomain.com 127.0.0.1:5986 check server db2.zone1.mydomain.com 127.0.0.2:5986 check server db3.zone2.mydomain.com 127.0.0.3:5986 check backup server db4.zone2.mydomain.com 127.0.0.4:5986 check backup listen haproxy-stats 127.0.0.1:22002 - mode http - stats uri / + mode http + stats uri / diff --git a/rabbitmq/rabbitmq.config b/rabbitmq/rabbitmq.config index fca901a..1d86f32 100644 --- a/rabbitmq/rabbitmq.config +++ b/rabbitmq/rabbitmq.config @@ -1,6 +1,6 @@ -[{rabbit, [{disk_free_limit, 5242880} +[ +{rabbit, [{disk_free_limit, 5242880} ,{vm_memory_high_watermark, 0.8} - ,{hipe_compile, true} ,{loopback_users, []} ]}, {rabbitmq_management_agent, [ {force_fine_statistics, false} ] } From 03309d313c4522b217646422f12831454302e185 Mon Sep 17 00:00:00 2001 From: lazedo Date: Wed, 4 Feb 2015 02:57:06 +0000 Subject: [PATCH 07/33] KAZOO-3265 MESSAGE-ROLE --- kamailio/default.cfg | 47 ++++++++++++++++++++++++++----- kamailio/local.cfg | 1 + kamailio/message-role.cfg | 58 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 99 insertions(+), 7 deletions(-) create mode 100644 kamailio/message-role.cfg diff --git a/kamailio/default.cfg b/kamailio/default.cfg index 04cb12e..9a9bd90 100644 --- a/kamailio/default.cfg +++ b/kamailio/default.cfg @@ -174,6 +174,9 @@ include_file "registrar-role.cfg" #!ifdef PRESENCE-ROLE include_file "presence-role.cfg" #!endif +#!ifdef MESSAGE-ROLE +include_file "message-role.cfg" +#!endif #!ifdef NAT-TRAVERSAL-ROLE include_file "nat-traversal-role.cfg" #!endif @@ -322,14 +325,44 @@ route[HANDLE_NOTIFY] route[HANDLE_MESSAGE] { - if (is_method("MESSAGE")) { - if (isflagset(FLAG_INTERNALLY_SOURCED)) { - route(INTERNAL_TO_EXTERNAL_RELAY); - } else { - sl_send_reply("202", "delivered to /dev/null"); - exit; + #!ifdef MESSAGE-ROLE + + if (is_method("MESSAGE")) { + xlog("L_INFO", "$ci|MESSAGE from $fu to $tu"); + if (isflagset(FLAG_INTERNALLY_SOURCED) || src_ip == myself) { + xlog("L_INFO", "$ci| routing MESSAGE to external from $fu to $tu"); + route(INTERNAL_TO_EXTERNAL_RELAY); + #!ifdef TRAFFIC-FILTER-ROLE + } else if (!isflagset(FLAG_TRUSTED_SOURCE) + && $rd =~ "[0-9]{1,3}\.[0-9]{1,3}.[0-9]{1,3}\.[0-9]{1,3}") { + xlog("L_WARN", "$ci|end|dropping MESSAGE request with IP domain"); + #!endif + } else { + xlog("L_WARN", "$ci|end|MESSAGE $(hdr(Content-Type))"); + if( $hdr(Content-Type) == "application/im-iscomposing+xml" ) { + xlog("L_WARN", "$ci|end|dropping MESSAGE application/im-iscomposing+xml"); + sl_send_reply("200", "OK"); + } else { + route(DISPATCHER_FIND_ROUTES); + route(EXTERNAL_TO_INTERNAL_RELAY); + } + } + exit(); } - } + + #!else + + if (is_method("MESSAGE")) { + if (isflagset(FLAG_INTERNALLY_SOURCED)) { + route(INTERNAL_TO_EXTERNAL_RELAY); + } else { + sl_send_reply("202", "delivered to /dev/null"); + exit; + } + } + + #!endif + } route[HANDLE_IN_DIALOG_REQUESTS] diff --git a/kamailio/local.cfg b/kamailio/local.cfg index 69b1000..f06e814 100644 --- a/kamailio/local.cfg +++ b/kamailio/local.cfg @@ -11,6 +11,7 @@ debug = L_INFO #!trydef NAT-TRAVERSAL-ROLE #!trydef REGISTRAR-ROLE #!trydef PRESENCE-ROLE +###!trydef MESSAGE-ROLE ## Disabled Roles - remove all but the last '#' to enable # # #!trydef TRAFFIC-FILTER-ROLE diff --git a/kamailio/message-role.cfg b/kamailio/message-role.cfg new file mode 100644 index 0000000..a8d97ee --- /dev/null +++ b/kamailio/message-role.cfg @@ -0,0 +1,58 @@ +modparam("htable", "htable", "msg=>size=32;autoexpire=60;") + + +event_route[kazoo:consumer-event-message-route] +{ + $var(uri_username) = ""; + kazoo_json($kzE, "Endpoints[0].To-Username", "$var(uri_username)"); + $var(x) = $(kzE{kz.json,Endpoints[0].To-Username}); + xlog("L_INFO", "received message route for $(kzE{kz.json,Endpoints[0].To-DID})"); + if( $var(uri_username) != "" ) { + $var(from_uri) = "sip:" + $(kzE{kz.json,Caller-ID-Number}) + "@" + $(kzE{kz.json,Endpoints[0].To-Realm}); + $var(to_uri) = "sip:" + $(kzE{kz.json,Endpoints[0].To-Username}) + "@" + $(kzE{kz.json,Endpoints[0].To-Realm}); + } else { + $var(from_uri) = "sip:" + $(kzE{kz.json,Caller-ID-Number}) + $(kzE{kz.json,Endpoints[0].To-Realm}); + $var(to_uri) = $(kzE{kz.json,Endpoints[0].Route}); + } + $sht(msg=>$(kzE{kz.json,Call-ID})) = $kzE; + $uac_req(method)="MESSAGE"; + $uac_req(body)= $(kzE{kz.json,Body}); + $uac_req(hdrs)="Content-Type: text/plain\r\n"; + $uac_req(turi) = $var(to_uri); + $uac_req(ruri) = $var(to_uri); + $uac_req(furi) = $var(from_uri); + $uac_req(ouri) = "sip:MY_IP_ADDRESS:5060"; + $uac_req(callid) = $(kzE{kz.json,Call-ID}); + xlog("L_INFO", "sending message from $var(from_uri) to $var(to_uri) "); + uac_req_send(); + +} + +route[MESSAGE_REPLY] +{ + if( $(sht(msg=>$ci)) == $null) { + exit(); + } + + if($T_reply_code != 200 && $T_reply_code != 202) { + $var(Result) = "Failure"; + } else { + $var(Result) = "Success"; + } + + + + $var(Payload) = '{ "Event-Category" : "message", "Event-Name" : "delivery", "Call-ID" : "' + $(sht(msg=>$ci){kz.json,Call-ID}) + '", "Message-ID" : "' + $(sht(msg=>$ci){kz.json,Message-ID}) +'" , "Delivery-Result-Code" : "sip:" + $T_reply_code + '" , "Msg-ID" : "' + $(sht(msg=>$ci){kz.json,Msg-ID}) + '" , "Status" : "' + $var(Result) + '"}'; + + $var(RoutingKey) = $(sht(msg=>$ci){kz.json,Server-ID}); + $var(exchange) = "targeted"; + if($var(RoutingKey) == "") { + $var(exchange) = "sms"; + $var(RoutingKey) = "message.delivery." + $(sht(msg=>$ci){kz.json,Call-ID}{kz.encode}); + } + xlog("L_INFO", "sending delivery message for $ci"); + kazoo_publish($var(exchange), $var(RoutingKey), $var(Payload)); +} + + +# vim: tabstop=4 softtabstop=4 shiftwidth=4 expandtab From 8f241272c84250ec65fd69d3c23df7743db128b1 Mon Sep 17 00:00:00 2001 From: karl anderson Date: Wed, 4 Feb 2015 12:07:04 -0800 Subject: [PATCH 08/33] KAZOO-3265: formating tweaks --- kamailio/default.cfg | 79 ++++++++++++++++++--------------------- kamailio/local.cfg | 2 +- kamailio/message-role.cfg | 13 +++---- 3 files changed, 43 insertions(+), 51 deletions(-) diff --git a/kamailio/default.cfg b/kamailio/default.cfg index 9a9bd90..1d939eb 100644 --- a/kamailio/default.cfg +++ b/kamailio/default.cfg @@ -325,44 +325,39 @@ route[HANDLE_NOTIFY] route[HANDLE_MESSAGE] { - #!ifdef MESSAGE-ROLE - - if (is_method("MESSAGE")) { - xlog("L_INFO", "$ci|MESSAGE from $fu to $tu"); - if (isflagset(FLAG_INTERNALLY_SOURCED) || src_ip == myself) { - xlog("L_INFO", "$ci| routing MESSAGE to external from $fu to $tu"); - route(INTERNAL_TO_EXTERNAL_RELAY); - #!ifdef TRAFFIC-FILTER-ROLE - } else if (!isflagset(FLAG_TRUSTED_SOURCE) - && $rd =~ "[0-9]{1,3}\.[0-9]{1,3}.[0-9]{1,3}\.[0-9]{1,3}") { - xlog("L_WARN", "$ci|end|dropping MESSAGE request with IP domain"); - #!endif - } else { - xlog("L_WARN", "$ci|end|MESSAGE $(hdr(Content-Type))"); - if( $hdr(Content-Type) == "application/im-iscomposing+xml" ) { + #!ifdef MESSAGE-ROLE + if (is_method("MESSAGE")) { + xlog("L_INFO", "$ci|MESSAGE from $fu to $tu"); + if (isflagset(FLAG_INTERNALLY_SOURCED) || src_ip == myself) { + xlog("L_INFO", "$ci| routing MESSAGE to external from $fu to $tu"); + route(INTERNAL_TO_EXTERNAL_RELAY); + #!ifdef TRAFFIC-FILTER-ROLE + } else if (!isflagset(FLAG_TRUSTED_SOURCE) + && $rd =~ "[0-9]{1,3}\.[0-9]{1,3}.[0-9]{1,3}\.[0-9]{1,3}") { + xlog("L_WARN", "$ci|end|dropping MESSAGE request with IP domain"); + #!endif + } else { + xlog("L_WARN", "$ci|end|MESSAGE $(hdr(Content-Type))"); + if( $hdr(Content-Type) == "application/im-iscomposing+xml" ) { xlog("L_WARN", "$ci|end|dropping MESSAGE application/im-iscomposing+xml"); sl_send_reply("200", "OK"); - } else { + } else { route(DISPATCHER_FIND_ROUTES); route(EXTERNAL_TO_INTERNAL_RELAY); - } } - exit(); } - - #!else - - if (is_method("MESSAGE")) { - if (isflagset(FLAG_INTERNALLY_SOURCED)) { - route(INTERNAL_TO_EXTERNAL_RELAY); - } else { - sl_send_reply("202", "delivered to /dev/null"); - exit; - } + exit(); + } + #!else + if (is_method("MESSAGE")) { + if (isflagset(FLAG_INTERNALLY_SOURCED)) { + route(INTERNAL_TO_EXTERNAL_RELAY); + } else { + sl_send_reply("202", "delivered to /dev/null"); + exit; } - - #!endif - + } + #!endif } route[HANDLE_IN_DIALOG_REQUESTS] @@ -542,9 +537,9 @@ onreply_route[INTERNAL_REPLY] #!endif if (is_method("INVITE") && - !isflagset(FLAG_SESSION_PROGRESS) && - t_check_status("(180)|(183)|(200)") - ) { + !isflagset(FLAG_SESSION_PROGRESS) && + t_check_status("(180)|(183)|(200)") + ) { if ($avp(AVP_REDIRECT_KEY) != $null && $sht(redirects=>$avp(AVP_REDIRECT_KEY)) != $null ) { @@ -576,8 +571,8 @@ failure_route[INTERNAL_FAULT] # Handle redirects if (t_check_status("302")) { - $var(redirect) = @from.uri.user + "@" + @from.uri.host + "->" - + $T_rpl($(ct{tobody.user})) + "@" + $T_rpl($(ct{tobody.host})); + $var(redirect) = @from.uri.user + "@" + @from.uri.host + "->" + + $T_rpl($(ct{tobody.user})) + "@" + $T_rpl($(ct{tobody.host})); if($T_rpl($hdr(X-Redirect-Server)) != $null) { $sht(redirects=>$var(redirect)) = $T_rpl($hdr(X-Redirect-Server)); xlog("L_INFO", "$ci|log|stored redirect mapping $var(redirect) to $T_rpl($hdr(X-Redirect-Server))"); @@ -596,7 +591,7 @@ failure_route[INTERNAL_FAULT] if (t_check_status("6[0-9][0-9]") && !t_check_status("600|603|604|606")) { $var(new_code) = "4" + $(T_reply_code{s.substr,1,0}); xlog("L_INFO", "$ci|log|sending 6XX reply as $var(new_code) $var(reply_reason)"); - t_reply("$(var(new_code){s.int})", "$var(reply_reason)"); + t_reply("$(var(new_code){s.int})", "$var(reply_reason)"); # if the failure case was something that we should recover # from then try to find a new media server @@ -637,13 +632,13 @@ event_route[kazoo:mod-init] { #!ifdef PRESENCE-ROLE -### use this simple form of binding a listener +### use this simple form of binding a listener ### kazoo_subscribe("dialoginfo", "direct", "BLF-QUEUE-MY_HOSTNAME", "BLF-MY_HOSTNAME"); ### ### or unleash the power of rabbit to kazoo-blf ### -### 'no_ack' : 1 => needs ack, -### 'wait_for_consumer_ack' +### 'no_ack' : 1 => needs ack, +### 'wait_for_consumer_ack' ### : 1 => when it receives, it processses on the AMQP Worker ad after that it confirms ### : 0 => when it receives, it acks then processes in the AMQP Worker ### only works if no_ack : 0 @@ -652,13 +647,13 @@ event_route[kazoo:mod-init] ### pattern : ^BLF ### definition : ha-mode: all ### -### +### $var(payload) = "{ 'exchange' : 'dialoginfo' , 'type' : 'direct', 'queue' : 'BLF-QUEUE-MY_HOSTNAME', 'routing' : 'BLF-MY_HOSTNAME', 'auto_delete' : 0, 'durable' : 1, 'no_ack' : 0, 'wait_for_consumer_ack' : 1 }"; xlog("L_INFO","SUBSCRIBE $var(payload)"); kazoo_subscribe("$var(payload)"); #!endif - + } event_route[kazoo:consumer-event] diff --git a/kamailio/local.cfg b/kamailio/local.cfg index f06e814..e6534ce 100644 --- a/kamailio/local.cfg +++ b/kamailio/local.cfg @@ -11,13 +11,13 @@ debug = L_INFO #!trydef NAT-TRAVERSAL-ROLE #!trydef REGISTRAR-ROLE #!trydef PRESENCE-ROLE -###!trydef MESSAGE-ROLE ## Disabled Roles - remove all but the last '#' to enable # # #!trydef TRAFFIC-FILTER-ROLE # # #!trydef WEBSOCKETS-ROLE # # #!trydef TLS-ROLE # # #!trydef ANTIFLOOD-ROLE +# # #!trydef MESSAGE-ROLE ################################################################################ ## SERVER INFORMATION diff --git a/kamailio/message-role.cfg b/kamailio/message-role.cfg index a8d97ee..72e5e1c 100644 --- a/kamailio/message-role.cfg +++ b/kamailio/message-role.cfg @@ -25,7 +25,6 @@ event_route[kazoo:consumer-event-message-route] $uac_req(callid) = $(kzE{kz.json,Call-ID}); xlog("L_INFO", "sending message from $var(from_uri) to $var(to_uri) "); uac_req_send(); - } route[MESSAGE_REPLY] @@ -35,21 +34,19 @@ route[MESSAGE_REPLY] } if($T_reply_code != 200 && $T_reply_code != 202) { - $var(Result) = "Failure"; + $var(Result) = "Failure"; } else { - $var(Result) = "Success"; + $var(Result) = "Success"; } - - $var(Payload) = '{ "Event-Category" : "message", "Event-Name" : "delivery", "Call-ID" : "' + $(sht(msg=>$ci){kz.json,Call-ID}) + '", "Message-ID" : "' + $(sht(msg=>$ci){kz.json,Message-ID}) +'" , "Delivery-Result-Code" : "sip:" + $T_reply_code + '" , "Msg-ID" : "' + $(sht(msg=>$ci){kz.json,Msg-ID}) + '" , "Status" : "' + $var(Result) + '"}'; $var(RoutingKey) = $(sht(msg=>$ci){kz.json,Server-ID}); $var(exchange) = "targeted"; if($var(RoutingKey) == "") { - $var(exchange) = "sms"; - $var(RoutingKey) = "message.delivery." + $(sht(msg=>$ci){kz.json,Call-ID}{kz.encode}); - } + $var(exchange) = "sms"; + $var(RoutingKey) = "message.delivery." + $(sht(msg=>$ci){kz.json,Call-ID}{kz.encode}); + } xlog("L_INFO", "sending delivery message for $ci"); kazoo_publish($var(exchange), $var(RoutingKey), $var(Payload)); } From cf1a6f073c0dd442645d511ee63f392b41d05e1b Mon Sep 17 00:00:00 2001 From: lazedo Date: Thu, 5 Feb 2015 01:41:25 +0000 Subject: [PATCH 09/33] message-role amqp init --- kamailio/default.cfg | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/kamailio/default.cfg b/kamailio/default.cfg index 1d939eb..978f4d9 100644 --- a/kamailio/default.cfg +++ b/kamailio/default.cfg @@ -648,8 +648,16 @@ event_route[kazoo:mod-init] ### definition : ha-mode: all ### ### - $var(payload) = "{ 'exchange' : 'dialoginfo' , 'type' : 'direct', 'queue' : 'BLF-QUEUE-MY_HOSTNAME', 'routing' : 'BLF-MY_HOSTNAME', 'auto_delete' : 0, 'durable' : 1, 'no_ack' : 0, 'wait_for_consumer_ack' : 1 }"; - xlog("L_INFO","SUBSCRIBE $var(payload)"); + + $var(payload) = '{ "exchange" : "dialoginfo" , "type" : "direct", "queue" : "BLF-QUEUE-MY_HOSTNAME", "routing" : "BLF-MY_HOSTNAME", "auto_delete" : 0, "durable" : 1, "no_ack" : 0, "wait_for_consumer_ack" : 1 }'; + kazoo_subscribe("$var(payload)"); + + #!endif + + #!ifdef MESSAGE-ROLE + + $var(key) = "kamailio@MY_HOSTNAME"; + $var(payload) = '{ "exchange" : "sms" , "type" : "topic", "queue" : "MSG-QUEUE-MY_HOSTNAME", "routing" : "message.route.' + $(var(key){kz.encode}) + '.*", "auto_delete" : 1, "durable" : 0, "no_ack" : 0, "wait_for_consumer_ack" : 1 }'; kazoo_subscribe("$var(payload)"); #!endif From 6d89f947cb636598becd353dae08e2e26b78498e Mon Sep 17 00:00:00 2001 From: lazedo Date: Thu, 5 Feb 2015 01:43:58 +0000 Subject: [PATCH 10/33] flush registrar cache --- kamailio/registrar-role.cfg | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/kamailio/registrar-role.cfg b/kamailio/registrar-role.cfg index e43cf08..0dab254 100644 --- a/kamailio/registrar-role.cfg +++ b/kamailio/registrar-role.cfg @@ -154,4 +154,15 @@ route[ATTEMPT_AUTHORIZATION] exit; } +## kazoo event route , {"directory", "reg_flush") => reg-flush by kamailio limitations +## when a Event-Category or Event-Name has a underscore (_) we need to declare it with a dash (-) +event_route[kazoo:consumer-event-directory-reg-flush] +{ + $var(user) = $(kzE{kz.json,Username}) + "@" + $(kzE{kz.json,Realm}); + if ($sht(auth_cache=>$var(user)) != $null) { + xlog("L_INFO", "log|removing SIP credentials cache for $var(user)"); + $sht(auth_cache=>$var(user)) = $null; + } +} + # vim: tabstop=4 softtabstop=4 shiftwidth=4 expandtab From 7c331b97a7e06256cb062ee086d85570ddd7a835 Mon Sep 17 00:00:00 2001 From: lazedo Date: Thu, 5 Feb 2015 01:46:07 +0000 Subject: [PATCH 11/33] init amqp for registrar cache flush --- kamailio/default.cfg | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/kamailio/default.cfg b/kamailio/default.cfg index 978f4d9..6c6249c 100644 --- a/kamailio/default.cfg +++ b/kamailio/default.cfg @@ -662,6 +662,13 @@ event_route[kazoo:mod-init] #!endif + #!ifdef REGISTRAR-ROLE + + $var(payload) = "{ 'exchange' : 'callmgr' , 'type' : 'topic', 'queue' : 'MSG-FLUSH-MY_HOSTNAME', 'routing' : 'registration.flush.*', 'auto_delete' : 1, 'durable' : 0, 'no_ack' : 1, 'wait_for_consumer_ack' : 0 }"; + kazoo_subscribe("$var(payload)"); + + #!endif + } event_route[kazoo:consumer-event] From c3db7e530cdbb0564e9ba2dd730cce22de2cd642 Mon Sep 17 00:00:00 2001 From: karl anderson Date: Tue, 10 Feb 2015 20:27:28 -0800 Subject: [PATCH 12/33] KAZOO-3320 reject subscribe requests if there is nothing to subscribe to (or from) --- kamailio/presence-role.cfg | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/kamailio/presence-role.cfg b/kamailio/presence-role.cfg index be4a015..01c0f79 100644 --- a/kamailio/presence-role.cfg +++ b/kamailio/presence-role.cfg @@ -48,6 +48,20 @@ route[HANDLE_SUBSCRIBE] exit; } + if ($tU == $null) { + xlog("L_INFO", "$ci|stop|ignoring subscribe with empty TO username from a $ua"); + sl_send_reply(400, "Missing TO username"); + t_release(); + exit; + } + + if ($fU == $null) { + xlog("L_INFO", "$ci|stop|ignoring subscribe with empty FROM username from a $ua"); + sl_send_reply(400, "Missing FROM username"); + t_release(); + exit; + } + handle_subscribe(); ##RabbitMQ From 87e76b8542672b8a957640588f260ac520b9acb0 Mon Sep 17 00:00:00 2001 From: lazedo Date: Fri, 13 Feb 2015 01:32:02 +0000 Subject: [PATCH 13/33] presence-role fix fo mixed case uri (cherry picked from commit eb0a4e766f4adcf2b666ae8657cc81813e70cc24) Conflicts: kamailio/presence-role.cfg (cherry picked from commit 0e4d783b690cc8218b54472da76010a1cb3b7e43) --- kamailio/presence-role.cfg | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/kamailio/presence-role.cfg b/kamailio/presence-role.cfg index 01c0f79..1e3fdcf 100644 --- a/kamailio/presence-role.cfg +++ b/kamailio/presence-role.cfg @@ -62,6 +62,8 @@ route[HANDLE_SUBSCRIBE] exit; } + $ru = $(ru{s.tolower}); + handle_subscribe(); ##RabbitMQ @@ -71,7 +73,7 @@ route[HANDLE_SUBSCRIBE] $var(fs_contact) = $var(fs_contact) + ";" + $(ct{tobody.params}); } - $var(amqp_payload_request) = "{'Event-Category' : 'presence', 'Event-Name' : 'subscription', 'Event-Package' : '" + $hdr(event) + "', 'Expires' : " + $hdr(Expires) + ", 'Queue' : 'BLF-MY_HOSTNAME', 'Server-ID' : 'BLF-MY_HOSTNAME' ,'Contact' : '" + $var(fs_contact) + "', 'Call-ID' : '" + $ci + "', 'From' : '" + $fu +"', 'User' : '" + $tu + "', 'User-Agent' : '" + $ua + "' }"; + $var(amqp_payload_request) = "{'Event-Category' : 'presence', 'Event-Name' : 'subscription', 'Event-Package' : '" + $hdr(event) + "', 'Expires' : " + $hdr(Expires) + ", 'Queue' : 'BLF-MY_HOSTNAME', 'Server-ID' : 'BLF-MY_HOSTNAME' ,'Contact' : '" + $var(fs_contact) + "', 'Call-ID' : '" + $ci + "', 'From' : '" + $(fu{s.tolower}) +"', 'User' : '" + $(tu{s.tolower}) + "', 'User-Agent' : '" + $ua + "' }"; kazoo_publish("dialoginfo_subs", "dialoginfo_subs", $var(amqp_payload_request)); From 9e740783a7c605c648ad90b7b8040893f1de5776 Mon Sep 17 00:00:00 2001 From: lazedo Date: Fri, 13 Feb 2015 02:41:59 +0000 Subject: [PATCH 14/33] fix mixed case in notifications ensure notification from omnipresence is treated as lowercase since we forced the presentity to lowercase (cherry picked from commit 18475a4a40b725f2dbd8187493a8ae3c4990dfc0) --- kamailio/presence-role.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kamailio/presence-role.cfg b/kamailio/presence-role.cfg index 1e3fdcf..957d02c 100644 --- a/kamailio/presence-role.cfg +++ b/kamailio/presence-role.cfg @@ -106,7 +106,7 @@ event_route[kazoo:consumer-event-presence-update] xlog("L_INFO", "payload $kzE"); $sht(p=>$(kzE{kz.json,Call-ID})) = $(kzE{kz.json,State}); kazoo_pua_publish($kzE); - pres_refresh_watchers("$(kzE{kz.json,From})", "$(kzE{kz.json,Event-Package})", 1); + pres_refresh_watchers("$(kzE{kz.json,From}{s.tolower})", "$(kzE{kz.json,Event-Package})", 1); } else { xlog("L_INFO", "received duplicate $(kzE{kz.json,Event-Package}) update for $(kzE{kz.json,From})"); xlog("L_INFO", "payload $kzE"); From 6c24975c218a9de911c74ec7e97922f97ca34a13 Mon Sep 17 00:00:00 2001 From: karl anderson Date: Fri, 13 Feb 2015 14:37:03 -0500 Subject: [PATCH 15/33] merged the various changes for Kamailio 4.2 --- kamailio/dbtext/active_watchers | 0 kamailio/dbtext/location | 0 kamailio/dbtext/location_attrs | 1 + kamailio/default.cfg | 42 +++++++++++++++++++++++---------- kamailio/dispatcher-role.cfg | 10 ++++---- kamailio/message-role.cfg | 2 +- kamailio/presence-role.cfg | 29 +++++++---------------- kamailio/registrar-role.cfg | 9 ++++++- 8 files changed, 52 insertions(+), 41 deletions(-) mode change 100755 => 100644 kamailio/dbtext/active_watchers mode change 100755 => 100644 kamailio/dbtext/location create mode 100644 kamailio/dbtext/location_attrs diff --git a/kamailio/dbtext/active_watchers b/kamailio/dbtext/active_watchers old mode 100755 new mode 100644 diff --git a/kamailio/dbtext/location b/kamailio/dbtext/location old mode 100755 new mode 100644 diff --git a/kamailio/dbtext/location_attrs b/kamailio/dbtext/location_attrs new file mode 100644 index 0000000..4214eb6 --- /dev/null +++ b/kamailio/dbtext/location_attrs @@ -0,0 +1 @@ +id(int,auto) ruid(string) username(string) domain(string,null) aname(string) atype(int) avalue(string) last_modified(int) diff --git a/kamailio/default.cfg b/kamailio/default.cfg index 6c6249c..c9de3e3 100644 --- a/kamailio/default.cfg +++ b/kamailio/default.cfg @@ -139,6 +139,9 @@ loadmodule "xlog.so" loadmodule "mi_fifo.so" modparam("mi_fifo", "fifo_name", "/tmp/kamailio_fifo") +######## UAC ######## +loadmodule "uac.so" + ######## UAC Redirection module ######## loadmodule "uac_redirect.so" @@ -147,22 +150,22 @@ loadmodule "db_text.so" modparam("db_text", "db_mode", 1) ####### Kazoo Integration module ########## -loadmodule "db_kazoo.so" -modparam("db_kazoo", "node_hostname", "MY_HOSTNAME") -modparam("db_kazoo", "amqp_connection", "MY_AMQP_URL") +loadmodule "kazoo.so" +modparam("kazoo", "node_hostname", "MY_HOSTNAME") +modparam("kazoo", "amqp_connection", "MY_AMQP_URL") #!ifdef MY_AMQP_URL_SECONDARY -modparam("db_kazoo", "amqp_connection", "MY_AMQP_URL_SECONDARY") +modparam("kazoo", "amqp_connection", "MY_AMQP_URL_SECONDARY") #!endif #!ifdef MY_AMQP_URL_TERTIARY -modparam("db_kazoo", "amqp_connection", "MY_AMQP_URL_TERTIARY") +modparam("kazoo", "amqp_connection", "MY_AMQP_URL_TERTIARY") #!endif #!ifdef MY_AMQP_MAX_CHANNELS -modparam("db_kazoo", "amqp_max_channels", MY_AMQP_MAX_CHANNELS) +modparam("kazoo", "amqp_max_channels", MY_AMQP_MAX_CHANNELS) #!else -modparam("db_kazoo", "amqp_max_channels", 100) +modparam("kazoo", "amqp_max_channels", 100) #!endif -modparam("db_kazoo", "amqp_internal_loop_count", 1); -modparam("db_kazoo", "amqp_consumer_loop_count", 4); +modparam("kazoo", "amqp_internal_loop_count", 1); +modparam("kazoo", "amqp_consumer_loop_count", 4); ####### Role Configurations ########## #!ifdef DISPATCHER-ROLE @@ -205,7 +208,7 @@ modparam("permissions", "db_mode", 1) route { # log the basic info regarding this call - xlog("L_INFO", "$ci|start|recieved $oP request $rm $ou"); + xlog("L_INFO", "$ci|start|recieved $pr request $rm $ou"); xlog("L_INFO", "$ci|log|source $si:$sp"); xlog("L_INFO", "$ci|log|from $fu"); xlog("L_INFO", "$ci|log|to $tu"); @@ -328,6 +331,7 @@ route[HANDLE_MESSAGE] #!ifdef MESSAGE-ROLE if (is_method("MESSAGE")) { xlog("L_INFO", "$ci|MESSAGE from $fu to $tu"); + t_on_reply("MESSAGE_REPLY"); if (isflagset(FLAG_INTERNALLY_SOURCED) || src_ip == myself) { xlog("L_INFO", "$ci| routing MESSAGE to external from $fu to $tu"); route(INTERNAL_TO_EXTERNAL_RELAY); @@ -352,14 +356,27 @@ route[HANDLE_MESSAGE] if (is_method("MESSAGE")) { if (isflagset(FLAG_INTERNALLY_SOURCED)) { route(INTERNAL_TO_EXTERNAL_RELAY); + #!ifdef TRAFFIC-FILTER-ROLE + } else if (!isflagset(FLAG_TRUSTED_SOURCE) + && $rd =~ "[0-9]{1,3}\.[0-9]{1,3}.[0-9]{1,3}\.[0-9]{1,3}") { + xlog("L_WARN", "$ci|end|dropping MESSAGE request with IP domain"); + #!endif } else { - sl_send_reply("202", "delivered to /dev/null"); - exit; + xlog("L_WARN", "$ci|end|MESSAGE $(hdr(Content-Type))"); + if( $hdr(Content-Type) == "application/im-iscomposing+xml" ) { + xlog("L_WARN", "$ci|end|dropping MESSAGE application/im-iscomposing+xml"); + sl_send_reply("200", "OK"); + } else { + route(DISPATCHER_FIND_ROUTES); + route(EXTERNAL_TO_INTERNAL_RELAY); + } } + exit(); } #!endif } + route[HANDLE_IN_DIALOG_REQUESTS] { if (has_totag()) { @@ -668,7 +685,6 @@ event_route[kazoo:mod-init] kazoo_subscribe("$var(payload)"); #!endif - } event_route[kazoo:consumer-event] diff --git a/kamailio/dispatcher-role.cfg b/kamailio/dispatcher-role.cfg index 5782199..d5e99b2 100644 --- a/kamailio/dispatcher-role.cfg +++ b/kamailio/dispatcher-role.cfg @@ -32,11 +32,11 @@ modparam("dispatcher", "ds_ping_from", "sip:sipcheck@MY_IP_ADDRESS") ####### Dispatcher Logic ######## route[DISPATCHER_CLASSIFY_SOURCE] { - if (ds_is_from_list("1", "1") || - ds_is_from_list("2", "1") || - ds_is_from_list("3", "1") || - ds_is_from_list("10", "1") || - ds_is_from_list("20", "1")) { + if (ds_is_from_list(1, 3) || + ds_is_from_list(2, 3) || + ds_is_from_list(3, 3) || + ds_is_from_list(10, 3) || + ds_is_from_list(20, 3)) { xlog("L_INFO", "$ci|log|originated from internal sources"); setflag(FLAG_INTERNALLY_SOURCED); diff --git a/kamailio/message-role.cfg b/kamailio/message-role.cfg index 72e5e1c..afa8f6a 100644 --- a/kamailio/message-role.cfg +++ b/kamailio/message-role.cfg @@ -27,7 +27,7 @@ event_route[kazoo:consumer-event-message-route] uac_req_send(); } -route[MESSAGE_REPLY] +onreply_route[MESSAGE_REPLY] { if( $(sht(msg=>$ci)) == $null) { exit(); diff --git a/kamailio/presence-role.cfg b/kamailio/presence-role.cfg index 957d02c..74817df 100644 --- a/kamailio/presence-role.cfg +++ b/kamailio/presence-role.cfg @@ -6,34 +6,21 @@ loadmodule "presence_dialoginfo.so" loadmodule "presence_mwi.so" loadmodule "presence_xml.so" +modparam("presence_dialoginfo", "force_dummy_dialog", 1) +modparam("presence_xml", "force_active", 1) + modparam("presence", "subs_db_mode", 1) modparam("presence", "expires_offset", 60) -modparam("presence", "send_fast_notify", 0) +modparam("presence", "send_fast_notify", 1) modparam("presence", "clean_period", 30) modparam("presence", "publ_cache", 0) -modparam("presence", "min_expires", 0) +modparam("presence", "min_expires_action", 2) +modparam("presence", "min_expires", 300) modparam("presence", "max_expires", 3600) - -## use this -#modparam("presence", "db_url", "MY_AMQP_URL/dialoginfo") - -## or this modparam("presence", "db_url", "text:///etc/kazoo/kamailio/dbtext") -modparam("db_kazoo", "db_url", "text:///etc/kazoo/kamailio/dbtext") -modparam("db_kazoo", "pua_mode", 1) - - -modparam("presence_xml", "force_active", 1) - - -######## Presence User Agent module ######## -#loadmodule "pua.so" -#modparam("pua", "db_mode", 0) -#modparam("pua", "db_url", "text:///etc/kazoo/kamailio/dbtext") -#modparam("pua", "update_period", 6) -#modparam("pua", "min_expires", 300) -#modparam("pua", "outbound_proxy", "sip:MY_IP_ADDRESS") +modparam("kazoo", "db_url", "text:///etc/kazoo/kamailio/dbtext") +modparam("kazoo", "pua_mode", 1) ####### Presence Logic ######## route[HANDLE_SUBSCRIBE] diff --git a/kamailio/registrar-role.cfg b/kamailio/registrar-role.cfg index 0dab254..769930a 100644 --- a/kamailio/registrar-role.cfg +++ b/kamailio/registrar-role.cfg @@ -11,10 +11,17 @@ loadmodule "auth.so" ####### User Location Implementation module ########## loadmodule "usrloc.so" -modparam("usrloc", "db_mode", 0) modparam("usrloc", "db_update_as_insert", 1) modparam("usrloc", "use_domain", 1) modparam("usrloc", "nat_bflag", FLB_NATB) +modparam("usrloc", "db_url", "text:///etc/kazoo/kamailio/dbtext") +modparam("usrloc", "db_mode", 1) +modparam("usrloc", "handle_lost_tcp", 1) +modparam("usrloc", "xavp_contact", "ulattrs") +modparam("usrloc", "db_check_update", 1) +modparam("usrloc", "timer_interval", 30) +modparam("usrloc", "timer_procs", 1) + ######## NAT Traversal module - signaling functions ######## #!ifdef NAT-TRAVERSAL-ROLE From 0f1fcc23cb502038b5e37c284c300431c83400e6 Mon Sep 17 00:00:00 2001 From: karl anderson Date: Fri, 13 Feb 2015 14:43:10 -0800 Subject: [PATCH 16/33] KAZOO-3288: set the default moh on the default conference profile --- freeswitch/autoload_configs/conference.conf.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/freeswitch/autoload_configs/conference.conf.xml b/freeswitch/autoload_configs/conference.conf.xml index c1831ae..379cfcb 100644 --- a/freeswitch/autoload_configs/conference.conf.xml +++ b/freeswitch/autoload_configs/conference.conf.xml @@ -26,6 +26,7 @@ + From 760235501bffcf22421ed485e85594499889c701 Mon Sep 17 00:00:00 2001 From: karl anderson Date: Tue, 17 Feb 2015 19:25:41 -0800 Subject: [PATCH 17/33] KAZOO-3336: execute nat test and correct in HANDLE_NOTIFY, also updated the db_insert parameter for 4.2 --- kamailio/default.cfg | 14 +++++++++++++- kamailio/registrar-role.cfg | 2 +- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/kamailio/default.cfg b/kamailio/default.cfg index c9de3e3..37e6b92 100644 --- a/kamailio/default.cfg +++ b/kamailio/default.cfg @@ -320,7 +320,19 @@ route[HANDLE_NOTIFY] route(FILTER_REQUEST_DOMAIN); #!endif - sl_send_reply("200", "Rawr!!"); + #!ifdef WEBSOCKETS-ROLE + route(NAT_WEBSOCKETS_CORRECT); + #!endif + + #!ifdef NAT-TRAVERSAL-ROLE + route(NAT_TEST_AND_CORRECT); + #!endif + + if($hdr(Event) == "keep-alive") { + sl_send_reply("405", "Stay Alive / Method Not Allowed"); + } else { + sl_send_reply("200", "Rawr!!"); + } } exit; } diff --git a/kamailio/registrar-role.cfg b/kamailio/registrar-role.cfg index 769930a..f79092f 100644 --- a/kamailio/registrar-role.cfg +++ b/kamailio/registrar-role.cfg @@ -11,7 +11,7 @@ loadmodule "auth.so" ####### User Location Implementation module ########## loadmodule "usrloc.so" -modparam("usrloc", "db_update_as_insert", 1) +modparam("usrloc", "db_update_as_insert", 0) modparam("usrloc", "use_domain", 1) modparam("usrloc", "nat_bflag", FLB_NATB) modparam("usrloc", "db_url", "text:///etc/kazoo/kamailio/dbtext") From c2aabcab6fd48284ca741cff68bdc5a0c835ebd8 Mon Sep 17 00:00:00 2001 From: karl anderson Date: Mon, 23 Feb 2015 15:50:53 -0800 Subject: [PATCH 18/33] KAZOO-3357: if handle_subscribe failes dont publish a AMQP message --- kamailio/default.cfg | 1 + kamailio/presence-role.cfg | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/kamailio/default.cfg b/kamailio/default.cfg index 37e6b92..3e2a13e 100644 --- a/kamailio/default.cfg +++ b/kamailio/default.cfg @@ -148,6 +148,7 @@ loadmodule "uac_redirect.so" ####### DB Text module ########## loadmodule "db_text.so" modparam("db_text", "db_mode", 1) +modparam("db_text", "emptystring", 1) ####### Kazoo Integration module ########## loadmodule "kazoo.so" diff --git a/kamailio/presence-role.cfg b/kamailio/presence-role.cfg index 74817df..0afdd2e 100644 --- a/kamailio/presence-role.cfg +++ b/kamailio/presence-role.cfg @@ -9,7 +9,7 @@ loadmodule "presence_xml.so" modparam("presence_dialoginfo", "force_dummy_dialog", 1) modparam("presence_xml", "force_active", 1) -modparam("presence", "subs_db_mode", 1) +modparam("presence", "subs_db_mode", 3) modparam("presence", "expires_offset", 60) modparam("presence", "send_fast_notify", 1) modparam("presence", "clean_period", 30) @@ -17,6 +17,7 @@ modparam("presence", "publ_cache", 0) modparam("presence", "min_expires_action", 2) modparam("presence", "min_expires", 300) modparam("presence", "max_expires", 3600) +modparam("presence", "sip_uri_match", 1) modparam("presence", "db_url", "text:///etc/kazoo/kamailio/dbtext") modparam("kazoo", "db_url", "text:///etc/kazoo/kamailio/dbtext") @@ -51,7 +52,11 @@ route[HANDLE_SUBSCRIBE] $ru = $(ru{s.tolower}); - handle_subscribe(); + if (!handle_subscribe()) { + xlog("L_INFO", "$ci|stop|unsupported subsribe"); + t_release(); + exit; + } ##RabbitMQ $var(fs_path) = "%3C" + $rz + "%3A" + $Ri + "%3A" + $Rp + "%3Btransport=" + $proto + "%3Blr%3Breceived=" + $si+":"+$sp+"%3E"; From 736be1329e0d014cc704afef6bc0b71eb8731af5 Mon Sep 17 00:00:00 2001 From: karl anderson Date: Mon, 23 Feb 2015 18:40:43 -0800 Subject: [PATCH 19/33] KAZOO-3343: there is not need to keep the locality in two places and we cant use NAT pings with dbtext --- kamailio/default.cfg | 22 ++++++++++++++-------- kamailio/registrar-role.cfg | 2 +- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/kamailio/default.cfg b/kamailio/default.cfg index 3e2a13e..139e5a7 100644 --- a/kamailio/default.cfg +++ b/kamailio/default.cfg @@ -208,14 +208,14 @@ modparam("permissions", "db_mode", 1) ####### Routing Logic ######## route { + route(SANITY_CHECK); + # log the basic info regarding this call xlog("L_INFO", "$ci|start|recieved $pr request $rm $ou"); xlog("L_INFO", "$ci|log|source $si:$sp"); xlog("L_INFO", "$ci|log|from $fu"); xlog("L_INFO", "$ci|log|to $tu"); - route(SANITY_CHECK); - route(CLASSIFY_SOURCE); #!ifdef ANTIFLOOD-ROLE @@ -264,21 +264,21 @@ route route[SANITY_CHECK] { - if (!mf_process_maxfwd_header("10")) { - xlog("L_WARN", "$ci|end|too much hops, not enough barley"); - send_reply("483", "Too Many Hops"); + if (!sanity_check()) { + xlog("L_WARN", "$ci|end|message from $si:$sp is insane"); exit; } - if (!sanity_check()) { - xlog("L_WARN", "$ci|end|message is insane"); + if (!mf_process_maxfwd_header("10")) { + xlog("L_WARN", "$ci|end|too much hops, not enough barley from $si:$sp"); + send_reply("483", "Too Many Hops"); exit; } if ($ua == "friendly-scanner" || $ua == "sundayddr" || $ua =~ "sipcli" ) { - xlog("L_WARN", "$ci|end|dropping message with user-agent $ua"); + xlog("L_WARN", "$ci|end|dropping message with user-agent $ua from $si:$sp"); exit; } } @@ -315,6 +315,10 @@ route[HANDLE_NOTIFY] { if (is_method("NOTIFY")) { if (isflagset(FLAG_INTERNALLY_SOURCED)) { + if (registered("location")) { + lookup("location"); + xlog("L_INFO", "$ci|log|routing to $ruid"); + } route(INTERNAL_TO_EXTERNAL_RELAY); } else { #!ifdef TRAFFIC-FILTER-ROLE @@ -330,8 +334,10 @@ route[HANDLE_NOTIFY] #!endif if($hdr(Event) == "keep-alive") { + xlog("L_INFO", "$ci|stop|replying to keep alive"); sl_send_reply("405", "Stay Alive / Method Not Allowed"); } else { + xlog("L_INFO", "$ci|stop|consuming event $hdr(Event)"); sl_send_reply("200", "Rawr!!"); } } diff --git a/kamailio/registrar-role.cfg b/kamailio/registrar-role.cfg index f79092f..c0391e5 100644 --- a/kamailio/registrar-role.cfg +++ b/kamailio/registrar-role.cfg @@ -15,7 +15,7 @@ modparam("usrloc", "db_update_as_insert", 0) modparam("usrloc", "use_domain", 1) modparam("usrloc", "nat_bflag", FLB_NATB) modparam("usrloc", "db_url", "text:///etc/kazoo/kamailio/dbtext") -modparam("usrloc", "db_mode", 1) +modparam("usrloc", "db_mode", 0) modparam("usrloc", "handle_lost_tcp", 1) modparam("usrloc", "xavp_contact", "ulattrs") modparam("usrloc", "db_check_update", 1) From 46b903648616bd401b527fe835063c347fc6973e Mon Sep 17 00:00:00 2001 From: karl anderson Date: Mon, 23 Feb 2015 19:56:10 -0800 Subject: [PATCH 20/33] KAZOO-3343: when running sub_db_mode 3 include a waitn parameter to negate the BLF delay --- kamailio/presence-role.cfg | 2 ++ 1 file changed, 2 insertions(+) diff --git a/kamailio/presence-role.cfg b/kamailio/presence-role.cfg index 0afdd2e..f31c8ea 100644 --- a/kamailio/presence-role.cfg +++ b/kamailio/presence-role.cfg @@ -18,6 +18,8 @@ modparam("presence", "min_expires_action", 2) modparam("presence", "min_expires", 300) modparam("presence", "max_expires", 3600) modparam("presence", "sip_uri_match", 1) +modparam("presence", "waitn_time", 1) +modparam("presence", "notifier_processes", 5) modparam("presence", "db_url", "text:///etc/kazoo/kamailio/dbtext") modparam("kazoo", "db_url", "text:///etc/kazoo/kamailio/dbtext") From 783340dce603958cb790a9a30e601179bf2e7a68 Mon Sep 17 00:00:00 2001 From: karl anderson Date: Mon, 23 Feb 2015 21:11:19 -0800 Subject: [PATCH 21/33] removed fix for mixed case uri as it turned out to be a bug in dbtext and fixed upstream --- kamailio/presence-role.cfg | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/kamailio/presence-role.cfg b/kamailio/presence-role.cfg index f31c8ea..16358fe 100644 --- a/kamailio/presence-role.cfg +++ b/kamailio/presence-role.cfg @@ -52,8 +52,6 @@ route[HANDLE_SUBSCRIBE] exit; } - $ru = $(ru{s.tolower}); - if (!handle_subscribe()) { xlog("L_INFO", "$ci|stop|unsupported subsribe"); t_release(); @@ -100,7 +98,7 @@ event_route[kazoo:consumer-event-presence-update] xlog("L_INFO", "payload $kzE"); $sht(p=>$(kzE{kz.json,Call-ID})) = $(kzE{kz.json,State}); kazoo_pua_publish($kzE); - pres_refresh_watchers("$(kzE{kz.json,From}{s.tolower})", "$(kzE{kz.json,Event-Package})", 1); + pres_refresh_watchers("$(kzE{kz.json,From})", "$(kzE{kz.json,Event-Package})", 1); } else { xlog("L_INFO", "received duplicate $(kzE{kz.json,Event-Package}) update for $(kzE{kz.json,From})"); xlog("L_INFO", "payload $kzE"); From fdc4cf9252f2f416d0b4846898233c27eb8ebc98 Mon Sep 17 00:00:00 2001 From: lazedo Date: Tue, 24 Feb 2015 11:54:36 +0000 Subject: [PATCH 22/33] FIX MESSAGE-ROLE --- kamailio/default.cfg | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/kamailio/default.cfg b/kamailio/default.cfg index 139e5a7..f0c6236 100644 --- a/kamailio/default.cfg +++ b/kamailio/default.cfg @@ -375,22 +375,10 @@ route[HANDLE_MESSAGE] if (is_method("MESSAGE")) { if (isflagset(FLAG_INTERNALLY_SOURCED)) { route(INTERNAL_TO_EXTERNAL_RELAY); - #!ifdef TRAFFIC-FILTER-ROLE - } else if (!isflagset(FLAG_TRUSTED_SOURCE) - && $rd =~ "[0-9]{1,3}\.[0-9]{1,3}.[0-9]{1,3}\.[0-9]{1,3}") { - xlog("L_WARN", "$ci|end|dropping MESSAGE request with IP domain"); - #!endif - } else { - xlog("L_WARN", "$ci|end|MESSAGE $(hdr(Content-Type))"); - if( $hdr(Content-Type) == "application/im-iscomposing+xml" ) { - xlog("L_WARN", "$ci|end|dropping MESSAGE application/im-iscomposing+xml"); - sl_send_reply("200", "OK"); - } else { - route(DISPATCHER_FIND_ROUTES); - route(EXTERNAL_TO_INTERNAL_RELAY); - } + } else { + sl_send_reply("202", "delivered to /dev/null"); + exit() } - exit(); } #!endif } From a9d666dfae073641e0857c1feac2122171516510 Mon Sep 17 00:00:00 2001 From: lazedo Date: Tue, 24 Feb 2015 12:00:34 +0000 Subject: [PATCH 23/33] FIX MESSAGE-ROLE 2 message dispatcher relies on lookup to deliver the message --- kamailio/default.cfg | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/kamailio/default.cfg b/kamailio/default.cfg index f0c6236..0a35470 100644 --- a/kamailio/default.cfg +++ b/kamailio/default.cfg @@ -353,6 +353,10 @@ route[HANDLE_MESSAGE] t_on_reply("MESSAGE_REPLY"); if (isflagset(FLAG_INTERNALLY_SOURCED) || src_ip == myself) { xlog("L_INFO", "$ci| routing MESSAGE to external from $fu to $tu"); + if (registered("location")) { + lookup("location"); + xlog("L_INFO", "$ci|log|routing to $ruid"); + } route(INTERNAL_TO_EXTERNAL_RELAY); #!ifdef TRAFFIC-FILTER-ROLE } else if (!isflagset(FLAG_TRUSTED_SOURCE) From 8594c3ad51c154f7e02afeb4e5c30dc324f79c98 Mon Sep 17 00:00:00 2001 From: lazedo Date: Tue, 24 Feb 2015 19:34:53 +0000 Subject: [PATCH 24/33] KAZOO-3308 call-park redirect in kamailio --- kamailio/default.cfg | 15 +++++++++++++++ kamailio/dispatcher-role.cfg | 16 ++++++++++++++++ kamailio/local.cfg | 1 + 3 files changed, 32 insertions(+) diff --git a/kamailio/default.cfg b/kamailio/default.cfg index 0a35470..b4e78b3 100644 --- a/kamailio/default.cfg +++ b/kamailio/default.cfg @@ -530,6 +530,14 @@ route[EXTERNAL_TO_INTERNAL_RELAY] } #!endif + #!ifdef CALL-PARK-REDIRECT-ROLE + if(is_method("REFER")) { + $avp(refer_to) = $hdr(Refer-To); + $avp(refer_to_uri) = $rt; + $avp(referred_by) = $hdr(Referred-By); + } + #!endif + remove_hf_re("^X-.*"); append_hf("X-AUTH-IP: $si\r\n"); @@ -578,6 +586,13 @@ onreply_route[INTERNAL_REPLY] setflag(FLAG_SESSION_PROGRESS); } + #!ifdef CALL-PARK-REDIRECT-ROLE + if (is_method("REFER") && $T_reply_code == "202" ) { + $sht(park=>$(avp(refer_to_uri){uri.user})@$(avp(refer_to_uri){uri.domain})) = "sip:" + $(ct{tobody.uri}{uri.host}) + ":" + $(ct{tobody.uri}{uri.port}); + xlog("L_INFO", "PARK $(avp(refer_to_uri){uri.user})@$(avp(refer_to_uri){uri.domain}) = sip:$(ct{tobody.uri}{uri.host}):$(ct{tobody.uri}{uri.port})"); + } + #!endif + if ($rs < 300) { xlog("L_INFO", "$ci|pass|$T_req($si):$T_req($sp)"); } diff --git a/kamailio/dispatcher-role.cfg b/kamailio/dispatcher-role.cfg index d5e99b2..c15bf0f 100644 --- a/kamailio/dispatcher-role.cfg +++ b/kamailio/dispatcher-role.cfg @@ -1,6 +1,10 @@ ######## Generic Hash Table container in shared memory ######## modparam("htable", "htable", "failover=>size=16;autoexpire=120") +#!ifdef CALL-PARK-REDIRECT-ROLE +modparam("htable", "htable", "park=>size=4;autoexpire=600") +#!endif + ####### Dispatcher module ######## loadmodule "dispatcher.so" modparam("dispatcher", "list_file", "/etc/kazoo/kamailio/dbtext/dispatcher") @@ -69,6 +73,7 @@ route[DISPATCHER_FIND_ROUTES] #!endif if (is_method("INVITE")) { + if($hdr(Replaces)!= $null) { $var(replaced_call_id) = $(hdr(Replaces){s.select,0,;}); xlog("L_INFO", "$ci|log|replaces call-id $var(replaced_call_id)"); @@ -82,6 +87,17 @@ route[DISPATCHER_FIND_ROUTES] } } } + + ##### CALL-PARK #### + #!ifdef CALL-PARK-REDIRECT-ROLE + if($(ru{uri.user}) =~ "\*3" && $sht(park=>$(ru{uri.user})@$(ru{uri.domain})) != $null) { + $du = $sht(park=>$(ru{uri.user})@$(ruri{uri.domain})); + $sht(park=>$(ru{uri.user})@$(ruri{uri.domain})) = $null; + xlog("L_INFO", "$ci|log|redirecting park request to $du"); + return; + } + #!endif + } if (!ds_select_dst("$var(ds_group)", "0") || $(avp(ds_dst)[0]) == $null) { diff --git a/kamailio/local.cfg b/kamailio/local.cfg index e6534ce..5c4f2ca 100644 --- a/kamailio/local.cfg +++ b/kamailio/local.cfg @@ -18,6 +18,7 @@ debug = L_INFO # # #!trydef TLS-ROLE # # #!trydef ANTIFLOOD-ROLE # # #!trydef MESSAGE-ROLE +# # #!trydef CALL-PARK-REDIRECT-ROLE ################################################################################ ## SERVER INFORMATION From a3d802ddd088331723697cf6d5362b8e87d1ad36 Mon Sep 17 00:00:00 2001 From: lazedo Date: Tue, 24 Feb 2015 20:00:28 +0000 Subject: [PATCH 25/33] KAZOO-3239 send registrar Custom-Channel-Vars for eCallmgr to use --- kamailio/registrar-role.cfg | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/kamailio/registrar-role.cfg b/kamailio/registrar-role.cfg index c0391e5..a1fe3af 100644 --- a/kamailio/registrar-role.cfg +++ b/kamailio/registrar-role.cfg @@ -38,6 +38,8 @@ loadmodule "registrar.so" modparam("registrar", "received_avp", "$avp(AVP_RECV_PARAM)") modparam("registrar", "min_expires", REGISTRAR_MIN_EXPIRES) modparam("registrar", "max_expires", REGISTRAR_MAX_EXPIRES) +modparam("registrar", "xavp_cfg", "regcfg") +modparam("registrar", "reg_match_flag", 1) ####### Registrar Logic ######## @@ -71,7 +73,10 @@ route[HANDLE_REGISTER] route[ATTEMPT_AUTHORIZATION] { - if ($sht(auth_cache=>$Au) != $null) { + $xavp(regcfg=>match_received) = $su; + $xavp(regcfg[0]=>match_contact) = $(ct{nameaddr.uri}); + + if ($sht(auth_cache=>$Au) != $null && registered("location", "$rz:$Au", 6) == 1)) { xlog("L_INFO", "$ci|log|authenticating $fu via cached SIP creds"); $var(password) = $sht(auth_cache=>$Au); } else { @@ -79,6 +84,7 @@ route[ATTEMPT_AUTHORIZATION] $var(amqp_routing_key) = "authn.req." + $(fd{kz.encode}); if(kazoo_query("callmgr", $var(amqp_routing_key), $var(amqp_payload_request))) { $var(password) = $(kzR{kz.json,Auth-Password}); + $xavp(ulattrs=>custom_channel_vars) = $(kzR{kz.json,Custom-Channel-Vars}); xlog("L_INFO", "$ci|log|authenticating $Au via Kazoo query response"); } else { xlog("L_INFO", "$ci|log|failed to query Kazoo for authentication credentials for $Au $si:$sp"); @@ -112,7 +118,18 @@ route[ATTEMPT_AUTHORIZATION] # user authenticated - remove auth header consume_credentials(); - save("location"); + + $var(save_result) = save("location", "0x04"); + if($var(save_result) == -1) { + auth_challenge("$fd", "0"); + xlog("L_INFO", "$ci|end|issued auth challenge after failed attempt to save contact for $Au $si:$sp"); + exit; + } else if($var(save_result) == 1) { + $var(new_reg) = "true"; + } else { + $var(new_reg) = "false"; + } + } if(@contact.expires) { $var(expires) = @contact.expires; @@ -151,7 +168,7 @@ route[ATTEMPT_AUTHORIZATION] $var(register_contants) = ' "Presence-Hosts" : "n/a", "Profile-Name" : "sipinterface_1", "Status" : "Registered", "Event-Timestamp" : "' + $TS + '", "Expires" : ' + $var(expires); - $var(amqp_payload_request) = '{"Event-Category" : "directory", "Event-Name" : "reg_success", "Contact" : "' + $var(fs_contact) + '", "Call-ID" : "' + $ci + '", "Realm" : "' + $fd + '", "Username" : "' + $fU + '", "From-User" : "' + $fU + '", "From-Host" : "' + $fd + '", "To-User" : "' + $tU + '", "To-Host" : "' + $td + '", "User-Agent" : "' + $ua + '" ,' + $var(register_contants) + ' }'; + $var(amqp_payload_request) = '{"Event-Category" : "directory", "Event-Name" : "reg_success", "First-Registration" : $var(new_reg), "Contact" : "$var(fs_contact)", "Call-ID" : "$ci", "Realm" : "$fd", "Username" : "$fU", "From-User" : "$fU", "From-Host" : "$fd", "To-User" : "$tU", "To-Host" : "$td", "User-Agent" : "$ua" , "Custom-Channel-Vars" : $xavp(ulattrs=>custom_channel_vars), $var(register_contants) }'; $var(amqp_routing_key) = "registration.success." + $(fd{kz.encode}) + "." + $(fU{kz.encode}); From 1cba6cade53b6e5bf2eb654f5663cec320d78364 Mon Sep 17 00:00:00 2001 From: lazedo Date: Tue, 24 Feb 2015 20:09:29 +0000 Subject: [PATCH 26/33] KAZOO-3308 call-park enabled --- kamailio/default.cfg | 6 ++---- kamailio/dispatcher-role.cfg | 5 ----- kamailio/local.cfg | 1 - 3 files changed, 2 insertions(+), 10 deletions(-) diff --git a/kamailio/default.cfg b/kamailio/default.cfg index b4e78b3..11bbbaa 100644 --- a/kamailio/default.cfg +++ b/kamailio/default.cfg @@ -530,13 +530,12 @@ route[EXTERNAL_TO_INTERNAL_RELAY] } #!endif - #!ifdef CALL-PARK-REDIRECT-ROLE + ##### CALL-PARK #### if(is_method("REFER")) { $avp(refer_to) = $hdr(Refer-To); $avp(refer_to_uri) = $rt; $avp(referred_by) = $hdr(Referred-By); } - #!endif remove_hf_re("^X-.*"); append_hf("X-AUTH-IP: $si\r\n"); @@ -586,12 +585,11 @@ onreply_route[INTERNAL_REPLY] setflag(FLAG_SESSION_PROGRESS); } - #!ifdef CALL-PARK-REDIRECT-ROLE + ##### CALL-PARK #### if (is_method("REFER") && $T_reply_code == "202" ) { $sht(park=>$(avp(refer_to_uri){uri.user})@$(avp(refer_to_uri){uri.domain})) = "sip:" + $(ct{tobody.uri}{uri.host}) + ":" + $(ct{tobody.uri}{uri.port}); xlog("L_INFO", "PARK $(avp(refer_to_uri){uri.user})@$(avp(refer_to_uri){uri.domain}) = sip:$(ct{tobody.uri}{uri.host}):$(ct{tobody.uri}{uri.port})"); } - #!endif if ($rs < 300) { xlog("L_INFO", "$ci|pass|$T_req($si):$T_req($sp)"); diff --git a/kamailio/dispatcher-role.cfg b/kamailio/dispatcher-role.cfg index c15bf0f..9cee94e 100644 --- a/kamailio/dispatcher-role.cfg +++ b/kamailio/dispatcher-role.cfg @@ -1,9 +1,6 @@ ######## Generic Hash Table container in shared memory ######## modparam("htable", "htable", "failover=>size=16;autoexpire=120") - -#!ifdef CALL-PARK-REDIRECT-ROLE modparam("htable", "htable", "park=>size=4;autoexpire=600") -#!endif ####### Dispatcher module ######## loadmodule "dispatcher.so" @@ -89,14 +86,12 @@ route[DISPATCHER_FIND_ROUTES] } ##### CALL-PARK #### - #!ifdef CALL-PARK-REDIRECT-ROLE if($(ru{uri.user}) =~ "\*3" && $sht(park=>$(ru{uri.user})@$(ru{uri.domain})) != $null) { $du = $sht(park=>$(ru{uri.user})@$(ruri{uri.domain})); $sht(park=>$(ru{uri.user})@$(ruri{uri.domain})) = $null; xlog("L_INFO", "$ci|log|redirecting park request to $du"); return; } - #!endif } diff --git a/kamailio/local.cfg b/kamailio/local.cfg index 5c4f2ca..e6534ce 100644 --- a/kamailio/local.cfg +++ b/kamailio/local.cfg @@ -18,7 +18,6 @@ debug = L_INFO # # #!trydef TLS-ROLE # # #!trydef ANTIFLOOD-ROLE # # #!trydef MESSAGE-ROLE -# # #!trydef CALL-PARK-REDIRECT-ROLE ################################################################################ ## SERVER INFORMATION From a937c6077845e46023bb56536b9ea2a7501d550b Mon Sep 17 00:00:00 2001 From: lazedo Date: Wed, 25 Feb 2015 12:24:12 +0000 Subject: [PATCH 27/33] KAZOO-3239 - fix missing bracket --- kamailio/registrar-role.cfg | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/kamailio/registrar-role.cfg b/kamailio/registrar-role.cfg index a1fe3af..2e1b7d4 100644 --- a/kamailio/registrar-role.cfg +++ b/kamailio/registrar-role.cfg @@ -121,14 +121,15 @@ route[ATTEMPT_AUTHORIZATION] $var(save_result) = save("location", "0x04"); if($var(save_result) == -1) { - auth_challenge("$fd", "0"); - xlog("L_INFO", "$ci|end|issued auth challenge after failed attempt to save contact for $Au $si:$sp"); - exit; - } else if($var(save_result) == 1) { - $var(new_reg) = "true"; - } else { - $var(new_reg) = "false"; - } + auth_challenge("$fd", "0"); + xlog("L_INFO", "$ci|end|issued auth challenge after failed attempt to save contact for $Au $si:$sp"); + exit; + } else { + if($var(save_result) == 1) { + $var(new_reg) = "true"; + } else { + $var(new_reg) = "false"; + } } if(@contact.expires) { From 5ad8a261bedbb45c56d6889874a5144112aeb7d4 Mon Sep 17 00:00:00 2001 From: lazedo Date: Thu, 26 Feb 2015 18:37:57 +0000 Subject: [PATCH 28/33] call-park check return status --- kamailio/default.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kamailio/default.cfg b/kamailio/default.cfg index 11bbbaa..bb77266 100644 --- a/kamailio/default.cfg +++ b/kamailio/default.cfg @@ -586,7 +586,7 @@ onreply_route[INTERNAL_REPLY] } ##### CALL-PARK #### - if (is_method("REFER") && $T_reply_code == "202" ) { + if (is_method("REFER") && t_check_status("(200)|(202)") ) { $sht(park=>$(avp(refer_to_uri){uri.user})@$(avp(refer_to_uri){uri.domain})) = "sip:" + $(ct{tobody.uri}{uri.host}) + ":" + $(ct{tobody.uri}{uri.port}); xlog("L_INFO", "PARK $(avp(refer_to_uri){uri.user})@$(avp(refer_to_uri){uri.domain}) = sip:$(ct{tobody.uri}{uri.host}):$(ct{tobody.uri}{uri.port})"); } From 1bc69f92aec97b4a34c508d74b90d6557a8d4ebd Mon Sep 17 00:00:00 2001 From: lazedo Date: Thu, 26 Feb 2015 18:45:03 +0000 Subject: [PATCH 29/33] call-park - better debug park in lowercase so we can grep easily --- kamailio/default.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kamailio/default.cfg b/kamailio/default.cfg index bb77266..fc65e14 100644 --- a/kamailio/default.cfg +++ b/kamailio/default.cfg @@ -588,7 +588,7 @@ onreply_route[INTERNAL_REPLY] ##### CALL-PARK #### if (is_method("REFER") && t_check_status("(200)|(202)") ) { $sht(park=>$(avp(refer_to_uri){uri.user})@$(avp(refer_to_uri){uri.domain})) = "sip:" + $(ct{tobody.uri}{uri.host}) + ":" + $(ct{tobody.uri}{uri.port}); - xlog("L_INFO", "PARK $(avp(refer_to_uri){uri.user})@$(avp(refer_to_uri){uri.domain}) = sip:$(ct{tobody.uri}{uri.host}):$(ct{tobody.uri}{uri.port})"); + xlog("L_INFO", "caching park info $(avp(refer_to_uri){uri.user})@$(avp(refer_to_uri){uri.domain}) = sip:$(ct{tobody.uri}{uri.host}):$(ct{tobody.uri}{uri.port})"); } if ($rs < 300) { From 4ecf1d8444666c42b2c69910078aeec989fd0bb3 Mon Sep 17 00:00:00 2001 From: lazedo Date: Sat, 28 Feb 2015 11:08:39 +0000 Subject: [PATCH 30/33] presence: fix expires value issue : when a UA subscribes with a expires value out of bounds of min/max expires and sip_min_expires_action = 2 (force value), the reported value to omnipresence is the original expires and not the corrected value. --- kamailio/presence-role.cfg | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/kamailio/presence-role.cfg b/kamailio/presence-role.cfg index 16358fe..c9a28a4 100644 --- a/kamailio/presence-role.cfg +++ b/kamailio/presence-role.cfg @@ -1,4 +1,8 @@ ######## Presence server module ######## +#!trydef PRESENCE_MIN_EXPIRES 300 +#!trydef PRESENCE_MIN_EXPIRES_ACTION 2 +#!trydef PRESENCE_MAX_EXPIRES 3600 + modparam("htable", "htable", "p=>size=32;autoexpire=600;") loadmodule "presence.so" @@ -14,9 +18,9 @@ modparam("presence", "expires_offset", 60) modparam("presence", "send_fast_notify", 1) modparam("presence", "clean_period", 30) modparam("presence", "publ_cache", 0) -modparam("presence", "min_expires_action", 2) -modparam("presence", "min_expires", 300) -modparam("presence", "max_expires", 3600) +modparam("presence", "min_expires_action", PRESENCE_MIN_EXPIRES_ACTION) +modparam("presence", "min_expires", PRESENCE_MIN_EXPIRES) +modparam("presence", "max_expires", PRESENCE_MAX_EXPIRES) modparam("presence", "sip_uri_match", 1) modparam("presence", "waitn_time", 1) modparam("presence", "notifier_processes", 5) @@ -58,6 +62,13 @@ route[HANDLE_SUBSCRIBE] exit; } + $var(Expires) = $hdr(Expires); + if($var(Expires) < PRESENCE_MIN_EXPIRES) { + $var(Expires) = PRESENCE_MIN_EXPIRES; + } else if($var(Expires) > PRESENCE_MAX_EXPIRES) { + $var(Expires) = PRESENCE_MAX_EXPIRES; + } + ##RabbitMQ $var(fs_path) = "%3C" + $rz + "%3A" + $Ri + "%3A" + $Rp + "%3Btransport=" + $proto + "%3Blr%3Breceived=" + $si+":"+$sp+"%3E"; $var(fs_contact) = "<" + $(ct{tobody.uri}) + ";fs_path=" + $var(fs_path) + ">"; @@ -65,7 +76,7 @@ route[HANDLE_SUBSCRIBE] $var(fs_contact) = $var(fs_contact) + ";" + $(ct{tobody.params}); } - $var(amqp_payload_request) = "{'Event-Category' : 'presence', 'Event-Name' : 'subscription', 'Event-Package' : '" + $hdr(event) + "', 'Expires' : " + $hdr(Expires) + ", 'Queue' : 'BLF-MY_HOSTNAME', 'Server-ID' : 'BLF-MY_HOSTNAME' ,'Contact' : '" + $var(fs_contact) + "', 'Call-ID' : '" + $ci + "', 'From' : '" + $(fu{s.tolower}) +"', 'User' : '" + $(tu{s.tolower}) + "', 'User-Agent' : '" + $ua + "' }"; + $var(amqp_payload_request) = '{"Event-Category" : "presence", "Event-Name" : "subscription", "Event-Package" : "$hdr(event)", "Expires" : "$var(Expires)", "Queue" : "BLF-MY_HOSTNAME", "Server-ID" : "BLF-MY_HOSTNAME" , "Contact" : "$(ct{s.escape.common})", "Call-ID" : "$ci", "From" : "$fu", "User" : "$tu", "User-Agent" : "$(ua{s.escape.common})" }'; kazoo_publish("dialoginfo_subs", "dialoginfo_subs", $var(amqp_payload_request)); From b9bd5a920b10b392cca89466ecca52cd64b626ad Mon Sep 17 00:00:00 2001 From: OnNet Date: Sun, 1 Mar 2015 23:23:47 +0300 Subject: [PATCH 31/33] Looks like semicolon missed --- kamailio/default.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kamailio/default.cfg b/kamailio/default.cfg index fc65e14..5b98c32 100644 --- a/kamailio/default.cfg +++ b/kamailio/default.cfg @@ -381,7 +381,7 @@ route[HANDLE_MESSAGE] route(INTERNAL_TO_EXTERNAL_RELAY); } else { sl_send_reply("202", "delivered to /dev/null"); - exit() + exit(); } } #!endif From bd1054df139599f34abae5d4de88a04f82baee46 Mon Sep 17 00:00:00 2001 From: karl anderson Date: Mon, 2 Mar 2015 09:50:36 -0800 Subject: [PATCH 32/33] update the fs_path to reflect the IP of the interface that recieved the request --- kamailio/registrar-role.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kamailio/registrar-role.cfg b/kamailio/registrar-role.cfg index 2e1b7d4..d5c2c96 100644 --- a/kamailio/registrar-role.cfg +++ b/kamailio/registrar-role.cfg @@ -153,7 +153,7 @@ route[ATTEMPT_AUTHORIZATION] $var(return_port) = "5060"; } - $var(params) = "fs_path="; + $var(params) = "fs_path="; ## TODO: fix escaping, some phones send us -- reg-id=1;+sip.instance="urn:uuid:9b8bd513-0e6e-4660-ad5e-5e35d88cc68f"; ## and if we can store it but not use it because it looses the escapes (that weren't there...) From bf5d19eab3e154b4d41edf851c72ff312264bb29 Mon Sep 17 00:00:00 2001 From: karl anderson Date: Mon, 2 Mar 2015 13:53:58 -0800 Subject: [PATCH 33/33] change min_expires_action --- kamailio/presence-role.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kamailio/presence-role.cfg b/kamailio/presence-role.cfg index c9a28a4..8c40331 100644 --- a/kamailio/presence-role.cfg +++ b/kamailio/presence-role.cfg @@ -1,6 +1,6 @@ ######## Presence server module ######## #!trydef PRESENCE_MIN_EXPIRES 300 -#!trydef PRESENCE_MIN_EXPIRES_ACTION 2 +#!trydef PRESENCE_MIN_EXPIRES_ACTION 1 #!trydef PRESENCE_MAX_EXPIRES 3600 modparam("htable", "htable", "p=>size=32;autoexpire=600;")