From 8f241272c84250ec65fd69d3c23df7743db128b1 Mon Sep 17 00:00:00 2001 From: karl anderson Date: Wed, 4 Feb 2015 12:07:04 -0800 Subject: [PATCH] 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)); }