@ -83,6 +83,9 @@ disable_sctp = yes
####### Modules Section ########
####### Modules Section ########
mpath = "/usr/lib64/kamailio/modules/"
mpath = "/usr/lib64/kamailio/modules/"
######## Kamailio control connector module ########
loadmodule "ctl.so"
######## Kamailio core extensions module ########
######## Kamailio core extensions module ########
loadmodule "kex.so"
loadmodule "kex.so"
@ -137,30 +140,34 @@ loadmodule "xlog.so"
loadmodule "mi_fifo.so"
loadmodule "mi_fifo.so"
modparam("mi_fifo", "fifo_name", "/tmp/kamailio_fifo")
modparam("mi_fifo", "fifo_name", "/tmp/kamailio_fifo")
######## UAC ########
loadmodule "uac.so"
######## UAC Redirection module ########
######## UAC Redirection module ########
loadmodule "uac_redirect.so"
loadmodule "uac_redirect.so"
####### DB Text module ##########
####### DB Text module ##########
loadmodule "db_text.so"
loadmodule "db_text.so"
modparam("db_text", "db_mode", 1)
modparam("db_text", "db_mode", 1)
modparam("db_text", "emptystring", 1)
####### Kazoo Integration module ##########
####### 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
#!ifdef MY_AMQP_URL_SECONDARY
modparam("db_ kazoo", "amqp_connection", "MY_AMQP_URL_SECONDARY")
modparam("kazoo", "amqp_connection", "MY_AMQP_URL_SECONDARY")
#!endif
#!endif
#!ifdef MY_AMQP_URL_TERTIARY
#!ifdef MY_AMQP_URL_TERTIARY
modparam("db_ kazoo", "amqp_connection", "MY_AMQP_URL_TERTIARY")
modparam("kazoo", "amqp_connection", "MY_AMQP_URL_TERTIARY")
#!endif
#!endif
#!ifdef MY_AMQP_MAX_CHANNELS
#!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
#!else
modparam("db_ kazoo", "amqp_max_channels", 100)
modparam("kazoo", "amqp_max_channels", 100)
#!endif
#!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 ##########
####### Role Configurations ##########
#!ifdef DISPATCHER-ROLE
#!ifdef DISPATCHER-ROLE
@ -172,6 +179,9 @@ include_file "registrar-role.cfg"
#!ifdef PRESENCE-ROLE
#!ifdef PRESENCE-ROLE
include_file "presence-role.cfg"
include_file "presence-role.cfg"
#!endif
#!endif
#!ifdef MESSAGE-ROLE
include_file "message-role.cfg"
#!endif
#!ifdef NAT-TRAVERSAL-ROLE
#!ifdef NAT-TRAVERSAL-ROLE
include_file "nat-traversal-role.cfg"
include_file "nat-traversal-role.cfg"
#!endif
#!endif
@ -205,14 +215,14 @@ modparam("permissions", "db_mode", 1)
####### Routing Logic ########
####### Routing Logic ########
route
route
{
{
route(SANITY_CHECK);
# log the basic info regarding this call
# 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|source $si:$sp");
xlog("L_INFO", "$ci|log|from $fu");
xlog("L_INFO", "$ci|log|from $fu");
xlog("L_INFO", "$ci|log|to $tu");
xlog("L_INFO", "$ci|log|to $tu");
route(SANITY_CHECK);
route(CLASSIFY_SOURCE);
route(CLASSIFY_SOURCE);
#!ifdef ANTIFLOOD-ROLE
#!ifdef ANTIFLOOD-ROLE
@ -269,21 +279,21 @@ route
route[SANITY_CHECK]
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;
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;
exit;
}
}
if ($ua = = "friendly-scanner" ||
if ($ua = = "friendly-scanner" ||
$ua = = "sundayddr" ||
$ua = = "sundayddr" ||
$ua = ~ "sipcli" ) {
$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;
exit;
}
}
}
}
@ -320,13 +330,31 @@ route[HANDLE_NOTIFY]
{
{
if (is_method("NOTIFY")) {
if (is_method("NOTIFY")) {
if (isflagset(FLAG_INTERNALLY_SOURCED)) {
if (isflagset(FLAG_INTERNALLY_SOURCED)) {
if (registered("location")) {
lookup("location");
xlog("L_INFO", "$ci|log|routing to $ruid");
}
route(INTERNAL_TO_EXTERNAL_RELAY);
route(INTERNAL_TO_EXTERNAL_RELAY);
} else {
} else {
#!ifdef TRAFFIC-FILTER-ROLE
#!ifdef TRAFFIC-FILTER-ROLE
route(FILTER_REQUEST_DOMAIN);
route(FILTER_REQUEST_DOMAIN);
#!endif
#!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") {
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!!");
}
}
}
exit;
exit;
}
}
@ -334,16 +362,47 @@ route[HANDLE_NOTIFY]
route[HANDLE_MESSAGE]
route[HANDLE_MESSAGE]
{
{
#!ifdef MESSAGE-ROLE
if (is_method("MESSAGE")) {
if (is_method("MESSAGE")) {
if (isflagset(FLAG_INTERNALLY_SOURCED)) {
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");
if (registered("location")) {
lookup("location");
xlog("L_INFO", "$ci|log|routing to $ruid");
}
route(INTERNAL_TO_EXTERNAL_RELAY);
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 {
} 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");
sl_send_reply("202", "delivered to /dev/null");
exit;
exit() ;
}
}
}
}
#!endif
}
}
route[HANDLE_IN_DIALOG_REQUESTS]
route[HANDLE_IN_DIALOG_REQUESTS]
{
{
if (has_totag()) {
if (has_totag()) {
@ -486,6 +545,13 @@ route[EXTERNAL_TO_INTERNAL_RELAY]
}
}
#!endif
#!endif
##### CALL-PARK ####
if(is_method("REFER")) {
$avp(refer_to) = $hdr(Refer-To);
$avp(refer_to_uri) = $rt;
$avp(referred_by) = $hdr(Referred-By);
}
remove_hf_re("^X-.*");
remove_hf_re("^X-.*");
append_hf("X-AUTH-IP: $si\r\n");
append_hf("X-AUTH-IP: $si\r\n");
@ -541,9 +607,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
) {
) {
@ -554,6 +620,12 @@ onreply_route[INTERNAL_REPLY]
setflag(FLAG_SESSION_PROGRESS);
setflag(FLAG_SESSION_PROGRESS);
}
}
##### 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", "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) {
if ($rs < 300) {
xlog("L_INFO", "$ci|pass|$T_req($si):$T_req($sp)");
xlog("L_INFO", "$ci|pass|$T_req($si):$T_req($sp)");
}
}
@ -575,8 +647,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))");
@ -595,7 +667,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
@ -636,13 +708,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
@ -651,13 +723,27 @@ 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 }";
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
#!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)");
kazoo_subscribe("$var(payload)");
#!endif
#!endif
}
}
event_route[kazoo:consumer-event]
event_route[kazoo:consumer-event]