Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #
- # OpenSIPS residential configuration script
- # by OpenSIPS Solutions <[email protected]>
- #
- # This script was generated via "make menuconfig", from
- # the "Residential" scenario.
- # You can enable / disable more features / functionalities by
- # re-generating the scenario with different options.#
- #
- # Please refer to the Core CookBook at:
- # https://opensips.org/Resources/DocsCookbooks
- # for a explanation of possible statements, functions and parameters.
- #
- ####### Global Parameters #########
- /* uncomment the following lines to enable debugging */
- #debug_mode=yes
- log_level=3
- xlog_level=3
- stderror_enabled=no
- syslog_enabled=yes
- syslog_facility=LOG_LOCAL0
- udp_workers=4
- /* 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
- socket=udp:192.168.3.102:42060 as 11.11.11.11:42060
- socket=tcp:192.168.3.102:42060 as 11.11.11.11:42060
- socket=tls:192.168.3.102:42061 as 11.11.11.11:42061
- ####### Modules Section ########
- #set module path
- mpath="/usr/lib/x86_64-linux-gnu/opensips/modules/"
- #### SIGNALING module
- loadmodule "signaling.so"
- #### StateLess module
- loadmodule "sl.so"
- #### Transaction Module
- loadmodule "tm.so"
- modparam("tm", "fr_timeout", 5)
- modparam("tm", "fr_inv_timeout", 30)
- modparam("tm", "restart_fr_on_each_reply", 0)
- modparam("tm", "onreply_avp_mode", 1)
- #### Record Route Module
- loadmodule "rr.so"
- /* do not append from tag to the RR (no need for this script) */
- modparam("rr", "append_fromtag", 0)
- #### MAX ForWarD module
- loadmodule "maxfwd.so"
- #### SIP MSG OPerationS module
- loadmodule "sipmsgops.so"
- #### FIFO Management Interface
- loadmodule "mi_fifo.so"
- modparam("mi_fifo", "fifo_name", "/run/opensips/opensips_fifo")
- modparam("mi_fifo", "fifo_mode", 0666)
- #### USeR LOCation module
- loadmodule "usrloc.so"
- modparam("usrloc", "nat_bflag", "NAT")
- modparam("usrloc", "working_mode_preset", "single-instance-no-db")
- #### REGISTRAR module
- loadmodule "registrar.so"
- modparam("registrar", "tcp_persistent_flag", "TCP_PERSISTENT")
- modparam("registrar", "received_avp", "$avp(received_nh)")/* uncomment the next line not to allow more than 10 contacts per AOR */
- #modparam("registrar", "max_contacts", 10)
- #### ACCounting module
- loadmodule "acc.so"
- /* what special events should be accounted ? */
- modparam("acc", "early_media", 0)
- modparam("acc", "report_cancels", 0)
- /* by default we do not adjust the direct of the sequential requests.
- if you enable this parameter, be sure to enable "append_fromtag"
- in "rr" module */
- modparam("acc", "detect_direction", 0)
- #### NAT modules
- loadmodule "nathelper.so"
- modparam("nathelper", "natping_interval", 10)
- modparam("nathelper", "ping_nated_only", 1)
- modparam("nathelper", "sipping_bflag", "SIP_PING_FLAG")
- modparam("nathelper", "sipping_from", "sip:[email protected]") #CUSTOMIZE ME
- modparam("nathelper", "received_avp", "$avp(received_nh)")
- #loadmodule "rtpproxy.so"
- #modparam("rtpproxy", "rtpproxy_sock", "udp:localhost:12221") # CUSTOMIZE ME
- loadmodule "proto_udp.so"
- loadmodule "proto_tcp.so"
- loadmodule "proto_tls.so"
- loadmodule "tls_wolfssl.so"
- loadmodule "tls_mgm.so"
- modparam("tls_mgm","server_domain", "default")
- modparam("tls_mgm","match_ip_address", "[default]*")
- modparam("tls_mgm","verify_cert", "[default]0")
- modparam("tls_mgm","require_cert", "[default]0")
- modparam("tls_mgm","tls_method", "[default]SSLv23")
- modparam("tls_mgm","certificate", "[default]/etc/opensips/tls/user/user-cert.pem")
- modparam("tls_mgm","private_key", "[default]/etc/opensips/tls/user/user-privkey.pem")
- modparam("tls_mgm","ca_list", "[default]/etc/opensips/tls/user/user-calist.pem")
- modparam("tls_mgm","client_tls_domain_avp", "tls_match_dom")
- #### STUN module
- loadmodule "stun.so"
- # Example of a STUN server within OpenSIPS which is behind NAT
- modparam("stun", "primary_ip", "192.168.3.102 / 11.11.11.11")
- modparam("stun", "primary_port", "42060")
- modparam("stun", "alternate_ip", "192.168.3.102 / 11.11.11.11")
- modparam("stun", "alternate_port","42060")
- ####### Routing Logic ########
- # main request routing logic
- route{
- # initial NAT handling; detect if the request comes from behind a NAT
- # and apply contact fixing
- force_rport();
- # if (nat_uac_test("diff-port-src-via,private-via,diff-ip-src-via,private-contact")) {
- if (nat_uac_test("diff-ip-src-via,private-contact")) {
- if (is_method("REGISTER")) {
- xlog("L_INFO","TEST POINT 0\n");
- xlog("L_INFO","SIP Request Original URI = '$ou'\n");
- xlog("L_INFO","Source Port = '$sp'\n");
- xlog("L_INFO","Contact Instance = '$ct'\n");
- xlog("L_INFO","Original request domain = '$od'\n");
- xlog("L_INFO","Preffered identity domain = '$pd'\n");
- xlog("L_INFO","Domain of destination = '$dd'\n");
- xlog("L_INFO","Destination URI = '$du'\n");
- xlog("L_INFO","Sip request port = '$rp'\n");
- xlog("L_INFO","Sip request domain = '$rd'\n");
- xlog("L_INFO","Sip request URI = '$ru'\n");
- xlog("L_INFO","Sip request uri username = '$rU'\n");
- xlog("L_INFO","Port of original request = '$op'\n");
- xlog("L_INFO","Transport Protocol = '$oP'\n");
- xlog("L_INFO","Transport Protocol = '$rP'\n");
- xlog("L_INFO","Destination URI = '$dP'\n");
- xlog("L_INFO","Destination Port = '$dp'\n");
- xlog("L_INFO","From URI domain = '$fd'\n");
- xlog("L_INFO","From header URI = '$fu'\n");
- xlog("L_INFO","From header URI username = '$fU'\n");
- xlog("L_INFO","Received avp = '$avp(received_nh)'\n");
- xlog("L_INFO","ct fields received = '$ct.fields(received)'\n");
- xlog("L_INFO","TEST POINT 1\n");
- fix_nated_register();
- setbflag("NAT");
- } else {
- xlog("L_INFO","TEST POINT 11\n");
- fix_nated_contact();
- setflag("NAT");
- }
- }
- if (!mf_process_maxfwd_header(10)) {
- xlog("L_INFO","TEST POINT 12\n");
- send_reply(483,"Too Many Hops");
- exit;
- }
- if (has_totag()) {
- xlog("L_INFO","TEST POINT 2\n");
- # handle hop-by-hop ACK (no routing required)
- if ( is_method("ACK") && t_check_trans() ) {
- xlog("L_INFO","TEST POINT 40\n");
- t_relay();
- exit;
- }
- # sequential request within a dialog should
- # take the path determined by record-routing
- if ( !loose_route() ) {
- xlog("L_INFO","TEST POINT 13\n");
- # 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")) {
- xlog("L_INFO","TEST POINT 14\n");
- # do accounting even if the transaction fails
- do_accounting("log","failed");
- }
- if (check_route_param("nat=yes")) ######
- setflag("NAT"); ######
- xlog("L_INFO","TEST POINT 3\n");
- # route it out to whatever destination was set by loose_route()
- # in $du (destination URI).
- route(relay);
- exit;
- }
- # CANCEL processing
- if (is_method("CANCEL")) {
- xlog("L_INFO","TEST POINT 15\n");
- if (t_check_trans())
- t_relay();
- exit;
- }
- # absorb retransmissions, but do not create transaction
- t_check_trans();
- if ( !(is_method("REGISTER") ) ) {
- xlog("L_INFO","TEST POINT 4\n");
- if (is_myself("$fd")) {
- xlog("L_INFO","TEST POINT 16\n");
- } else {
- xlog("L_INFO","TEST POINT 17\n");
- # if caller is not local, then called number must be local
- # AAA commented out testing this is preventing local calls on same network as opensips server - from here
- # This is preventing any external remote outside local network calls from calling into the local network
- # if (!is_myself("$rd")) {
- # send_reply(403,"Relay Forbidden");
- # exit;
- # }
- # AAA commented out testing this is preventing local calls on same network as opensips server - upto here
- }
- }
- # preloaded route checking
- if (loose_route()) {
- xlog("L_INFO","TEST POINT 18\n");
- xlog("L_ERR",
- "Attempt to route with preloaded Route's [$fu/$tu/$ru/$ci]");
- if (!is_method("ACK"))
- xlog("L_INFO","TEST POINT 19\n");
- send_reply(403,"Preload Route denied");
- exit;
- }
- # record routing
- if (!is_method("REGISTER|MESSAGE"))
- xlog("L_INFO","TEST POINT 20\n");
- record_route();
- # account only INVITEs
- if (is_method("INVITE")) {
- xlog("L_INFO","TEST POINT 21\n");
- do_accounting("log");
- }
- if (!is_myself("$rd")) {
- append_hf("P-hint: outbound\r\n");
- xlog("L_INFO","TEST POINT 22\n");
- # if you have some interdomain connections via TLS
- ## CUSTOMIZE IF NEEDED
- ##if ($rd=="tls_domain1.net"
- ## || $rd=="tls_domain2.net"
- ##) {
- ## force_send_socket("tls:127.0.0.1:5061"); # CUSTOMIZE
- ##}
- route(relay);
- }
- # requests for my domain
- if (is_method("PUBLISH|SUBSCRIBE")) {
- xlog("L_INFO","TEST POINT 23\n");
- send_reply(503, "Service Unavailable");
- exit;
- }
- if (is_method("REGISTER")) {
- xlog("L_INFO","TEST POINT 5\n");
- if ($socket_in(proto) == "tcp" || $socket_in(proto) == "tls")
- xlog("L_INFO","TEST POINT 24\n");
- setflag("TCP_PERSISTENT");
- if (isflagset("NAT")) { ######
- xlog("L_INFO","TEST POINT 25\n"); ######
- setbflag("SIP_PING_FLAG"); ######
- } ######
- # store the registration and generate a SIP reply
- if (!save("location"))
- xlog("failed to register AoR $tu\n");
- exit;
- }
- if ($rU==NULL) {
- xlog("L_INFO","TEST POINT 27\n");
- # request with no Username in RURI
- send_reply(484,"Address Incomplete");
- exit;
- }
- # do lookup with method filtering
- if (!lookup("location", "method-filtering")) {
- xlog("L_INFO","TEST POINT 28\n");
- t_reply(404, "Not Found");
- exit;
- }
- if (isbflagset("NAT")) setflag("NAT"); ######
- xlog("L_INFO","TEST POINT 29\n");
- xlog("L_INFO","b flag set\n");
- # when routing via usrloc, log the missed calls also
- do_accounting("log","missed");
- route(relay);
- }
- route[relay] {
- # for INVITEs enable some additional helper routes
- if (is_method("INVITE")) {
- xlog("L_INFO","TEST POINT 6\n");
- if (isflagset("NAT") && has_body("application/sdp")) { ######
- xlog("L_INFO","TEST POINT 30\n");
- # rtpproxy_offer("ro"); ######
- } ######
- t_on_branch("per_branch_ops");
- t_on_reply("handle_nat");
- t_on_failure("missed_call");
- }
- if (isflagset("NAT")) { ######
- xlog("L_INFO","TEST POINT 31\n");
- add_rr_param(";nat=yes"); ######
- } ######
- if (!t_relay()) {
- xlog("L_INFO","TEST POINT 32\n");
- send_reply(500,"Internal Error");
- }
- exit;
- }
- branch_route[per_branch_ops] {
- xlog("L_INFO","TEST POINT 33\n");
- xlog("new branch at $ru\n");
- }
- onreply_route[handle_nat] {
- if (nat_uac_test("private-contact")) ######
- fix_nated_contact(); ######
- xlog("L_INFO","TEST POINT 7\n"); ######
- if ( isflagset("NAT") && has_body("application/sdp") ) ######
- # rtpproxy_answer("ro"); ######
- xlog("L_INFO","TEST POINT 8\n"); ######
- xlog("incoming reply\n");
- }
- failure_route[missed_call] {
- xlog("L_INFO","TEST POINT 34\n");
- if (t_was_cancelled()) {
- xlog("L_INFO","TEST POINT 35\n");
- exit;
- }
- # uncomment the following lines if you want to block client
- # redirect based on 3xx replies.
- ##if (t_check_status("3[0-9][0-9]")) {
- ##t_reply(404,"Not found");
- ## exit;
- ##}
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement