rafaelsnsa

Untitled

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