Browse Source

KAZOO-3265: formating tweaks

3.20
karl anderson 11 years ago
parent
commit
8f241272c8
3 changed files with 43 additions and 51 deletions
  1. +37
    -42
      kamailio/default.cfg
  2. +1
    -1
      kamailio/local.cfg
  3. +5
    -8
      kamailio/message-role.cfg

+ 37
- 42
kamailio/default.cfg View File

@ -325,44 +325,39 @@ route[HANDLE_NOTIFY]
route[HANDLE_MESSAGE] 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"); xlog("L_WARN", "$ci|end|dropping MESSAGE application/im-iscomposing+xml");
sl_send_reply("200", "OK"); sl_send_reply("200", "OK");
} else {
} else {
route(DISPATCHER_FIND_ROUTES); route(DISPATCHER_FIND_ROUTES);
route(EXTERNAL_TO_INTERNAL_RELAY); 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] route[HANDLE_IN_DIALOG_REQUESTS]
@ -542,9 +537,9 @@ onreply_route[INTERNAL_REPLY]
#!endif #!endif
if (is_method("INVITE") && 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 && if ($avp(AVP_REDIRECT_KEY) != $null &&
$sht(redirects=>$avp(AVP_REDIRECT_KEY)) != $null $sht(redirects=>$avp(AVP_REDIRECT_KEY)) != $null
) { ) {
@ -576,8 +571,8 @@ failure_route[INTERNAL_FAULT]
# Handle redirects # Handle redirects
if (t_check_status("302")) { 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) { if($T_rpl($hdr(X-Redirect-Server)) != $null) {
$sht(redirects=>$var(redirect)) = $T_rpl($hdr(X-Redirect-Server)); $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))"); 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")) { 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}); $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)"); 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 # if the failure case was something that we should recover
# from then try to find a new media server # from then try to find a new media server
@ -637,13 +632,13 @@ event_route[kazoo:mod-init]
{ {
#!ifdef PRESENCE-ROLE #!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"); ### kazoo_subscribe("dialoginfo", "direct", "BLF-QUEUE-MY_HOSTNAME", "BLF-MY_HOSTNAME");
### ###
### or unleash the power of rabbit to kazoo-blf ### 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 ### : 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 ### : 0 => when it receives, it acks then processes in the AMQP Worker
### only works if no_ack : 0 ### only works if no_ack : 0
@ -652,13 +647,13 @@ event_route[kazoo:mod-init]
### pattern : ^BLF ### pattern : ^BLF
### definition : ha-mode: all ### 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 }"; $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)"); xlog("L_INFO","SUBSCRIBE $var(payload)");
kazoo_subscribe("$var(payload)"); kazoo_subscribe("$var(payload)");
#!endif #!endif
} }
event_route[kazoo:consumer-event] event_route[kazoo:consumer-event]


+ 1
- 1
kamailio/local.cfg View File

@ -11,13 +11,13 @@ debug = L_INFO
#!trydef NAT-TRAVERSAL-ROLE #!trydef NAT-TRAVERSAL-ROLE
#!trydef REGISTRAR-ROLE #!trydef REGISTRAR-ROLE
#!trydef PRESENCE-ROLE #!trydef PRESENCE-ROLE
###!trydef MESSAGE-ROLE
## Disabled Roles - remove all but the last '#' to enable ## Disabled Roles - remove all but the last '#' to enable
# # #!trydef TRAFFIC-FILTER-ROLE # # #!trydef TRAFFIC-FILTER-ROLE
# # #!trydef WEBSOCKETS-ROLE # # #!trydef WEBSOCKETS-ROLE
# # #!trydef TLS-ROLE # # #!trydef TLS-ROLE
# # #!trydef ANTIFLOOD-ROLE # # #!trydef ANTIFLOOD-ROLE
# # #!trydef MESSAGE-ROLE
################################################################################ ################################################################################
## SERVER INFORMATION ## SERVER INFORMATION


+ 5
- 8
kamailio/message-role.cfg View File

@ -25,7 +25,6 @@ event_route[kazoo:consumer-event-message-route]
$uac_req(callid) = $(kzE{kz.json,Call-ID}); $uac_req(callid) = $(kzE{kz.json,Call-ID});
xlog("L_INFO", "sending message from $var(from_uri) to $var(to_uri) "); xlog("L_INFO", "sending message from $var(from_uri) to $var(to_uri) ");
uac_req_send(); uac_req_send();
} }
route[MESSAGE_REPLY] route[MESSAGE_REPLY]
@ -35,21 +34,19 @@ route[MESSAGE_REPLY]
} }
if($T_reply_code != 200 && $T_reply_code != 202) { if($T_reply_code != 200 && $T_reply_code != 202) {
$var(Result) = "Failure";
$var(Result) = "Failure";
} else { } 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(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(RoutingKey) = $(sht(msg=>$ci){kz.json,Server-ID});
$var(exchange) = "targeted"; $var(exchange) = "targeted";
if($var(RoutingKey) == "") { 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"); xlog("L_INFO", "sending delivery message for $ci");
kazoo_publish($var(exchange), $var(RoutingKey), $var(Payload)); kazoo_publish($var(exchange), $var(RoutingKey), $var(Payload));
} }


Loading…
Cancel
Save