Guest User

Untitled

a guest
May 27th, 2018
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.05 KB | None | 0 0
  1. debug=6
  2. log_stderror=no
  3. log_facility=LOG_LOCAL0
  4.  
  5. fork=yes
  6. children=4
  7.  
  8. /* uncomment the following lines to enable debugging */
  9. #debug=6
  10. #log_stderror=yes
  11.  
  12. /* uncomment the next line to disable TCP (default on) */
  13. #disable_tcp=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. /* uncomment the next line to disable the auto discovery of local aliases
  24. based on revers DNS on IPs (default on) */
  25. #auto_aliases=no
  26.  
  27. /* uncomment the following lines to enable TLS support (default off) */
  28. #disable_tls = no
  29. #listen = tls:your_IP:5061
  30. #tls_verify_server = 1
  31. #tls_verify_client = 1
  32. #tls_require_client_certificate = 0
  33. #tls_method = TLSv1
  34. #tls_certificate = "//etc/opensips/tls/user/user-cert.pem"
  35. #tls_private_key = "//etc/opensips/tls/user/user-privkey.pem"
  36. #tls_ca_list = "//etc/opensips/tls/user/user-calist.pem"
  37.  
  38. /* default db_url to be used by modules requiring DB connection;
  39. uncomment it if you use any module requiring DB connectivity */
  40. db_default_url="mysql://xxxxx:xxxxx@localhost/opensips"
  41.  
  42.  
  43. /*
  44. INTERFACE BINDING
  45. */
  46. port=5060
  47. listen=udp:10.195.100.5:5060
  48. listen=tcp:10.195.100.5:5061
  49. listen=tls:10.195.100.5:5062
  50.  
  51.  
  52. ####### Modules Section ########
  53.  
  54. #set module path
  55. mpath="//lib/opensips/modules/"
  56.  
  57. loadmodule "db_mysql.so"
  58. loadmodule "signaling.so"
  59. loadmodule "sl.so"
  60. loadmodule "tm.so"
  61. loadmodule "rr.so"
  62. loadmodule "maxfwd.so"
  63. loadmodule "usrloc.so"
  64. loadmodule "registrar.so"
  65. loadmodule "textops.so"
  66. loadmodule "mi_fifo.so"
  67. loadmodule "uri.so"
  68. loadmodule "acc.so"
  69. loadmodule "domain.so"
  70. loadmodule "drouting.so"
  71.  
  72. # ----------------- setting module-specific parameters ---------------
  73.  
  74.  
  75. # ----- mi_fifo params -----
  76. modparam("mi_fifo", "fifo_name", "/tmp/opensips_fifo")
  77.  
  78.  
  79. # ----- rr params -----
  80. modparam("rr", "append_fromtag", 0)
  81.  
  82.  
  83. # ----- usrloc params -----
  84. modparam("usrloc", "db_mode", 0)
  85. modparam("usrloc", "db_mode", 2)
  86. modparam("usrloc", "db_url", "mysql://xxxxx:xxxxx@localhost/opensips")
  87.  
  88.  
  89. # ----- uri params -----
  90. modparam("uri", "use_uri_table", 0)
  91.  
  92.  
  93. # ----- acc params -----
  94. modparam("acc", "early_media", 1)
  95. modparam("acc", "report_cancels", 1)
  96. modparam("acc", "detect_direction", 0)
  97. modparam("acc", "failed_transaction_flag", 3)
  98. modparam("acc", "log_flag", 1)
  99. modparam("acc", "log_missed_flag", 2)
  100. modparam("acc", "db_flag", 1)
  101. modparam("acc", "db_missed_flag", 2)
  102.  
  103.  
  104. # ----- domain params -----
  105. modparam("domain", "db_url", "mysql://xxxxx:xxxxx@localhost/opensips")
  106. modparam("domain", "db_mode", 1) # Use caching
  107.  
  108.  
  109. # ----- multi-module params -----
  110. modparam("auth_db|usrloc|uri", "use_domain", 1)
  111.  
  112.  
  113. # ----- drouting params -----
  114. modparam("drouting", "db_url", "mysql://xxxxx:xxxxx@localhost/opensips")
  115. modparam("drouting", "use_domain", 1)
  116. modparam("drouting", "probing_interval", 60)
  117. modparam("drouting", "probing_from", "sip:pinger@10.195.100.5")
  118. modparam("drouting", "probing_method", "OPTIONS")
  119. modparam("drouting", "probing_reply_codes", "501, 403, 404")
  120.  
  121. ####### Routing Logic ########
  122.  
  123.  
  124. # main request routing logic
  125.  
  126. route{
  127. if (!mf_process_maxfwd_header("10")) {
  128. xlog("DEBUG: Failed the loop test!\n");
  129. sl_send_reply("483","Too Many Hops");
  130. exit;
  131. }
  132.  
  133. if (is_method("INVITE")) {
  134. xlog("DEBUG: INVITE message...\n");
  135. setflag(1); # do accounting
  136. record_route();
  137. route(4); # Call our dynamic route.
  138. }
  139.  
  140. if (has_totag()) {
  141. xlog("DEBUG: HAS TOTAG...\n");
  142.  
  143. # if this is a sequential request, use the recorded route
  144. if(loose_route()) {
  145. if (is_method("BYE")) {
  146. setflag(1); # do accounting
  147. setflag(3); # ... even if the transaction fails
  148. } else if (is_method("INVITE"))
  149. {
  150. setflag(1); # do accounting
  151. record_route(); # record the route
  152. route(4); # route it dynamically
  153. }
  154.  
  155. # If it's neither an INVITE or BYE, use the recorded route in loose_route()
  156. route(1);
  157. } else {
  158. # if it's an ACK message
  159. if (is_method("ACK")) {
  160. # check to see if it's a transaction we know about
  161. if (t_check_trans()) {
  162. # it's not loosely routed, but it is stateful -- forward it
  163. t_relay();
  164. exit; # we're done
  165. } else {
  166. # if we don't know which transaction the ACK is to, discard
  167. exit; # we're done
  168. }
  169. }
  170.  
  171. # if it isn't loosely routed, and it isn't an ACK
  172. sl_send_reply("404", "Not here");
  173. }
  174.  
  175. # if we get here, we don't know what the heck it is, discard
  176. exit;
  177. }
  178.  
  179. #initial requests
  180.  
  181. # CANCEL processing
  182. if (is_method("CANCEL"))
  183. {
  184. xlog("DEBUG: Message Canceled!\n");
  185. if (t_check_trans())
  186. t_relay();
  187. exit;
  188. }
  189.  
  190. t_check_trans();
  191.  
  192. # preloaded route checking
  193. if (loose_route()) {
  194. xlog("L_ERR",
  195. "Attempt to route with preloaded Route's [$fu/$tu/$ru/$ci]");
  196. if (!is_method("ACK"))
  197. sl_send_reply("403","Preload Route denied");
  198. exit;
  199. }
  200.  
  201. # record routing
  202. if (!is_method("REGISTER|MESSAGE"))
  203. record_route();
  204.  
  205. # outbound
  206. if (!is_uri_host_local())
  207. {
  208. xlog("DEBUG: Hit the if !is_uri_host_local statement!\n");
  209. append_hf("P-hint: outbound\r\n");
  210.  
  211. route(1);
  212. }
  213.  
  214.  
  215. if (is_method("PUBLISH"))
  216. {
  217. sl_send_reply("503", "Service Unavailable");
  218. exit;
  219. }
  220.  
  221.  
  222. if (is_method("REGISTER"))
  223. {
  224.  
  225. if (!save("location"))
  226. sl_reply_error();
  227.  
  228. exit;
  229. }
  230.  
  231. if ($rU==NULL) {
  232. # request with no Username in RURI
  233. sl_send_reply("484","Address Incomplete");
  234. exit;
  235. }
  236.  
  237.  
  238. # do lookup with method filtering
  239. if (!lookup("location","m")) {
  240. switch ($retcode) {
  241. case -1:
  242. case -3:
  243. t_newtran();
  244. t_reply("404", "Not Found");
  245. exit;
  246. case -2:
  247. sl_send_reply("405", "Method Not Allowed");
  248. exit;
  249. }
  250. }
  251.  
  252. # when routing via usrloc, log the missed calls also
  253. setflag(2);
  254.  
  255. route(1);
  256. }
  257.  
  258.  
  259. route[1] {
  260. xlog("DEBUG: >>>BEGIN: route[1] Block -->\n");
  261. # for INVITEs enable some additional helper routes
  262. if (is_method("INVITE")) {
  263. t_on_branch("2");
  264. t_on_reply("2");
  265. t_on_failure("1");
  266. }
  267.  
  268. if (!t_relay()) {
  269. xlog("DEBUG: route[1] Block: Failed to relay-->!\n");
  270. sl_reply_error();
  271. };
  272. exit;
  273. }
  274.  
  275.  
  276. # drouting route
  277. route[4] {
  278. #log that we're trying dynamically at least
  279. xlog("DEBUG: >>>BEGIN: route[4] Block -->\n");
  280. if (!do_routing("0")) {
  281. xlog("!do_routing: No Rules matching the URI\n");
  282. send_reply("503", "No Rules matching the URI");
  283. exit;
  284. }
  285.  
  286. if (is_method("INVITE")) {
  287. t_on_failure("4");
  288. }
  289.  
  290. route(1);
  291. }
  292.  
  293.  
  294. branch_route[2] {
  295. xlog("new branch at $ru\n");
  296. }
  297.  
  298.  
  299. onreply_route[2] {
  300. xlog("incoming reply\n");
  301.  
  302. }
  303.  
  304.  
  305. failure_route[1] {
  306. xlog("DEBUG: failure_route[1] Block-->!\n");
  307. if (t_was_cancelled()) {
  308. exit;
  309. }
  310. }
  311.  
  312. failure_route[4] {
  313. xlog("DEBUG: Hit the DRouting failure route!\n");
  314. if (t_was_cancelled()) {
  315. exit;
  316. }
  317. if (t_check_status("[34][0-9][0-9]")) {
  318. exit;
  319. }
  320.  
  321. if (use_next_gw()) {
  322. t_relay();
  323. exit;
  324. } else {
  325. t_reply ("503", "Service not available");
  326. exit;
  327. }
  328. }
Add Comment
Please, Sign In to add comment