Browse Source

added haproxy, rabbitmq, kamailio, config.ini, and updated freeswitch confs

3.12
karl anderson 13 years ago
parent
commit
eeeccddec3
10 changed files with 1025 additions and 151 deletions
  1. +25
    -0
      config.ini
  2. +0
    -12
      freeswitch/autoload_configs/cepstral.conf.xml
  3. +0
    -127
      freeswitch/autoload_configs/httapi.conf.xml
  4. +10
    -9
      freeswitch/autoload_configs/kazoo.conf.xml
  5. +0
    -3
      freeswitch/autoload_configs/modules.conf.xml
  6. +39
    -0
      haproxy/haproxy.cfg
  7. +1
    -0
      kamailio/dispatcher.list
  8. +944
    -0
      kamailio/kamailio.cfg
  9. +1
    -0
      rabbitmq/enabled_plugins
  10. +5
    -0
      rabbitmq/rabbitmq-env.conf

+ 25
- 0
config.ini View File

@ -0,0 +1,25 @@
; section are between [] = [section]
; key = value
; to comment add ";" in front of the line
[amqp]
uri = "amqp://guest:guest@127.0.0.1:5672"
[bigcouch]
compact_automatically = true
cookie = change_me
ip = "127.0.0.1"
port = 5984
; username = "XXX"
; password = "XXX"
admin_port = 5986
[whistle_apps]
cookie = change_me
[ecallmgr]
cookie = change_me
[log]
syslog = info
console = notice
file = error

+ 0
- 12
freeswitch/autoload_configs/cepstral.conf.xml View File

@ -1,12 +0,0 @@
<configuration name="cepstral.conf" description="Cepstral TTS configuration">
<settings>
<!--
Possible encodings:
* utf-8
* us-ascii
* iso8859-1 (default)
* iso8859-15
-->
<param name="encoding" value="utf-8"/>
</settings>
</configuration>

+ 0
- 127
freeswitch/autoload_configs/httapi.conf.xml View File

@ -1,127 +0,0 @@
<configuration name="httapi.conf" description="HT-TAPI Hypertext Telephony API">
<settings>
<!-- print xml on the consol -->
<param name="debug" value="true"/>
<!-- time to keep audio files when discoverd they were deleted from the http server -->
<param name="file-not-found-expires" value="300"/>
<!-- how often to re-check the server to make sure the remote file has not changed -->
<param name="file-cache-ttl" value="300"/>
</settings>
<profiles>
<profile name="default">
<!-- default params for conference action tags -->
<conference>
<param name="default-profile" value="default"/>
</conference>
<!-- default params for dial action tags -->
<dial>
<param name="context" value="default"/>
<param name="dialplan" value="XML"/>
</dial>
<!-- permissions -->
<permissions>
<!-- <permission name="all" value="true"/> -->
<!--<permission name="none" value="true"/> -->
<permission name="set-params" value="true"/>
<permission name="set-vars" value="false">
<!-- default to "deny" or "allow" -->
<!-- type attr can be "deny" or "allow" nothing defaults to opposite of the list default so allow in this case -->
<!--
<variable-list default="deny">
<variable name="caller_id_name"/>
<variable name="hangup"/>
</variable-list>
-->
</permission>
<permission name="get-vars" value="false">
<!-- default to "deny" or "allow" -->
<!-- type attr can be "deny" or "allow" nothing defaults to opposite of the list default so allow in this case -->
<!--
<variable-list default="deny">
<variable name="caller_id_name"/>
<variable name="hangup"/>
</variable-list>
-->
</permission>
<permission name="extended-data" value="false"/>
<permission name="execute-apps" value="true">
<!-- default to "deny" or "allow" -->
<application-list default="deny">
<!-- type attr can be "deny" or "allow" nothing defaults to opposite of the list default so allow in this case -->
<application name="info"/>
<application name="hangup"/>
</application-list>
</permission>
<permission name="expand-vars-in-tag-body" value="false">
<!-- default to "deny" or "allow" -->
<!-- type attr can be "deny" or "allow" nothing defaults to opposite of the list default so allow in this case -->
<!--
<variable-list default="deny">
<variable name="caller_id_name"/>
<variable name="hangup"/>
</variable-list>
<api-list default="deny">
<api name="expr"/>
<api name="lua"/>
</api-list>
-->
</permission>
<permission name="dial" value="true"/>
<permission name="dial-set-context" value="false"/>
<permission name="dial-set-dialplan" value="false"/>
<permission name="dial-set-cid-name" value="false"/>
<permission name="dial-set-cid-number" value="false"/>
<permission name="dial-full-originate" value="false"/>
<permission name="conference" value="true"/>
<permission name="conference-set-profile" value="false"/>
</permissions>
<params>
<!-- default url can be overridden by app data -->
<param name="gateway-url" value="http://www.freeswitch.org/api/index.cgi" />
<!-- set this to provide authentication credentials to the server -->
<!--<param name="gateway-credentials" value="muser:mypass"/>-->
<!--<param name="auth-scheme" value="basic"/>-->
<!-- optional: this will enable the CA root certificate check by libcurl to
verify that the certificate was issued by a major Certificate Authority.
note: default value is disabled. only enable if you want this! -->
<!--<param name="enable-cacert-check" value="true"/>-->
<!-- optional: verify that the server is actually the one listed in the cert -->
<!-- <param name="enable-ssl-verifyhost" value="true"/> -->
<!-- optional: these options can be used to specify custom SSL certificates
to use for HTTPS communications. Either use both options or neither.
Specify your public key with 'ssl-cert-path' and the private key with
'ssl-key-path'. If your private key has a password, specify it with
'ssl-key-password'. -->
<!-- <param name="ssl-cert-path" value="$${base_dir}/conf/certs/public_key.pem"/> -->
<!-- <param name="ssl-key-path" value="$${base_dir}/conf/certs/private_key.pem"/> -->
<!-- <param name="ssl-key-password" value="MyPrivateKeyPassword"/> -->
<!-- optional timeout -->
<!-- <param name="timeout" value="10"/> -->
<!-- optional: use a custom CA certificate in PEM format to verify the peer
with. This is useful if you are acting as your own certificate authority.
note: only makes sense if used in combination with "enable-cacert-check." -->
<!-- <param name="ssl-cacert-file" value="$${base_dir}/conf/certs/cacert.pem"/> -->
<!-- optional: specify the SSL version to force HTTPS to use. Valid options are
"SSLv3" and "TLSv1". Otherwise libcurl will auto-negotiate the version. -->
<!-- <param name="ssl-version" value="TLSv1"/> -->
<!-- optional: enables cookies and stores them in the specified file. -->
<!-- <param name="cookie-file" value="/tmp/cookie-mod_xml_curl.txt"/> -->
<!-- one or more of these imply you want to pick the exact variables that are transmitted -->
<!--<param name="enable-post-var" value="Caller-Unique-ID"/>-->
</params>
</profile>
</profiles>
</configuration>

+ 10
- 9
freeswitch/autoload_configs/kazoo.conf.xml View File

@ -1,12 +1,13 @@
<configuration name="kazoo.conf" description="Kazoo Erlang Socket Client">
<?xml version="1.0" encoding="UTF-8"?>
<configuration name="kazoo.conf" description="General purpose Erlang C-node produced to better fit the Kazoo project">
<settings>
<param name="listen-ip" value="0.0.0.0"/>
<param name="listen-port" value="8031"/>
<param name="cookie-file" value="/etc/freeswitch/autoload_configs/.erlang.cookie" />
<param name="shortname" value="false"/>
<param name="nodename" value="freeswitch@fs01a.5060.io" />
<!--<param name="apply-inbound-acl" value="lan"/>-->
<param name="encoding" value="binary"/>
<param name="listen-ip" value="0.0.0.0" />
<param name="listen-port" value="8031" />
<!--<param name="cookie-file" value="/etc/freeswitch/autoload_configs/.erlang.cookie" />-->
<param name="cookie" value="change_me" />-->
<param name="shortname" value="false" />
<param name="nodename" value="freeswitch" />
<!--<param name="kazoo-var-prefix" value="ecallmgr" />-->
<!--<param name="compat-rel" value="12"/> -->
</settings>
</configuration>
</configuration>

+ 0
- 3
freeswitch/autoload_configs/modules.conf.xml View File

@ -22,13 +22,11 @@
<load module="mod_commands"/>
<load module="mod_conference"/>
<load module="mod_dptools"/>
<load module="mod_expr"/>
<load module="mod_http_cache"/>
<!-- Codec Interfaces -->
<load module="mod_spandsp"/>
<load module="mod_siren"/>
<load module="mod_com_g729"/>
<load module="mod_g723_1"/>
<load module="mod_amr"/>
<load module="mod_ilbc"/>
@ -39,7 +37,6 @@
<!-- File Format Interfaces -->
<load module="mod_sndfile"/>
<!--<load module="mod_native_file"/>-->
<load module="mod_local_stream"/>
<load module="mod_tone_stream"/>
<load module="mod_shout"/>


+ 39
- 0
haproxy/haproxy.cfg View File

@ -0,0 +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
defaults
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
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
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 /

+ 1
- 0
kamailio/dispatcher.list View File

@ -0,0 +1 @@
# setit(integer) destination(sip uri) flags (integer, optional)

+ 944
- 0
kamailio/kamailio.cfg View File

@ -0,0 +1,944 @@
#### Preprocessor Directives #########
#!define L_ALERT -5
#!define L_BUG -4
#!define L_CRIT2 -3
#!define L_CRIT -2
#!define L_ERR -1
#!define L_WARN 0
#!define L_NOTICE 1
#!define L_INFO 2
#!define L_DBG 3
#!define AVP_RECV_PARAM "recv_param"
#!define AVP_LOG_LEVEL "log_level"
#!define AVP_ROUTE_CNT "route_cnt"
#!define AVP_ASSOCIATED_SERVER "associated_server"
#!define AVP_ASSOCIATE_CONTACT "associate_contact"
####### Global Parameters #########
fork = yes
children = 16
#group =
#user =
server_signature = no
server_header = "Server: Kazoo"
user_agent_header = "User-Agent: Kazoo"
shm_force_alloc = yes
mlock_pages = yes
phone2tel = 1
max_while_loops = 500
####### Logging Parameters #########
debug = L_INFO
memdbg = 10
memlog = 10
corelog = L_ERR
log_stderror = no
log_facility = LOG_LOCAL0
log_name="kamailio"
####### Alias Parameters #########
auto_aliases = yes
# alias = "mydomain.net"
####### Binding Parameters #########
listen = tcp:127.0.0.1:5060
listen = udp:127.0.0.1:5060
listen = tcp:127.0.0.1:5080
listen = udp:127.0.0.1:5080
listen = tcp:127.0.0.1:7000
listen = udp:127.0.0.1:7000
#listen = tcp:127.0.0.1:5065
#listen = udp:127.0.0.1:5065
tos = IPTOS_LOWDELAY
####### TCP Parameters #########
tcp_children = 25
disable_tcp = no
tcp_max_connections = 4096
tcp_connection_lifetime = 3605
tcp_accept_aliases = no
tcp_async = yes
tcp_connect_timeout = 10
tcp_conn_wq_max = 65536
tcp_crlf_ping = yes
tcp_delayed_ack = yes
tcp_fd_cache = yes
tcp_keepalive = yes
tcp_keepcnt = 3
tcp_keepidle = 30
tcp_keepintvl = 10
tcp_linger2 = 30
tcp_rd_buf_size = 4096
tcp_send_timeout = 10
tcp_wq_blk_size = 2100
tcp_wq_max = 10485760
####### UDP Parameters #########
udp4_raw = -1
udp4_raw_mtu = 1500
####### DNS Parameters #########
dns = no
rev_dns = no
dns_try_ipv6 = no
use_dns_cache = on
dns_cache_del_nonexp = no
dns_cache_flags = 1
dns_cache_gc_interval = 120
dns_cache_init = 1
dns_cache_mem = 1000
dns_cache_negative_ttl = 60
dns_try_naptr = no
use_dns_failover = off
dns_srv_lb = off
####### TLS Parameters #########
enable_tls = yes
####### SCTP Parameters #########
disable_sctp = yes
####### Custom Parameters #########
####### Modules Section ########
mpath="/usr/local/lib64/kamailio/modules/"
####### Flags #######
flags
FLAG_INTERNALLY_SOURCED: 1,
# FLAG_ITSP_SOURCED: 2,
FLAG_ASSOCIATE_SERVER: 3,
FLAG_SKIP_NAT_CORRECTION: 4;
#!define FLB_NATB 6
#!define FLB_NATSIPPING 7
######## Kamailio core extensions module ########
loadmodule "kex.so"
######## Transaction (stateful) module ########
loadmodule "tm.so"
loadmodule "tmx.so"
modparam("tm", "auto_inv_100", 1)
modparam("tm", "auto_inv_100_reason", "Attempting to connect your call")
modparam("tm", "cancel_b_method", 2)
modparam("tm", "ruri_matching", 0)
modparam("tm", "failure_reply_mode", 3)
# modparam("tm", "fr_timer", 30000)
# modparam("tm", "fr_inv_timer", 120000)
######## Stateless replier module ########
loadmodule "sl.so"
######## Record-Route and Route module ########
loadmodule "rr.so"
modparam("rr", "enable_full_lr", 1)
######## Max-Forward processor module ########
loadmodule "maxfwd.so"
######## SIP utilities [requires sl] ########
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", "autodrop", 0)
######## Text operations module ########
loadmodule "textops.so"
loadmodule "textopsx.so"
######## Path support for SIP loadbalancer ########
loadmodule "path.so"
modparam("path", "use_received", 0)
######## Generic Hash Table container in shared memory ########
loadmodule "htable.so"
#modparam("htable", "htable", "associations=>size=14;")
modparam("htable", "htable", "a=>size=10;")
/*
######## Memcached connector module ########
loadmodule "memcached.so"
modparam("memcached", "servers", "localhost:11211")
modparam("memcached", "expire", 10800)
modparam("memcached", "mode", 0)
modparam("memcached", "timeout", 10000)
*/
######## Module holding Pseudo-Variables ########
loadmodule "pv.so"
######## Advanced logger module ########
loadmodule "xlog.so"
####### FIFO support for Management Interface ########
loadmodule "mi_fifo.so"
modparam("mi_fifo", "fifo_name", "/tmp/kamailio_fifo")
####### Different config utilities ########
loadmodule "cfgutils.so"
####### Dispatcher Module Parameters ########
loadmodule "dispatcher.so"
modparam("dispatcher", "list_file", "/etc/kazoo/kamailio/dispatcher.list")
modparam("dispatcher", "flags", 2)
modparam("dispatcher", "use_default", 0)
modparam("dispatcher", "force_dst", 1)
modparam("dispatcher", "dst_avp", "$avp(ds_dst)")
modparam("dispatcher", "attrs_avp", "$avp(ds_attrs)")
modparam("dispatcher", "grp_avp", "$avp(ds_grp)")
modparam("dispatcher", "cnt_avp", "$avp(ds_cnt)")
modparam("dispatcher", "hash_pvar", "$avp(ds_grp)")
# modparam("dispatcher", "setid_pvar", "$var(setid)")
modparam("dispatcher", "ds_ping_method", "OPTIONS")
modparam("dispatcher", "ds_ping_from", "sip:sipcheck@127.0.0.1")
modparam("dispatcher", "ds_ping_interval", 10)
# modparam("dispatcher", "ds_ping_sock", "udp:{{SIP_IP}}:{{SIP_PORT}}")
modparam("dispatcher", "ds_probing_threshhold", 3)
modparam("dispatcher", "ds_probing_mode", 1)
modparam("dispatcher", "ds_ping_reply_codes", "501,403,404,400,200")
######## Uac_redirect ########
loadmodule "uac_redirect.so"
####### db_kazoo registrar modules ##########
loadmodule "db_kazoo.so"
loadmodule "auth.so"
loadmodule "auth_db.so"
# ----- registrar modules -----
loadmodule "usrloc.so"
loadmodule "registrar.so"
modparam("auth_db|usrloc", "db_url", "kazoo://guest:guest@127.0.0.1:5672/callmgr")
modparam("auth_db", "use_domain", 1)
modparam("auth_db", "version_table", 0)
modparam("auth_db", "calculate_ha1", 1)
modparam("auth_db", "password_column", "password")
modparam("auth_db", "load_credentials", "$avp(password)=password")
/* enable DB persistency for location entries */
modparam("usrloc", "db_mode", 1)
modparam("usrloc", "db_update_as_insert", 1)
modparam("usrloc", "use_domain", 1)
modparam("usrloc", "nat_bflag", FLB_NATB)
######## NAT traversal module - signaling functions ########
loadmodule "nathelper.so"
modparam("nathelper|registrar", "received_avp", "$avp(AVP_RECV_PARAM)")
modparam("nathelper", "natping_interval", 30)
modparam("nathelper", "ping_nated_only", 1)
modparam("nathelper", "natping_processes", 5)
modparam("nathelper", "sipping_bflag", FLB_NATSIPPING)
modparam("nathelper", "sipping_from", "sip:sipcheck@127.0.0.1")
#modparam("nathelper", "natping_socket", "127.0.0.1:5060")
####### Routing Logic ########
route {
# log the basic info regarding this call
xlog("L_INFO", "$ci|start|recieved $oP 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(SET_LOGGING_FLAGS);
route(CLASSIFY_SOURCE);
route(HANDLE_OPTIONS);
route(HANDLE_IN_DIALOG_REQUESTS);
route(PREPARE_INITIAL_REQUESTS);
if (isflagset(FLAG_INTERNALLY_SOURCED)) {
route(INTERNAL_TO_EXTERNAL_RELAY);
exit();
}
route(HANDLE_MOVE_REQUEST);
route(FIND_ROUTES);
$avp(route_attempts) = 1;
route(EXTERNAL_TO_INTERNAL_RELAY);
}
route[SANITY_CHECK] {
if (!mf_process_maxfwd_header("10")) {
xlog("L_WARN", "$ci|end|max-forward limit reached");
sl_send_reply("483", "Too Many Hops");
exit;
}
if (!sanity_check()) {
xlog("L_WARN", "$ci|end|message is insane");
exit;
}
}
route[SET_LOGGING_FLAGS] {
return();
}
route[CLASSIFY_SOURCE]
{
if (ds_is_from_list("1") || ds_is_from_list("3"))
{
xlog("L_INFO", "$ci|log|originated from internal sources");
setflag(FLAG_INTERNALLY_SOURCED);
}
else
{
xlog("L_INFO", "$ci|log|originated from external sources");
}
}
/*
route[CLASSIFY_SOURCE] {
switch($mct($si)) {
case "itsp":
xlog("L_INFO", "$ci|log|message is from ITSP");
setflag(FLAG_ITSP_SOURCED);
break;
case "kazoo":
xlog("L_INFO", "$ci|log|message is from KAZOO");
setflag(FLAG_INTERNALLY_SOURCED);
break;
default:
xlog("L_INFO", "$ci|log|message is from an unknown source");
break;
}
}
*/
route[HANDLE_OPTIONS] {
if (is_method("OPTIONS")) {
if (isflagset(FLAG_INTERNALLY_SOURCED)) {
route(INTERNAL_TO_EXTERNAL_RELAY);
} else {
sl_send_reply("200", "Rawr!!");
}
exit;
}
}
# Called on in-dialog requests
# If the request in an Invite for on hold from external to internal,
# associate the contact with the media server
route[MAYBE_ASSOCIATE_USER] {
# if Invite for on hold, we need to associate the contact URI with the next hop
if (is_method("INVITE") && !isflagset(FLAG_INTERNALLY_SOURCED) && is_audio_on_hold()) {
$var(contact_uri) = $(ct{tobody.user}) + "@" + $(ct{tobody.host});
xlog("L_INFO", "$ci|log|associate user $var(contact_uri):$si:$sp with media server $du\n");
$sht(associations=>$var(contact_uri))= $du;
}
}
route[HANDLE_IN_DIALOG_REQUESTS] {
if (has_totag()) {
if (loose_route()) {
xlog("L_INFO", "$ci|log|loose_route in-dialog message");
route(MAYBE_ASSOCIATE_USER);
route(RELAY);
} else if (isflagset(FLAG_INTERNALLY_SOURCED)) {
xlog("L_INFO", "$ci|log|relay internally sourced in-dialog message without loose_route");
if(is_method("INVITE")) {
xlog("L_INFO", "$ci|log|re-associate $ci with media server $si:$sp");
}
route(RELAY);
} else if (t_check_trans()) {
xlog("L_INFO", "$ci|log|allow message for a known transaction");
route(RELAY);
} else {
xlog("L_INFO", "$ci|log|message had a to-tag but can't be loose routed");
sl_send_reply("481", "Call Leg/Transaction Does Not Exist");
}
exit();
}
}
route[PREPARE_INITIAL_REQUESTS] {
if (is_method("CANCEL")) {
if (t_check_trans()) {
route(RELAY);
} else {
sl_send_reply("481", "Call Leg/Transaction Does Not Exist");
}
exit();
} else if (is_method("ACK")) {
if (t_check_trans()) {
route(RELAY);
}
exit();
}
t_check_trans();
if (loose_route()) {
sl_send_reply("403", "No pre-loaded routes");
exit();
}
if (is_method("REGISTER")) {
if (nat_uac_test("3")) {
xlog("L_INFO", "Nated contact\n");
# setflag(FLB_NATSIPPING);
force_rport();
setbflag(FLB_NATB);
setbflag(FLB_NATSIPPING);
fix_nated_register();
}
# authenticate requests
# check iif we have the password in cache
if ( is_present_hf("Authorization") ) {
if ( $sht(a=>$Au) != $null ) {
xlog("L_INFO", "Found stored password for $Au, $sht(a=>$Au)\n");
if (!pv_auth_check("$fd", "$sht(a=>$Au)", "0", "0")) {
xlog("L_INFO", "Authentication did not work with stored password\n");
## RABBITMQ - Credentials fetch
if (!auth_check("$fd", "subscriber", "1")) {
auth_challenge("$fd", "0");
exit;
} else {
xlog("Credential fetch $avp(password)\n");
# xlog("au=$au, ad = $ad, aU=$aU, Au= $Au\n");
$sht(a=>$Au) = $avp(password);
}
}
} else {
## RABBITMQ - Credentials fetch
if (!auth_check("$fd", "subscriber", "1")) {
auth_challenge("$fd", "0");
exit;
} else {
xlog("L_INFO", "Credential fetch $avp(password)\n");
# xlog("au=$Au, ad = $ad, aU=$aU, Au= $Au\n");
$sht(a=>$Au) = $avp(password);
}
}
} else {
auth_challenge("$fd", "0");
exit;
}
# user authenticated - remove auth header
consume_credentials();
# if (!add_path_received()) {
# sl_send_reply("503", "Internal path befuddlement");
# # route(CLEANUP_DIALOG);
# exit();
# }
save("location");
exit;
/*
if (is_method("REGISTER")) {
if (!add_path_received()) {
sl_send_reply("503", "Internal path befuddlement");
# route(CLEANUP_DIALOG);
exit();
}
*/
} else {
if (!is_method("MESSAGE"))
record_route();
}
}
# Take the routes from dispatcher - hash over callid
# If prefered route defined, reorder the destionations
route[FIND_ROUTES]
{
if (is_method("REGISTER"))
{
# alg 2 = hash(To URI)
# To URI is actually AOR - to help with nounce reusage at reRegister
if (!ds_select_dst("3", "2") && !ds_select_dst("1", "2"))
{
xlog("L_ERR", "$ci|end|no servers avaliable");
sl_send_reply("480", "All servers busy");
exit;
}
}
else
{
# alg 0 = hash(Callid)
if (!ds_select_dst("1", "0"))
{
xlog("L_ERR", "$ci|end|no servers avaliable");
sl_send_reply("480", "All servers busy");
exit;
}
# Handle the case when a prefered route is set
$var(contact_uri) = $(ct{tobody.user}) + "@" + $(ct{tobody.host});
if ($sht(associations=>$var(contact_uri)) != $null)
{
$var(prefered_route) = $sht(associations=>$var(contact_uri));
xlog("L_INFO", "$ci|log|should route to $var(prefered_route)");
route(REORDER_ROUTES);
}
}
}
route[REORDER_ROUTES] {
# if the dispatcher list does not start with
# the the prefered route, reorder the list so that it does
if ($(avp(ds_dst)[0]) != $var(prefered_route))
{
# create a index var for our loop (arrays are start at 0 and this is a count)
$var(i) = $avp(ds_cnt) - 1;
# loop over the dispatcher list
while($var(i) > 0)
{
# if this element in the dispatch list is the same
# as the call destination
if($(avp(ds_dst)[$var(i)]) == $var(prefered_route))
{
# replace it with the first element of the list
$(avp(ds_dst)[$(var(i))]) = $(avp(ds_dst)[0]);
# break out of the loop
$var(i) = -1;
}
$var(i) = $var(i) - 1;
}
# handles the case were we only have two servers
# and the one that we are locked to has failed
if ($var(i) >= 0)
{
xlog("L_INFO", "$ci|log|associated media server is inactive, moving to $rd");
$sht(associations=>$var(contact_uri)) = "sip:$rd:$rp";
xlog("L_INFO", "$ci|log|associated contact $var(contact_uri) with media server sip:$rd:$rp");
}
# the server we are locked to is in the active server list from then
# dispatcher so re-arrange the list to try it first
else
{
xlog("L_INFO", "$ci|log|re-ordering the dispatcher list to keep associated server first");
# set the first element of the list to the destination
$(avp(ds_dst)[0]) = $var(prefered_route);
# set the domain for this request (server IP to route to)
$rd = $(var(prefered_route){uri.host});
# set the port for this request (server IP to route to)
$rp = $(var(prefered_route){uri.port});
}
}
}
route[HANDLE_MOVE_REQUEST]
{
if (is_method("INVITE") && $rU == "*6683*" && $sht(associations=>$var(contact_uri)) != $null )
{
$var(contact_uri) = $(ct{tobody.user}) + "@" + $(ct{tobody.host});
xlog("L_INFO", "$ci|log|remove association for user $var(contact_uri):$si:$sp
with media server $sht(associations=>$var(contact_uri))\n");
$sht(associations=>$var(contact_uri))= $null;
# TODO - does the test expect smth like $rd:$rp as reason?
send_reply("503", "Removed association");
exit;
}
}
route[RELAY] {
# if (is_method("CANCEL") || is_method("BYE")) {
# route(CLEANUP_DIALOG);
# }
if (isflagset(FLAG_INTERNALLY_SOURCED)) {
route(INTERNAL_TO_EXTERNAL_RELAY);
} else {
route(EXTERNAL_TO_INTERNAL_RELAY);
}
exit();
}
route[INTERNAL_TO_EXTERNAL_RELAY] {
remove_hf("X-AUTH-IP");
t_on_reply("EXTERNAL_REPLY");
t_set_fr(0, 10000);
route(LOG_DESTINATION);
# xlog("L_INFO", "$ci|log|associate call-id $ci with sip:$sip:$sp");
# $sht(associations=>$ci) = "sip:" + $si + ":" + $sp;
t_relay();
}
route[EXTERNAL_TO_INTERNAL_RELAY] {
if (!isflagset(FLAG_INTERNALLY_SOURCED)) {
route(NAT_TEST_AND_CORRECT);
}
remove_hf("X-AUTH-IP");
append_hf("X-AUTH-IP: $si\r\n");
t_on_reply("INTERNAL_REPLY");
t_on_failure("INTERNAL_FAULT");
t_set_fr(0, 1000);
route(LOG_DESTINATION);
t_relay();
}
route[LOG_DESTINATION] {
if (isdsturiset()) {
$var(port) = $dp;
$var(domain) = $dd;
} else {
$var(port) = $rp;
$var(domain) = $rd;
}
if ($(var(port){s.len}) <= 0) {
$var(port) = "5060";
}
xlog("L_INFO", "$ci|pass|$var(domain):$var(port)");
}
route[NAT_TEST_AND_CORRECT] {
if (is_present_hf("Record-Route")) {
$var(i) = $rr_count;
while($var(i) > 0) {
$var(i) = $var(i) - 1;
$var(rr) = $(hdr(Record-Route)[$var(i)]);
if (!is_myself("$(var(rr){nameaddr.uri})")) {
setflag(FLAG_SKIP_NAT_CORRECTION);
}
}
} else if ($Rp == "5080") {
setflag(FLAG_SKIP_NAT_CORRECTION);
}
if (isflagset(FLAG_SKIP_NAT_CORRECTION)) {
return();
}
if (nat_uac_test("3")) {
force_rport();
fix_nated_contact();
}
if (has_body("application/sdp") && nat_uac_test("8")) {
fix_nated_sdp("10");
}
}
onreply_route[EXTERNAL_REPLY] {
xlog("L_INFO", "$ci|log|external reply $T_reply_code");
route(NAT_TEST_AND_CORRECT);
# if (is_method("INVITE") && t_check_status("200")) {
# $var(user) = $(ct{tobody.user}) + "@" + $(ct{tobody.host});
# xlog("L_INFO", "$ci|log|associate user $var(user):$si:$sp with media server");
# $sht(associations=>$var(user)) = $avp(AVP_ASSOCIATED_SERVER);
# }
}
onreply_route[INTERNAL_REPLY]
{
# this route handles replies that are comming from our media server
xlog("L_INFO", "$ci|start|recieved internal reply $T_reply_code $rr");
xlog("L_INFO", "$ci|log|source $si:$sp");
if ($rs < 300)
{
xlog("L_INFO", "$ci|pass|$T_req($si):$T_req($sp)");
}
# change 6xx to 4xx
if (t_check_status("6[0-9][0-9]"))
{
$var(new_code) = "4" + $(T_reply_code{s.substr,1,0});
change_reply_status("$var(new_code)", "$rr");
}
}
failure_route[INTERNAL_FAULT]
{
# this branch handles failures (>=300) to our media servers,
# which we can sometimes overcome by routing to another server
# if the failure cause was due to the transaction being
# cancelled then we are complete
if (t_is_canceled())
{
xlog("L_INFO", "$ci|log|transaction was cancelled");
exit;
}
# if the failure case was something that we should recover
# from then try to find a new media server
if (t_check_status("(401)|(407)"))
{
xlog("L_INFO", "$ci|log|failure route ignoring auth reply $T_reply_code $rr");
exit;
}
else if (t_check_status("403"))
{
xlog("L_INFO", "$ci|log|failure route overriding reply code 403 with 503");
xlog("L_INFO", "$ci|pass|$si:$sp");
send_reply("503", "Error: Services Unavailable. Try Later");
exit;
}
else if (t_check_status("402"))
{
xlog("L_INFO", "$ci|log|failure route overriding reply code 402 with 486");
xlog("L_INFO", "$ci|pass|$si:$sp");
send_reply("486", "Insufficient Funds");
exit;
}
else if (t_check_status("(4[0-9][0-9])|(5[0-9][0-9])"))
{
xlog("L_INFO", "$ci|start|received failure reply $T_reply_code $rr");
# try to find a new media server to send the call to
if ($avp(route_attempts) < 3 && ds_next_domain())
{
xlog("L_INFO", "$ci|log|attempting retry $avp(route_attempts) of failed request");
xlog("L_INFO", "$ci|log|routing call to next media server $rd:$rp");
# reset the final reply timer
$avp(final_reply_timer) = 3;
t_on_reply("INTERNAL_REPLY");
t_on_failure("INTERNAL_FAULT");
# relay the request to the new media server
route(EXTERNAL_TO_INTERNAL_RELAY);
$avp(route_attempts) = $avp(route_attempts) + 1;
}
else if (t_check_status("404"))
{
xlog("L_ERR", "$ci|log|no other media servers avaliable, sending 486");
send_reply("486", "Not found");
exit;
}
else
{
xlog("L_ERR", "$ci|log|no other media servers avaliable");
exit;
}
}
else if (t_check_status("302"))
{
## TODO - test this
get_redirects("*");
route(EXTERNAL_TO_INTERNAL_RELAY);
/*
if( $(<reply>hdr(X-Redirect-Server)) && $(<reply>ct.fields(uri)) )
{
$var(redirect_host) = $(<reply>hdr(X-Redirect-Server){uri.host});
$var(redirect_port) = $(<reply>hdr(X-Redirect-Server){uri.port});
cache_store("local", "$(<reply>ct.fields(uri))", "sip:$var(redirect_host):$var(redirect_port)", 60);
xlog("L_INFO", "$ci|log|stored redirect mapping for $(<reply>ct.fields(uri)) to sip:$var(redirect_host):$var(redirect_port)");
remove_hf("X-Redirect-Server");
}
*/
}
else
{
xlog("L_INFO", "$ci|log|failure route ignoring reply $T_reply_code $rr");
exit;
}
route(LOG_DESTINATION);
}
onsend_route {
xlog("L_INFO", "$ci|pass|$sndfrom(ip):$sndfrom(port) -> $sndto(ip):$sndto(port)");
}
## Not used routes
/*
# Take the routes from memcached
# Write them in an AVP
# Randomize
route[LOAD_KAZOO_ROUTES] {
$var(routes) = $mct(available_kazoo_routes);
route(LOAD_ROUTES);
$var(randomizer_pos) = $avp(AVP_ROUTE_CNT);
route(RANDOMIZE_ROUTES);
if (!isflagset(FLAG_ITSP_SOURCED) && is_method("REGISTER|INVITE|SUBSCRIBE")) {
setflag(FLAG_ASSOCIATE_SERVER);
}
}
route[LOAD_ROUTES] {
if ($var(routes) == $null) {
return(-1);
}
$var(i) = 0;
$var(route) = $(var(routes){s.select,$var(i),;});
while($(var(route){s.len}) > 0) {
$var(i) = $var(i) + 1;
$avp($var(i)) = $var(route);
$var(route) = $(var(routes){s.select,$var(i),;});
}
$avp(AVP_ROUTE_CNT) = $var(i);
return(1);
}
# No longer used
route[NEXT_ROUTE] {
if ($avp(AVP_ROUTE_CNT) <= 0) {
return(-1);
}
$var(domain) = $(avp($avp(AVP_ROUTE_CNT)){uri.host});
$var(port) = $(avp($avp(AVP_ROUTE_CNT)){uri.port});
$avp(AVP_ROUTE_CNT) = $avp(AVP_ROUTE_CNT) - 1;
if ($(var(domain){s.len}) <= 0) {
route(NEXT_ROUTE);
}
if ($(var(port){s.len}) <= 4) {
$var(port) = "5060";
}
$du = "sip:" + $var(domain) + ":" + $var(port);
xlog("L_INFO", "$ci|log|associate call-id $ci with $du");
$sht(associations=>$ci) = $du;
return(1);
}
route[RANDOMIZE_ROUTES] {
if ($var(randomizer_pos) <= 0) {
return();
}
$var(random_pos) = ($RANDOM mod $var(randomizer_pos) + 1);
if ($var(random_pos) != $var(randomizer_pos)) {
$var(route) = $avp($var(randomizer_pos));
$avp($var(randomizer_pos)) = $avp($var(random_pos));
$avp($var(random_pos)) = $var(route);
}
$var(randomizer_pos) = $var(randomizer_pos) - 1;
route(RANDOMIZE_ROUTES);
}
route[LOG_ROUTES] {
$var(i) = $avp(AVP_ROUTE_CNT);
while($var(i) > 0) {
$var(value) = $avp($var(i));
xlog("L_INFO", "$ci|log|route $var(i): $var(value)");
$var(i) = $var(i) - 1;
}
}
route[CLEANUP_DIALOG] {
xlog("L_INFO", "$ci|log|remove any association for $ci");
sht_rm_name_re("associations=>$ci");
return();
}
route[MAYBE_ASSOCIATE_SERVER] {
if (isflagset(FLAG_ASSOCIATE_SERVER) && defined $avp(AVP_ASSOCIATED_SERVER)) {
xlog("L_INFO", "$ci|log|associate call-id $ci with $avp(AVP_ASSOCIATED_SERVER)");
$sht(associations=>$ci) = $avp(AVP_ASSOCIATED_SERVER);
if (is_method("INVITE")) {
$var(user) = $(ct{tobody.user}) + "@" + $si;
xlog("L_INFO", "$ci|log|associate user $var(user) with $avp(AVP_ASSOCIATED_SERVER)");
$sht(associations=>$var(user)) = $avp(AVP_ASSOCIATED_SERVER);
}
}
}
*/
## vim:set tabstop=4 softtabstop=4 shiftwidth=4 expandtab

+ 1
- 0
rabbitmq/enabled_plugins View File

@ -0,0 +1 @@
[rabbitmq_management].

+ 5
- 0
rabbitmq/rabbitmq-env.conf View File

@ -0,0 +1,5 @@
NODENAME=rabbit
NODE_IP_ADDRESS=0.0.0.0
NODE_PORT=5672
LOG_BASE=/var/log/rabbitmq
MNESIA_BASE=/var/lib/rabbitmq/mnesia

Loading…
Cancel
Save