Guest User

Untitled

a guest
Sep 22nd, 2017
46
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #
  2. # $Id$
  3. #
  4. # OpenSIPS residential configuration script
  5. #     by OpenSIPS Solutions <team@opensips-solutions.com>
  6. #
  7. # This script was generated via "make menuconfig", from
  8. #   the "Residential" scenario.
  9. # You can enable / disable more features / functionalities by
  10. #   re-generating the scenario with different options.#
  11. #
  12. # Please refer to the Core CookBook at:
  13. #      http://www.opensips.org/Resources/DocsCookbooks
  14. # for a explanation of possible statements, functions and parameters.
  15. #
  16.  
  17.  
  18. ####### Global Parameters #########
  19.  
  20. log_level=9
  21. log_stderror=no
  22. log_facility=LOG_LOCAL0
  23.  
  24. children=4
  25.  
  26. /* uncomment the following line to enable debugging */
  27. #debug_mode=yes
  28.  
  29. /* uncomment the next line to enable the auto temporary blacklisting of
  30.    not available destinations (default disabled) */
  31. #disable_dns_blacklist=no
  32.  
  33. /* uncomment the next line to enable IPv6 lookup after IPv4 dns
  34.    lookup failures (default disabled) */
  35. #dns_try_ipv6=yes
  36.  
  37. /* comment the next line to enable the auto discovery of local aliases
  38.    based on revers DNS on IPs */
  39. auto_aliases=no
  40.  
  41.  
  42. listen=udp:12.19.17.232:5060   # CUSTOMIZE ME
  43. listen=udp:avoice.com:5060
  44.  
  45.  
  46.  
  47. ####### Modules Section ########
  48.  
  49. #set module path
  50. mpath="/usr/local//lib/opensips/modules/"
  51.  
  52. #### SIGNALING module
  53. loadmodule "signaling.so"
  54. loadmodule "db_mysql.so"
  55.  
  56. #### StateLess module
  57. loadmodule "sl.so"
  58.  
  59. #CDRS
  60. #loadmodule "dialog.so"
  61. #modparam("dialog", "db_mode, 0)
  62.  
  63. #### Transaction Module
  64. loadmodule "tm.so"
  65. modparam("tm", "fr_timeout", 5)
  66. modparam("tm", "fr_inv_timeout", 30)
  67. modparam("tm", "restart_fr_on_each_reply", 0)
  68. modparam("tm", "onreply_avp_mode", 1)
  69.  
  70. #### Record Route Module
  71. loadmodule "rr.so"
  72. /* do not append from tag to the RR (no need for this script) */
  73. modparam("rr", "append_fromtag", 0)
  74.  
  75. #### MAX ForWarD module
  76. loadmodule "maxfwd.so"
  77.  
  78. #### SIP MSG OPerationS module
  79. loadmodule "sipmsgops.so"
  80.  
  81. #### FIFO Management Interface
  82. loadmodule "mi_fifo.so"
  83. modparam("mi_fifo", "fifo_name", "/tmp/opensips_fifo")
  84. modparam("mi_fifo", "fifo_mode", 0666)
  85.  
  86.  
  87. #### URI module
  88. loadmodule "uri.so"
  89. modparam("uri", "use_uri_table", 0)
  90.  
  91. #### USeR LOCation module
  92. loadmodule "usrloc.so"
  93. modparam("usrloc", "nat_bflag", "NAT")
  94. modparam("usrloc", "db_mode",   0)
  95.  
  96. #### REGISTRAR module
  97. loadmodule "registrar.so"
  98.  
  99. /* uncomment the next line not to allow more than 10 contacts per AOR */
  100. #modparam("registrar", "max_contacts", 10)
  101.  
  102. #### ACCounting module
  103. loadmodule "acc.so"
  104. /* what special events should be accounted ? */
  105. modparam("acc", "early_media", 1)
  106. modparam("acc", "report_cancels", 1)
  107. /* by default we do not adjust the direct of the sequential requests.
  108.    if you enable this parameter, be sure the enable "append_fromtag"
  109.    in "rr" module */
  110. modparam("acc", "detect_direction", 0)
  111. modparam("acc", "db_url", "mysql://opensips:jusfrk1@localhost/opensips")
  112.  
  113.  
  114.  
  115.  
  116. ######CDRS
  117. #loadmodule "dialog.so"
  118. #modparam("dialog", "db_mode, 0)
  119.  
  120.  
  121.  
  122. #### UDP protocol
  123. loadmodule "proto_udp.so"
  124.  
  125. ####### Routing Logic ########
  126.  
  127. # main request routing logic
  128.  
  129. route{
  130.     if (!mf_process_maxfwd_header("10")) {
  131.         sl_send_reply("483","Too Many Hops");
  132.         exit;
  133.     }
  134.  
  135.     if (has_totag()) {
  136.         # sequential requests within a dialog should
  137.         # take the path determined by record-routing
  138.         if (loose_route()) {
  139.            
  140.             if (is_method("BYE")) {
  141.                 # do accunting, even if the transaction fails
  142.                 do_accounting("log","failed");
  143.             } else if (is_method("INVITE")) {
  144.                 # even if in most of the cases is useless, do RR for
  145.                 # re-INVITEs alos, as some buggy clients do change route set
  146.                 # during the dialog.
  147.                 record_route();
  148.             }
  149.  
  150.             # route it out to whatever destination was set by loose_route()
  151.             # in $du (destination URI).
  152.             route(relay);
  153.         } else {
  154.            
  155.             if ( is_method("ACK") ) {
  156.                 if ( t_check_trans() ) {
  157.                     # non loose-route, but stateful ACK; must be an ACK after
  158.                     # a 487 or e.g. 404 from upstream server
  159.                     t_relay();
  160.                     exit;
  161.                 } else {
  162.                     # ACK without matching transaction ->
  163.                     # ignore and discard
  164.                     exit;
  165.                 }
  166.             }
  167.             sl_send_reply("404","Not here");
  168.         }
  169.         exit;
  170.     }
  171.  
  172.     # CANCEL processing
  173.     if (is_method("CANCEL"))
  174.     {
  175.         if (t_check_trans())
  176.             t_relay();
  177.         exit;
  178.     }
  179.  
  180.     t_check_trans();
  181.  
  182.     if ( !(is_method("REGISTER")  ) ) {
  183.         if (from_uri==myself)
  184.         {
  185.         } else {
  186.             # if caller is not local, then called number must be local
  187.             if (!uri==myself) {
  188.                 send_reply("403","Rely forbidden");
  189.                 exit;
  190.             }
  191.         }
  192.     }
  193.  
  194.     # preloaded route checking
  195.     if (loose_route()) {
  196.         xlog("L_ERR",
  197.         "Attempt to route with preloaded Route's [$fu/$tu/$ru/$ci]");
  198.         if (!is_method("ACK"))
  199.             sl_send_reply("403","Preload Route denied");
  200.         exit;
  201.     }
  202.  
  203.     # record routing
  204.     if (!is_method("REGISTER|MESSAGE"))
  205.         record_route();
  206.  
  207.     # account only INVITEs
  208.     if (is_method("INVITE")) {
  209.         do_accounting("log", "cdr");
  210.     }
  211.  
  212.     if (!uri==myself) {
  213.         append_hf("P-hint: outbound\r\n");
  214.         route(relay);
  215.     }
  216.  
  217.     # requests for my domain
  218.     if (is_method("PUBLISH|SUBSCRIBE"))
  219.     {
  220.         sl_send_reply("503", "Service Unavailable");
  221.         exit;
  222.     }
  223.  
  224.     if (is_method("REGISTER"))
  225.     {
  226.         if (!save("location"))
  227.             sl_reply_error();
  228.  
  229.         exit;
  230.     }
  231.  
  232.     if ($rU==NULL) {
  233.         # request with no Username in RURI
  234.         sl_send_reply("484","Address Incomplete");
  235.         exit;
  236.     }
  237.  
  238.     # do lookup with method filtering
  239.     if (!lookup("location","m")) {
  240.         t_newtran();
  241.         t_reply("404", "Not Found");
  242.         exit;
  243.     }
  244.  
  245.     # when routing via usrloc, log the missed calls also
  246.     do_accounting("log","missed");
  247.     route(relay);
  248. }
  249.  
  250.  
  251. route[relay] {
  252.     # for INVITEs enable some additional helper routes
  253.     if (is_method("INVITE")) {
  254.         t_on_branch("per_branch_ops");
  255.         t_on_reply("handle_nat");
  256.         t_on_failure("missed_call");
  257.     }
  258.  
  259.     if (!t_relay()) {
  260.         send_reply("500","Internal Error");
  261.     };
  262.     exit;
  263. }
  264.  
  265.  
  266.  
  267.  
  268. branch_route[per_branch_ops] {
  269.     xlog("new branch at $ru\n");
  270. }
  271.  
  272.  
  273. onreply_route[handle_nat] {
  274.    
  275.     xlog("incoming reply\n");
  276. }
  277.  
  278.  
  279. failure_route[missed_call] {
  280.     if (t_was_cancelled()) {
  281.         exit;
  282.     }
  283.  
  284.     # uncomment the following lines if you want to block client
  285.     # redirect based on 3xx replies.
  286.     ##if (t_check_status("3[0-9][0-9]")) {
  287.     ##t_reply("404","Not found");
  288.     ##  exit;
  289.     ##}
  290.  
  291. }
RAW Paste Data