|
|
|
@ -23,8 +23,9 @@ max_while_loops = 500 |
|
|
|
####### Logging Parameters ######### |
|
|
|
debug = L_INFO |
|
|
|
memdbg = 10 |
|
|
|
memlog = 10 |
|
|
|
memlog = L_INFO |
|
|
|
corelog = L_ERR |
|
|
|
mem_summary = 12 |
|
|
|
log_stderror = no |
|
|
|
log_facility = LOG_LOCAL0 |
|
|
|
log_name="kamailio" |
|
|
|
@ -81,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" |
|
|
|
|
|
|
|
@ -112,10 +116,8 @@ loadmodule "siputils.so" |
|
|
|
|
|
|
|
######## SIP message formatting sanity checks [requires sl] ######## |
|
|
|
loadmodule "sanity.so" |
|
|
|
# sip_version, scheme, req_headers, cseq_method/value |
|
|
|
# content_length, parse_uri, digest |
|
|
|
modparam("sanity", "default_checks", 3303) |
|
|
|
modparam("sanity", "uri_checks", 3) |
|
|
|
modparam("sanity", "default_checks", 1511) |
|
|
|
modparam("sanity", "uri_checks", 7) |
|
|
|
modparam("sanity", "autodrop", 0) |
|
|
|
|
|
|
|
######## Text operations module ######## |
|
|
|
@ -140,9 +142,6 @@ modparam("mi_fifo", "fifo_name", "/tmp/kamailio_fifo") |
|
|
|
######## UAC Redirection module ######## |
|
|
|
loadmodule "uac_redirect.so" |
|
|
|
|
|
|
|
######## DoS prevention mdule ######## |
|
|
|
loadmodule "pike.so" |
|
|
|
|
|
|
|
####### DB Text module ########## |
|
|
|
loadmodule "db_text.so" |
|
|
|
modparam("db_text", "db_mode", 1) |
|
|
|
@ -150,13 +149,12 @@ modparam("db_text", "db_mode", 1) |
|
|
|
####### Kazoo Integration module ########## |
|
|
|
loadmodule "db_kazoo.so" |
|
|
|
modparam("db_kazoo", "node_hostname", "MY_HOSTNAME") |
|
|
|
modparam("db_kazoo", "register_fs_path", "MY_IP_ADDRESS") |
|
|
|
modparam("db_kazoo", "amqp_connection", "MY_AMQP_URL") |
|
|
|
#!ifdef MY_AMQP_URL_SECONDARY |
|
|
|
modparam("db_kazoo", "amqp_connection", "MY_AMQP_URL_SECONDARY") |
|
|
|
#!endif |
|
|
|
#!ifdef MY_AMQP_URL_TERTIARY |
|
|
|
#modparam("db_kazoo", "amqp_connection", "MY_AMQP_URL_TERTIARY") |
|
|
|
modparam("db_kazoo", "amqp_connection", "MY_AMQP_URL_TERTIARY") |
|
|
|
#!endif |
|
|
|
#!ifdef MY_AMQP_MAX_CHANNELS |
|
|
|
modparam("db_kazoo", "amqp_max_channels", MY_AMQP_MAX_CHANNELS) |
|
|
|
@ -164,7 +162,7 @@ modparam("db_kazoo", "amqp_max_channels", MY_AMQP_MAX_CHANNELS) |
|
|
|
modparam("db_kazoo", "amqp_max_channels", 100) |
|
|
|
#!endif |
|
|
|
modparam("db_kazoo", "amqp_internal_loop_count", 1); |
|
|
|
modparam("db_kazoo", "amqp_consumer_loop_count", 3); |
|
|
|
modparam("db_kazoo", "amqp_consumer_loop_count", 4); |
|
|
|
|
|
|
|
####### Role Configurations ########## |
|
|
|
#!ifdef DISPATCHER-ROLE |
|
|
|
@ -185,6 +183,15 @@ include_file "websockets-role.cfg" |
|
|
|
#!ifdef TLS-ROLE |
|
|
|
include_file "tls-role.cfg" |
|
|
|
#!endif |
|
|
|
#!ifdef ACCOUNTING-ROLE |
|
|
|
include_file "accounting-role.cfg" |
|
|
|
#!endif |
|
|
|
#!ifdef ANTIFLOOD-ROLE |
|
|
|
include_file "antiflood-role.cfg" |
|
|
|
#!endif |
|
|
|
#!ifdef TRAFFIC-FILTER-ROLE |
|
|
|
include_file "traffic-filter-role.cfg" |
|
|
|
#!endif |
|
|
|
|
|
|
|
####### Permissions module ########## |
|
|
|
loadmodule "permissions.so" |
|
|
|
@ -202,12 +209,15 @@ route |
|
|
|
|
|
|
|
route(SANITY_CHECK); |
|
|
|
|
|
|
|
#!ifdef DISPATCHER-ROLE |
|
|
|
route(DISPATCHER_CLASSIFY_SOURCE); |
|
|
|
route(CLASSIFY_SOURCE); |
|
|
|
|
|
|
|
#!ifdef ANTIFLOOD-ROLE |
|
|
|
route(ANTIFLOOD_RATE_LIMIT); |
|
|
|
route(ANITFLOOD_AUTH_LIMIT); |
|
|
|
#!endif |
|
|
|
|
|
|
|
#!ifdef TRAFFIC-FILTER-ROLE |
|
|
|
route(DOS_PREVENTION); |
|
|
|
route(TRAFFIC_FILTER); |
|
|
|
#!endif |
|
|
|
|
|
|
|
#!ifdef WEBSOCKETS-ROLE |
|
|
|
@ -220,8 +230,6 @@ route |
|
|
|
|
|
|
|
route(HANDLE_MESSAGE); |
|
|
|
|
|
|
|
route(HANDLE_MOVE_REQUEST); |
|
|
|
|
|
|
|
#!ifdef PRESENCE-ROLE |
|
|
|
route(HANDLE_SUBSCRIBE); |
|
|
|
route(HANDLE_PUBLISH); |
|
|
|
@ -268,17 +276,28 @@ route[SANITY_CHECK] |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
route[CLASSIFY_SOURCE] |
|
|
|
{ |
|
|
|
if (isflagset(FLAG_INTERNALLY_SOURCED) || allow_source_address(TRUSTED_ADR_GROUP) || is_myself($si)) { |
|
|
|
xlog("L_INFO", "$ci|log|request from trusted IP"); |
|
|
|
setflag(FLAG_TRUSTED_SOURCE); |
|
|
|
} |
|
|
|
|
|
|
|
#!ifdef DISPATCHER-ROLE |
|
|
|
route(DISPATCHER_CLASSIFY_SOURCE); |
|
|
|
#!endif |
|
|
|
} |
|
|
|
|
|
|
|
route[HANDLE_OPTIONS] |
|
|
|
{ |
|
|
|
if (is_method("OPTIONS")) { |
|
|
|
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 OPTIONS request with IP domain"); |
|
|
|
#!endif |
|
|
|
} else { |
|
|
|
#!ifdef TRAFFIC-FILTER-ROLE |
|
|
|
route(FILTER_REQUEST_DOMAIN); |
|
|
|
#!endif |
|
|
|
|
|
|
|
sl_send_reply("200", "Rawr!!"); |
|
|
|
} |
|
|
|
exit; |
|
|
|
@ -290,12 +309,11 @@ route[HANDLE_NOTIFY] |
|
|
|
if (is_method("NOTIFY")) { |
|
|
|
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 OPTIONS request with IP domain"); |
|
|
|
#!endif |
|
|
|
} else { |
|
|
|
#!ifdef TRAFFIC-FILTER-ROLE |
|
|
|
route(FILTER_REQUEST_DOMAIN); |
|
|
|
#!endif |
|
|
|
|
|
|
|
sl_send_reply("200", "Rawr!!"); |
|
|
|
} |
|
|
|
exit; |
|
|
|
@ -314,23 +332,6 @@ route[HANDLE_MESSAGE] |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
route[HANDLE_MOVE_REQUEST] |
|
|
|
{ |
|
|
|
if (is_method("INVITE") && $rU == "*6683*") { |
|
|
|
$var(contact_uri) = $(ct{tobody.user}) + "@" + $(ct{tobody.host}); |
|
|
|
|
|
|
|
if ($sht(associations=>$var(contact_uri)) != $null) { |
|
|
|
$sht(associations=>$var(contact_uri)) = $null; |
|
|
|
xlog("L_INFO", "$ci|log|removed contact association for $var(contact_uri) |
|
|
|
with media server $sht(associations=>$var(contact_uri))"); |
|
|
|
} |
|
|
|
|
|
|
|
send_reply("503", "Removed association"); |
|
|
|
|
|
|
|
exit; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
route[HANDLE_IN_DIALOG_REQUESTS] |
|
|
|
{ |
|
|
|
if (has_totag()) { |
|
|
|
@ -338,6 +339,14 @@ route[HANDLE_IN_DIALOG_REQUESTS] |
|
|
|
record_route(); |
|
|
|
} |
|
|
|
if (loose_route()) { |
|
|
|
|
|
|
|
#!ifdef ACCOUNTING-ROLE |
|
|
|
if (is_method("BYE")) { |
|
|
|
setflag(FLAG_ACC); |
|
|
|
setflag(FLAG_ACCFAILED); |
|
|
|
} |
|
|
|
#!endif |
|
|
|
|
|
|
|
#!ifdef WEBSOCKETS-ROLE |
|
|
|
if ($du == $null) { |
|
|
|
handle_ruri_alias(); |
|
|
|
@ -385,7 +394,7 @@ route[PREPARE_INITIAL_REQUESTS] |
|
|
|
if (t_check_trans()) { |
|
|
|
route(RELAY); |
|
|
|
} else { |
|
|
|
sl_send_reply("481", "Call Leg/Transaction Does Not Exist"); |
|
|
|
sl_send_reply("481", "Call leg/transaction does not exist"); |
|
|
|
} |
|
|
|
exit(); |
|
|
|
} else if (is_method("ACK")) { |
|
|
|
@ -395,8 +404,21 @@ route[PREPARE_INITIAL_REQUESTS] |
|
|
|
exit(); |
|
|
|
} |
|
|
|
|
|
|
|
# handle re-transmissions |
|
|
|
t_check_trans(); |
|
|
|
|
|
|
|
if (is_method("UPDATE")) { |
|
|
|
xlog("L_WARN", "$ci|end|update outside dialog not allowed"); |
|
|
|
send_reply("403", "Dialog does not exist"); |
|
|
|
break; |
|
|
|
} |
|
|
|
|
|
|
|
if (is_method("BYE|PRACK")) { |
|
|
|
xlog("L_WARN", "$ci|end|originating subsequent requests outside dialog not allowed"); |
|
|
|
send_reply("403", "Dialog does not exist"); |
|
|
|
break; |
|
|
|
} |
|
|
|
|
|
|
|
if (loose_route()) { |
|
|
|
xlog("L_WARN", "$ci|end|denying initial request with route-set"); |
|
|
|
sl_send_reply("403", "No pre-loaded routes"); |
|
|
|
@ -421,7 +443,14 @@ route[RELAY] |
|
|
|
|
|
|
|
route[INTERNAL_TO_EXTERNAL_RELAY] |
|
|
|
{ |
|
|
|
remove_hf_re("X-.*"); |
|
|
|
#!ifdef ACCOUNTING-ROLE |
|
|
|
if (is_method("INVITE")) { |
|
|
|
setflag(FLAG_ACC); |
|
|
|
setflag(FLAG_ACCFAILED); |
|
|
|
} |
|
|
|
#!endif |
|
|
|
|
|
|
|
remove_hf_re("^X-.*"); |
|
|
|
|
|
|
|
t_on_reply("EXTERNAL_REPLY"); |
|
|
|
|
|
|
|
@ -432,13 +461,20 @@ route[INTERNAL_TO_EXTERNAL_RELAY] |
|
|
|
|
|
|
|
route[EXTERNAL_TO_INTERNAL_RELAY] |
|
|
|
{ |
|
|
|
#!ifdef ACCOUNTING-ROLE |
|
|
|
if (is_method("INVITE") && is_present_hf("Proxy-Authorization")) { |
|
|
|
setflag(FLAG_ACC); |
|
|
|
setflag(FLAG_ACCFAILED); |
|
|
|
} |
|
|
|
#!endif |
|
|
|
|
|
|
|
#!ifdef NAT-TRAVERSAL-ROLE |
|
|
|
if (!isflagset(FLAG_INTERNALLY_SOURCED)) { |
|
|
|
route(NAT_TEST_AND_CORRECT); |
|
|
|
} |
|
|
|
#!endif |
|
|
|
|
|
|
|
remove_hf_re("X-.*"); |
|
|
|
remove_hf_re("^X-.*"); |
|
|
|
append_hf("X-AUTH-IP: $si\r\n"); |
|
|
|
|
|
|
|
t_on_reply("INTERNAL_REPLY"); |
|
|
|
@ -449,39 +485,6 @@ route[EXTERNAL_TO_INTERNAL_RELAY] |
|
|
|
t_relay(); |
|
|
|
} |
|
|
|
|
|
|
|
route[DOS_PREVENTION] |
|
|
|
{ |
|
|
|
# allow request from internal network or from whitelist |
|
|
|
if (isflagset(FLAG_INTERNALLY_SOURCED) || allow_source_address(TRUSTED_ADR_GROUP) || is_myself($si)) { |
|
|
|
xlog("L_INFO", "$ci|log|request from trusted IP"); |
|
|
|
setflag(FLAG_TRUSTED_SOURCE); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
# drop requests with no To domain or IP To domain (friendly-scanner) |
|
|
|
if (is_method("REGISTER|SUBSCRIBE|OPTIONS") && |
|
|
|
($td == $null || $td=~ "[0-9]{1,3}\.[0-9]{1,3}.[0-9]{1,3}\.[0-9]{1,3}")) { |
|
|
|
xlog("L_WARN", "$ci|log|dropping request with IP domain in To header"); |
|
|
|
exit; |
|
|
|
} |
|
|
|
|
|
|
|
# drop Invite with IP auth realm |
|
|
|
if (is_method("INVITE") && is_present_hf("Proxy-Authorization") && |
|
|
|
$ar =~ "[0-9]{1,3}\.[0-9]{1,3}.[0-9]{1,3}\.[0-9]{1,3}" ) { |
|
|
|
xlog("L_WARN", "$ci|log|dropping request with IP domain in Proxy-Authorization header"); |
|
|
|
exit; |
|
|
|
} |
|
|
|
|
|
|
|
# use pike check for the others |
|
|
|
if (!pike_check_req()) { |
|
|
|
# If it is a new flood, emit a log |
|
|
|
if($rc == -2) { |
|
|
|
xlog("L_WARN", "$ci|log|dropping due to rate of requests from IP"); |
|
|
|
} |
|
|
|
exit; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
onreply_route[EXTERNAL_REPLY] |
|
|
|
{ |
|
|
|
xlog("L_INFO", "$ci|log|external reply $T_reply_code"); |
|
|
|
@ -535,7 +538,6 @@ failure_route[INTERNAL_FAULT] |
|
|
|
# cancelled then we are complete |
|
|
|
if (t_is_canceled()) { |
|
|
|
xlog("L_INFO", "$ci|log|transaction was cancelled"); |
|
|
|
|
|
|
|
exit; |
|
|
|
} |
|
|
|
|
|
|
|
@ -555,7 +557,7 @@ failure_route[INTERNAL_FAULT] |
|
|
|
$sht(redirects=>$avp(AVP_REDIRECT_KEY)) = $null; |
|
|
|
} |
|
|
|
|
|
|
|
remove_hf_re("X-.*"); |
|
|
|
remove_hf_re("^X-.*"); |
|
|
|
|
|
|
|
# change 6xx to 4xx |
|
|
|
if (t_check_status("6[0-9][0-9]") && !t_check_status("600|603|604|606")) { |
|
|
|
@ -601,8 +603,29 @@ onsend_route { |
|
|
|
event_route[kazoo:mod-init] |
|
|
|
{ |
|
|
|
#!ifdef PRESENCE-ROLE |
|
|
|
kazoo_subscribe("dialoginfo", "direct", "BLF-QUEUE-MY_HOSTNAME", "BLF-MY_HOSTNAME"); |
|
|
|
|
|
|
|
### 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' |
|
|
|
### : 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 |
|
|
|
### |
|
|
|
### Rabbit Policy for ha-mode |
|
|
|
### 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] |
|
|
|
@ -610,5 +633,15 @@ event_route[kazoo:consumer-event] |
|
|
|
xlog("L_INFO","unhandled AMQP event, payload: $kzE"); |
|
|
|
} |
|
|
|
|
|
|
|
event_route[kazoo:consumer-event-connection-open] |
|
|
|
{ |
|
|
|
xlog("L_INFO","connection to $(kzE{kz.json,host}) opened"); |
|
|
|
} |
|
|
|
|
|
|
|
event_route[kazoo:consumer-event-connection-closed] |
|
|
|
{ |
|
|
|
xlog("L_INFO","connection to $(kzE{kz.json,host}) closed"); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
# vim: tabstop=4 softtabstop=4 shiftwidth=4 expandtab |