Advertisement
Guest User

Untitled

a guest
Aug 5th, 2015
359
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.85 KB | None | 0 0
  1. ####### Global Parameters #########
  2.  
  3. debug=6
  4. log_stderror=no
  5. log_facility=LOG_LOCAL0
  6.  
  7. fork=yes
  8. children=4
  9.  
  10. /* uncomment the following lines to enable debugging */
  11. #debug=6
  12. #fork=no
  13. #log_stderror=yes
  14.  
  15. /* uncomment the next line to enable the auto temporary blacklisting of
  16. not available destinations (default disabled) */
  17. #disable_dns_blacklist=no
  18.  
  19. /* uncomment the next line to enable IPv6 lookup after IPv4 dns
  20. lookup failures (default disabled) */
  21. #dns_try_ipv6=yes
  22.  
  23. /* comment the next line to enable the auto discovery of local aliases
  24. based on revers DNS on IPs */
  25.  
  26. auto_aliases=no
  27.  
  28. alias="domain.com"
  29.  
  30. listen=udp:87.71.230.41:5060 # CUSTOMIZE ME
  31.  
  32. disable_tcp=yes
  33.  
  34. disable_tls=yes
  35.  
  36. ####### Modules Section ########
  37.  
  38. #set module path
  39. mpath="/usr/local/lib64/opensips/modules/"
  40.  
  41. #### SIGNALING module
  42. loadmodule "signaling.so"
  43.  
  44. #### StateLess module
  45. loadmodule "sl.so"
  46.  
  47. #### Transaction Module
  48. loadmodule "tm.so"
  49. modparam("tm", "fr_timeout", 5)
  50. modparam("tm", "fr_inv_timeout", 30)
  51. modparam("tm", "restart_fr_on_each_reply", 0)
  52. modparam("tm", "onreply_avp_mode", 1)
  53.  
  54. #### Record Route Module
  55. loadmodule "rr.so"
  56. /* do not append from tag to the RR (no need for this script) */
  57. modparam("rr", "append_fromtag", 0)
  58.  
  59. #### MAX ForWarD module
  60. loadmodule "maxfwd.so"
  61.  
  62. #### SIP MSG OPerationS module
  63. loadmodule "sipmsgops.so"
  64.  
  65. #### FIFO Management Interface
  66. loadmodule "mi_fifo.so"
  67. modparam("mi_fifo", "fifo_name", "/tmp/opensips_fifo")
  68. modparam("mi_fifo", "fifo_mode", 0666)
  69.  
  70.  
  71. #### URI module
  72. loadmodule "uri.so"
  73. modparam("uri", "use_uri_table", 0)
  74.  
  75.  
  76.  
  77.  
  78.  
  79.  
  80.  
  81. #### MYSQL module
  82. loadmodule "db_mysql.so"
  83.  
  84.  
  85.  
  86. #### USeR LOCation module
  87. loadmodule "usrloc.so"
  88. modparam("usrloc", "nat_bflag", "NAT")
  89. modparam("usrloc", "db_mode", 2)
  90. modparam("usrloc", "db_url",
  91. "mysql://root:password@87.71.230.41/name") # CUSTOMIZE ME
  92.  
  93.  
  94. #### REGISTRAR module
  95. loadmodule "registrar.so"
  96. modparam("registrar", "tcp_persistent_flag", "TCP_PERSISTENT")
  97. modparam("registrar", "received_avp", "$avp(received_nh)")
  98. /* uncomment the next line not to allow more than 10 contacts per AOR */
  99. #modparam("registrar", "max_contacts", 10)
  100.  
  101. #### ACCounting module
  102. loadmodule "acc.so"
  103. /* what special events should be accounted ? */
  104. modparam("acc", "early_media", 0)
  105. modparam("acc", "report_cancels", 0)
  106. /* by default we do not adjust the direct of the sequential requests.
  107. if you enable this parameter, be sure the enable "append_fromtag"
  108. in "rr" module */
  109. modparam("acc", "detect_direction", 0)
  110. modparam("acc", "failed_transaction_flag", "ACC_FAILED")
  111. /* account triggers (flags) */
  112. modparam("acc", "db_flag", "ACC_DO")
  113. modparam("acc", "db_missed_flag", "ACC_MISSED")
  114. modparam("acc", "db_url",
  115. "mysql://root:password@87.71.230.41/name") # CUSTOMIZE ME
  116.  
  117.  
  118.  
  119.  
  120. #### ALIAS module
  121. loadmodule "alias_db.so"
  122. modparam("alias_db", "db_url",
  123. "mysql://root:password@87.71.230.41/name") # CUSTOMIZE ME
  124.  
  125.  
  126.  
  127.  
  128.  
  129.  
  130. #### DIALOG module
  131. loadmodule "dialog.so"
  132. modparam("dialog", "dlg_match_mode", 1)
  133. modparam("dialog", "default_timeout", 21600) # 6 hours timeout
  134. modparam("dialog", "db_mode", 2)
  135. modparam("dialog", "db_url",
  136. "mysql://root:password@87.71.230.41/name") # CUSTOMIZE ME
  137.  
  138.  
  139. #### NAT modules
  140. loadmodule "nathelper.so"
  141. modparam("nathelper", "natping_interval", 10)
  142. modparam("nathelper", "ping_nated_only", 1)
  143. modparam("nathelper", "received_avp", "$avp(received_nh)")
  144.  
  145. loadmodule "rtpproxy.so"
  146. modparam("rtpproxy", "rtpproxy_sock", "udp:87.71.230.41:7890") # CUSTOMIZE ME
  147.  
  148.  
  149.  
  150.  
  151.  
  152.  
  153.  
  154.  
  155. ####### Routing Logic ########
  156.  
  157. # main request routing logic
  158.  
  159. route{
  160. force_rport();
  161. if (nat_uac_test("23")) {
  162. if (is_method("REGISTER")) {
  163. fix_nated_register();
  164. setbflag(NAT);
  165. } else {
  166. fix_nated_contact();
  167. setflag(NAT);
  168. }
  169. }
  170.  
  171.  
  172. if (!mf_process_maxfwd_header("10")) {
  173. sl_send_reply("483","Too Many Hops");
  174. exit;
  175. }
  176.  
  177. if (has_totag()) {
  178. # sequential request withing a dialog should
  179. # take the path determined by record-routing
  180. if (loose_route()) {
  181.  
  182. # validate the sequential request against dialog
  183. if ( $DLG_status!=NULL && !validate_dialog() ) {
  184. xlog("In-Dialog $rm from $si (callid=$ci) is not valid according to dialog\n");
  185. ## exit;
  186. }
  187.  
  188. if (is_method("BYE")) {
  189. setflag(ACC_DO); # do accounting ...
  190. setflag(ACC_FAILED); # ... even if the transaction fails
  191. } else if (is_method("INVITE")) {
  192. # even if in most of the cases is useless, do RR for
  193. # re-INVITEs alos, as some buggy clients do change route set
  194. # during the dialog.
  195. record_route();
  196. }
  197.  
  198. if (check_route_param("nat=yes"))
  199. setflag(NAT);
  200.  
  201. # route it out to whatever destination was set by loose_route()
  202. # in $du (destination URI).
  203. route(relay);
  204. } else {
  205.  
  206. if ( is_method("ACK") ) {
  207. if ( t_check_trans() ) {
  208. # non loose-route, but stateful ACK; must be an ACK after
  209. # a 487 or e.g. 404 from upstream server
  210. t_relay();
  211. exit;
  212. } else {
  213. # ACK without matching transaction ->
  214. # ignore and discard
  215. exit;
  216. }
  217. }
  218. sl_send_reply("404","Not here");
  219. }
  220. exit;
  221. }
  222.  
  223. # CANCEL processing
  224. if (is_method("CANCEL"))
  225. {
  226. if (t_check_trans())
  227. t_relay();
  228. exit;
  229. }
  230.  
  231. t_check_trans();
  232.  
  233. if ( !(is_method("REGISTER") ) ) {
  234.  
  235. if (from_uri==myself)
  236.  
  237. {
  238.  
  239. } else {
  240. # if caller is not local, then called number must be local
  241.  
  242. if (!uri==myself) {
  243. send_reply("403","Rely forbidden");
  244. exit;
  245. }
  246. }
  247.  
  248. }
  249.  
  250. # preloaded route checking
  251. if (loose_route()) {
  252. xlog("L_ERR",
  253. "Attempt to route with preloaded Route's [$fu/$tu/$ru/$ci]");
  254. if (!is_method("ACK"))
  255. sl_send_reply("403","Preload Route denied");
  256. exit;
  257. }
  258.  
  259. # record routing
  260. if (!is_method("REGISTER|MESSAGE"))
  261. record_route();
  262.  
  263. # account only INVITEs
  264. if (is_method("INVITE")) {
  265.  
  266. # create dialog with timeout
  267. if ( !create_dialog("B") ) {
  268. send_reply("500","Internal Server Error");
  269. exit;
  270. }
  271.  
  272. setflag(ACC_DO); # do accounting
  273. }
  274.  
  275.  
  276. if (!uri==myself) {
  277. append_hf("P-hint: outbound\r\n");
  278.  
  279. route(relay);
  280. }
  281.  
  282. # requests for my domain
  283.  
  284. if (is_method("PUBLISH|SUBSCRIBE"))
  285. {
  286. sl_send_reply("503", "Service Unavailable");
  287. exit;
  288. }
  289.  
  290. if (is_method("REGISTER"))
  291. {
  292.  
  293.  
  294. if ( 0 ) setflag(TCP_PERSISTENT);
  295.  
  296. if (!save("location"))
  297. sl_reply_error();
  298.  
  299. exit;
  300. }
  301.  
  302. if ($rU==NULL) {
  303. # request with no Username in RURI
  304. sl_send_reply("484","Address Incomplete");
  305. exit;
  306. }
  307.  
  308.  
  309. # apply DB based aliases
  310. alias_db_lookup("dbaliases");
  311.  
  312.  
  313.  
  314.  
  315.  
  316. # do lookup with method filtering
  317. if (!lookup("location","m")) {
  318.  
  319.  
  320. t_newtran();
  321. t_reply("404", "Not Found");
  322. exit;
  323. }
  324.  
  325. if (isbflagset(NAT)) setflag(NAT);
  326.  
  327. # when routing via usrloc, log the missed calls also
  328. setflag(ACC_MISSED);
  329. route(relay);
  330. }
  331.  
  332.  
  333. route[relay] {
  334. # for INVITEs enable some additional helper routes
  335. if (is_method("INVITE")) {
  336.  
  337. if (isflagset(NAT)) {
  338. rtpproxy_offer("ro");
  339. }
  340.  
  341. t_on_branch("per_branch_ops");
  342. t_on_reply("handle_nat");
  343. t_on_failure("missed_call");
  344. }
  345.  
  346. if (isflagset(NAT)) {
  347. add_rr_param(";nat=yes");
  348. }
  349.  
  350. if (!t_relay()) {
  351. send_reply("500","Internal Error");
  352. };
  353. exit;
  354. }
  355.  
  356.  
  357.  
  358.  
  359. branch_route[per_branch_ops] {
  360. xlog("new branch at $ru\n");
  361. }
  362.  
  363.  
  364. onreply_route[handle_nat] {
  365. if (nat_uac_test("1"))
  366. fix_nated_contact();
  367. if ( isflagset(NAT) )
  368. rtpproxy_answer("ro");
  369. xlog("incoming reply\n");
  370. }
  371.  
  372.  
  373. failure_route[missed_call] {
  374. if (t_was_cancelled()) {
  375. exit;
  376. }
  377.  
  378. # uncomment the following lines if you want to block client
  379. # redirect based on 3xx replies.
  380. ##if (t_check_status("3[0-9][0-9]")) {
  381. ##t_reply("404","Not found");
  382. ## exit;
  383. ##}
  384.  
  385.  
  386. }
  387.  
  388.  
  389.  
  390. local_route {
  391. if (is_method("BYE") && $DLG_dir=="UPSTREAM") {
  392.  
  393. acc_db_request("200 Dialog Timeout", "acc");
  394.  
  395. }
  396. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement