opensips 代理 freeswitch
####### Global Parameters #########
log_level=3
log_stderror=no
log_facility=LOG_LOCAL0
children=4
/* uncomment the following lines to enable debugging */
#debug_mode=yes
/* uncomment the next line to enable the auto temporary blacklisting of
not available destinations (default disabled) */
#disable_dns_blacklist=no
/* uncomment the next line to enable IPv6 lookup after IPv4 dns
lookup failures (default disabled) */
#dns_try_ipv6=yes
/* comment the next line to enable the auto discovery of local aliases
based on reverse DNS on IPs */
auto_aliases=no
listen=udp:ens33:6060
listen=tcp:ens33:6060
tos=IPTOS_LOWDELAY
mcast_loopback=no
mcast_ttl=1
mhomed=0
# tcp_accept_aliases
tcp_accept_aliases=yes
tcp_connect_timeout=3
tcp_connection_lifetime=120
tcp_max_connections=2048
check_via=0
#disable_stateless_fwd=no
####### Modules Section ########
#set module path
mpath="/usr/local//lib64/opensips/modules/"
loadmodule "signaling.so"
loadmodule "sl.so"
loadmodule "tm.so"
loadmodule "rr.so"
loadmodule "maxfwd.so"
loadmodule "sipmsgops.so"
loadmodule "mi_fifo.so"
loadmodule "uri.so"
loadmodule "usrloc.so"
loadmodule "registrar.so"
loadmodule "acc.so"
loadmodule "proto_udp.so"
loadmodule "proto_tcp.so"
loadmodule "path.so"
loadmodule "db_mysql.so"
loadmodule "dialog.so"
loadmodule "textops.so"
loadmodule "nathelper.so"
loadmodule "nat_traversal.so"
loadmodule "uac_redirect.so"
loadmodule "dispatcher.so"
#### FIFO Management Interface
modparam("mi_fifo", "fifo_name", "/tmp/opensips_fifo")
modparam("mi_fifo", "fifo_mode", 0666)
## Stateless UA Module Parameters
modparam("sl", "enable_stats", 1)
modparam("tm", "fr_timeout", 5)
modparam("tm", "fr_inv_timeout", 120)
modparam("tm", "restart_fr_on_each_reply", 0)
modparam("tm", "onreply_avp_mode", 1)
modparam("tm", "pass_provisional_replies", 1)
## Max Forward Module Parameters
modparam("maxfwd", "max_limit", 30)
## Record Route Module Parameters
modparam("rr", "append_fromtag", 1)
modparam("rr", "enable_double_rr", 0)
modparam("rr", "add_username", 0)
modparam("rr", "append_fromtag", 0)
## URI Module Parameters
modparam("uri", "use_sip_uri_host", 0)
modparam("uri", "use_uri_table", 0)
modparam("uri", "service_type", 10)
modparam("uri", "use_domain", 1)
modparam("uri", "use_uri_table", 0)
## User Location Module Parameters
#modparam("usrloc", "nat_bflag", 6)
modparam("usrloc", "nat_bflag", "NAT_BFLAG")
modparam("usrloc", "use_domain", 1)
modparam("usrloc", "desc_time_order", 0)
modparam("usrloc", "timer_interval", 60)
modparam("usrloc", "matching_mode", 0)
modparam("usrloc", "cseq_delay", 20)
modparam("usrloc", "hash_size", 9)
modparam("usrloc", "db_mode", 0)
modparam("usrloc", "user_column", "username")
modparam("usrloc", "domain_column", "domain")
modparam("usrloc", "contact_column", "contact")
modparam("usrloc", "expires_column", "expires")
modparam("usrloc", "q_column", "q")
modparam("usrloc", "callid_column", "callid")
modparam("usrloc", "cseq_column", "cseq")
modparam("usrloc", "methods_column", "methods")
modparam("usrloc", "flags_column", "flags")
modparam("usrloc", "cflags_column", "cflags")
modparam("usrloc", "user_agent_column", "user_agent")
modparam("usrloc", "received_column", "received")
modparam("usrloc", "socket_column", "socket")
modparam("usrloc", "path_column", "path")
## NAT Traversal Module Parameters
#modparam("nat_traversal", "keepalive_interval", 60)
#modparam("nat_traversal", "keepalive_method", "OPTIONS")
#modparam("nat_traversal", "keepalive_from", "sip:keepalive@172.16.1.147:5060")
#modparam("nat_traversal", "keepalive_state_file", "/tmp/opensips_keepalive_state")
## UAC Redirect Module Parameters
modparam("uac_redirect", "default_filter", "accept")
#### REGISTRAR module
modparam("registrar", "tcp_persistent_flag", "TCP_PERSISTENT")
modparam("registrar", "max_contacts", 10)
modparam("registrar", "received_avp", "$avp(received_nh)")
## Path Module Parameters
modparam("path", "use_received", 1)
## Dispatcher Module Parameters
modparam("dispatcher", "db_url", "mysql://root:123456@127.0.0.1/opensips")
modparam("dispatcher", "ds_ping_method", "OPTIONS")
modparam("dispatcher", "ds_ping_interval", 10)
modparam("dispatcher", "ds_probing_threshhold", 3)
modparam("dispatcher", "ds_probing_mode", 1)
####### Routing Logic ########
# main request routing logic
route{
if (!mf_process_maxfwd_header("10")) {
send_reply("483","Too Many Hops");
exit;
}
if (has_totag()) {
# handle hop-by-hop ACK (no routing required)
if ( is_method("ACK") && t_check_trans() ) {
t_relay();
exit;
}
# sequential request within a dialog should
# take the path determined by record-routing
if ( !loose_route() ) {
# we do record-routing for all our traffic, so we should not
# receive any sequential requests without Route hdr.
send_reply("404","Not here");
exit;
}
if (is_method("BYE")) {
# do accounting even if the transaction fails
do_accounting("log","failed");
}
# route it out to whatever destination was set by loose_route()
# in $du (destination URI).
route(relay);
exit;
}
else{
record_route();
}
if (is_method("CANCEL")) {
if (t_check_trans())
t_relay();
exit;
}
if (is_method("REGISTER")) {
if ( !ds_select_dst("1","4") ) {
send_reply("500","Internal Server Error");
exit;
}
#if (!save("location"))
#{
# xlog("failed to register AoR $tu\n");
# exit;
#}
if (!add_path_received())
{
sl_send_reply("503", "Internal path befuddlement");
exit;
}
}
if (is_method("INVITE")) {
if (ds_is_in_list("$si", "", "1")) {
# if (!lookup("location", "m")) {
# xlog("L_ERR","lookup error");
# t_reply("404", "Not Found");
# exit;
# }
} else {
if ( !ds_select_dst("1","4") ){
send_reply("500","Internal Server Error");
exit;
}
}
}
route(relay);
}
route[relay] {
if (!t_relay()) {
send_reply("500","Internal Error");
}
exit;
}
branch_route[per_branch_ops] {
xlog("new branch at $ru\n");
}
onreply_route[handle_nat] {
xlog("incoming reply\n");
}
failure_route[missed_call] {
if (t_was_cancelled()) {
exit;
}
}