Advertisement
Guest User

Untitled

a guest
Jul 17th, 2013
313
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.72 KB | None | 0 0
  1. ####### Global Parameters #########
  2.  
  3. debug=9
  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=9
  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. auto_aliases=no
  26.  
  27.  
  28. listen=udp:0.0.0.0:5060 # CUSTOMIZE ME
  29.  
  30.  
  31. ####### Modules Section ########
  32.  
  33. #set module path
  34. mpath="/usr/lib64/opensips/modules/"
  35.  
  36. #### SIGNALING module
  37. loadmodule "signaling.so"
  38.  
  39. #### StateLess module
  40. loadmodule "sl.so"
  41.  
  42. #### Transaction Module
  43. loadmodule "tm.so"
  44. modparam("tm", "fr_timer", 5)
  45. modparam("tm", "fr_inv_timer", 30)
  46. modparam("tm", "restart_fr_on_each_reply", 0)
  47. modparam("tm", "onreply_avp_mode", 1)
  48.  
  49. #### Record Route Module
  50. loadmodule "rr.so"
  51. /* do not append from tag to the RR (no need for this script) */
  52. modparam("rr", "append_fromtag", 0)
  53.  
  54. #### MAX ForWarD module
  55. loadmodule "maxfwd.so"
  56.  
  57. #### SIP MSG OPerationS module
  58. loadmodule "sipmsgops.so"
  59.  
  60. #### FIFO Management Interface
  61. loadmodule "mi_fifo.so"
  62. modparam("mi_fifo", "fifo_name", "/tmp/opensips_fifo")
  63. modparam("mi_fifo", "fifo_mode", 0666)
  64.  
  65.  
  66. #### URI module
  67. loadmodule "uri.so"
  68. modparam("uri", "use_uri_table", 0)
  69. modparam("uri", "db_url",
  70. "mysql://willian:tecno2212@10.1.1.249/opensips")
  71.  
  72. loadmodule "xcap.so"
  73. modparam("xcap", "db_url",
  74. "mysql://willian:tecno2212@10.1.1.249/opensips")
  75.  
  76.  
  77.  
  78.  
  79. #### MYSQL module
  80. loadmodule "db_mysql.so"
  81.  
  82.  
  83.  
  84. #### USeR LOCation module
  85. loadmodule "usrloc.so"
  86. modparam("usrloc", "nat_bflag", "NAT")
  87. modparam("usrloc", "db_mode", 2)
  88. modparam("usrloc", "db_url",
  89. "mysql://willian:senha@10.1.1.249/opensips")
  90.  
  91.  
  92. #### REGISTRAR module
  93. loadmodule "registrar.so"
  94. modparam("registrar", "tcp_persistent_flag", "TCP_PERSISTENT")
  95. modparam("registrar", "received_avp", "$avp(received_nh)")
  96. /* uncomment the next line not to allow more than 10 contacts per AOR */
  97. #modparam("registrar", "max_contacts", 10)
  98.  
  99. #### ACCounting module
  100. loadmodule "acc.so"
  101. /* what special events should be accounted ? */
  102. modparam("acc", "early_media", 0)
  103. modparam("acc", "report_cancels", 0)
  104. /* by default we do not adjust the direct of the sequential requests.
  105. if you enable this parameter, be sure the enable "append_fromtag"
  106. in "rr" module */
  107. modparam("acc", "detect_direction", 0)
  108. modparam("acc", "failed_transaction_flag", "ACC_FAILED")
  109. /* account triggers (flags) */
  110. modparam("acc", "db_flag", "ACC_DO")
  111. modparam("acc", "db_missed_flag", "ACC_MISSED")
  112. modparam("acc", "db_url",
  113. "mysql://willian:senha@10.1.1.249/opensips")
  114.  
  115.  
  116. #### AUTHentication modules
  117. loadmodule "auth.so"
  118. loadmodule "auth_db.so"
  119. modparam("auth_db", "calculate_ha1", yes)
  120. modparam("auth_db", "password_column", "password")
  121. modparam("auth_db", "db_url",
  122. "mysql://willian:tecno2212@10.1.1.249/opensips")
  123. modparam("auth_db", "load_credentials", "")
  124.  
  125.  
  126.  
  127.  
  128. #### DOMAIN module
  129. loadmodule "domain.so"
  130. modparam("domain", "db_url",
  131. "mysql://willian:senha@10.1.1.249/opensips")
  132.  
  133. modparam("domain", "db_mode", 1) # Use caching
  134. modparam("auth_db|usrloc|uri", "use_domain", 1)
  135.  
  136.  
  137. #### PRESENCE modules
  138. loadmodule "presence.so"
  139. loadmodule "presence_xml.so"
  140. modparam("presence", "db_url",
  141. "mysql://willian:senha@10.1.1.249/opensips")
  142. modparam("presence_xml", "force_active", 1)
  143. modparam("presence", "server_address", "sip:MY_EXT_IP:5060") # CUSTOMIZE ME
  144.  
  145.  
  146. #### DIALOG module
  147. loadmodule "dialog.so"
  148. modparam("dialog", "dlg_match_mode", 1)
  149. modparam("dialog", "default_timeout", 21600) # 6 hours timeout
  150. modparam("dialog", "db_mode", 2)
  151. modparam("dialog", "db_url",
  152. "mysql://willian:senha@10.1.1.249/opensips")
  153.  
  154.  
  155. #### NAT modules
  156. loadmodule "nathelper.so"
  157. modparam("nathelper", "natping_interval", 10)
  158. modparam("nathelper", "ping_nated_only", 1)
  159. modparam("nathelper", "received_avp", "$avp(received_nh)")
  160.  
  161. loadmodule "rtpproxy.so"
  162. modparam("rtpproxy", "rtpproxy_sock", "udp:localhost:7890") # CUSTOMIZE ME
  163.  
  164.  
  165.  
  166.  
  167.  
  168.  
  169.  
  170.  
  171. ####### Routing Logic ########
  172.  
  173. # main request routing logic
  174.  
  175. route{
  176. force_rport();
  177. if (nat_uac_test("23")) {
  178. if (is_method("REGISTER")) {
  179. fix_nated_register();
  180. setbflag(NAT);
  181. } else {
  182. fix_nated_contact();
  183. setflag(NAT);
  184. }
  185. }
  186.  
  187.  
  188. if (!mf_process_maxfwd_header("10")) {
  189. sl_send_reply("483","Too Many Hops");
  190. exit;
  191. }
  192.  
  193. if (has_totag()) {
  194. # sequential request withing a dialog should
  195. # take the path determined by record-routing
  196. if (loose_route()) {
  197.  
  198. # validate the sequential request against dialog
  199. if ( $DLG_status!=NULL && !validate_dialog() ) {
  200. xlog("In-Dialog $rm from $si (callid=$ci) is not valid according to dialog\n");
  201. ## exit;
  202. }
  203.  
  204. if (is_method("BYE")) {
  205. setflag(ACC_DO); # do accounting ...
  206. setflag(ACC_FAILED); # ... even if the transaction fails
  207. } else if (is_method("INVITE")) {
  208. # even if in most of the cases is useless, do RR for
  209. # re-INVITEs alos, as some buggy clients do change route set
  210. # during the dialog.
  211. record_route();
  212. }
  213.  
  214. if (check_route_param("nat=yes"))
  215. setflag(NAT);
  216.  
  217. # route it out to whatever destination was set by loose_route()
  218. # in $du (destination URI).
  219. route(relay);
  220. } else {
  221. if (is_method("SUBSCRIBE") && $rd == "127.0.0.1:5060") { # CUSTOMIZE ME
  222. # in-dialog subscribe requests
  223. route(handle_presence);
  224. exit;
  225. }
  226. if ( is_method("ACK") ) {
  227. if ( t_check_trans() ) {
  228. # non loose-route, but stateful ACK; must be an ACK after
  229. # a 487 or e.g. 404 from upstream server
  230. t_relay();
  231. exit;
  232. } else {
  233. # ACK without matching transaction ->
  234. # ignore and discard
  235. exit;
  236. }
  237. }
  238. sl_send_reply("404","Not here");
  239. }
  240. exit;
  241. }
  242.  
  243. # CANCEL processing
  244. if (is_method("CANCEL"))
  245. {
  246. if (t_check_trans())
  247. t_relay();
  248. exit;
  249. }
  250.  
  251. t_check_trans();
  252.  
  253. if ( !(is_method("REGISTER") && is_from_local() ) ) {
  254.  
  255.  
  256. # authenticate if from local subscriber
  257. # authenticate all initial non-REGISTER request that pretend to be
  258. # generated by local subscriber (domain from FROM URI is local)
  259. if (!proxy_authorize("", "subscriber")) {
  260. proxy_challenge("", "0");
  261. exit;
  262. }
  263. if (!db_check_from()) {
  264. sl_send_reply("403","Forbidden auth ID");
  265. exit;
  266. }
  267.  
  268. consume_credentials();
  269. # caller authenticated
  270.  
  271. } else {
  272. # if caller is not local, then called number must be local
  273.  
  274. if (!is_uri_host_local()) {
  275. send_reply("403","Rely forbidden");
  276. exit;
  277. }
  278.  
  279. }
  280.  
  281. # preloaded route checking
  282. if (loose_route()) {
  283. xlog("L_ERR",
  284. "Attempt to route with preloaded Route's [$fu/$tu/$ru/$ci]");
  285. if (!is_method("ACK"))
  286. sl_send_reply("403","Preload Route denied");
  287. exit;
  288. }
  289.  
  290. # record routing
  291. if (!is_method("REGISTER|MESSAGE"))
  292. record_route();
  293.  
  294. # account only INVITEs
  295. if (is_method("INVITE")) {
  296.  
  297. # create dialog with timeout
  298. if ( !create_dialog("B") ) {
  299. send_reply("500","Internal Server Error");
  300. exit;
  301. }
  302.  
  303. setflag(ACC_DO); # do accounting
  304. }
  305.  
  306.  
  307. if (!is_uri_host_local()) {
  308. append_hf("P-hint: outbound\r\n");
  309.  
  310. route(relay);
  311. }
  312.  
  313. # requests for my domain
  314.  
  315. if( is_method("PUBLISH|SUBSCRIBE"))
  316. route(handle_presence);
  317.  
  318. if (is_method("REGISTER"))
  319. {
  320.  
  321. # authenticate the REGISTER requests
  322. if (!www_authorize("", "subscriber"))
  323. {
  324. www_challenge("", "0");
  325. exit;
  326. }
  327.  
  328. if (!db_check_to())
  329. {
  330. sl_send_reply("403","Forbidden auth ID");
  331. exit;
  332. }
  333.  
  334. if ( 0 ) setflag(TCP_PERSISTENT);
  335.  
  336. if (!save("location"))
  337. sl_reply_error();
  338.  
  339. exit;
  340. }
  341.  
  342. if ($rU==NULL) {
  343. # request with no Username in RURI
  344. sl_send_reply("484","Address Incomplete");
  345. exit;
  346. }
  347.  
  348.  
  349.  
  350.  
  351.  
  352.  
  353. if ($rU=~"^\0+") {
  354.  
  355. $rd="MY_ASTERISK_SERVER";
  356. $rp=5060;
  357.  
  358. route(relay);
  359. exit;
  360. }
  361.  
  362.  
  363. # do lookup with method filtering
  364. if (!lookup("location","m")) {
  365. if (!db_does_uri_exist()) {
  366. send_reply("420","Bad Extension");
  367. exit;
  368. }
  369.  
  370. t_newtran();
  371. t_reply("404", "Not Found");
  372. exit;
  373. }
  374.  
  375. if (isbflagset(NAT)) setflag(NAT);
  376.  
  377. # when routing via usrloc, log the missed calls also
  378. setflag(ACC_MISSED);
  379. route(relay);
  380. }
  381.  
  382.  
  383. route[relay] {
  384. # for INVITEs enable some additional helper routes
  385. if (is_method("INVITE")) {
  386.  
  387. if (isflagset(NAT)) {
  388. rtpproxy_offer("ro");
  389. }
  390.  
  391. t_on_branch("per_branch_ops");
  392. t_on_reply("handle_nat");
  393. t_on_failure("missed_call");
  394. }
  395.  
  396. if (isflagset(NAT)) {
  397. add_rr_param(";nat=yes");
  398. }
  399.  
  400. if (!t_relay()) {
  401. send_reply("500","Internal Error");
  402. };
  403. exit;
  404. }
  405.  
  406.  
  407. # Presence route
  408. route[handle_presence]
  409. {
  410. if (!t_newtran())
  411. {
  412. sl_reply_error();
  413. exit;
  414. }
  415.  
  416. if(is_method("PUBLISH"))
  417. {
  418. handle_publish();
  419. }
  420. else
  421. if( is_method("SUBSCRIBE"))
  422. {
  423. handle_subscribe();
  424. }
  425.  
  426. exit;
  427. }
  428.  
  429.  
  430. branch_route[per_branch_ops] {
  431. xlog("new branch at $ru\n");
  432. }
  433.  
  434.  
  435. onreply_route[handle_nat] {
  436. if (nat_uac_test("1"))
  437. fix_nated_contact();
  438. if ( isflagset(NAT) )
  439. rtpproxy_answer("ro");
  440. xlog("incoming reply\n");
  441. }
  442.  
  443.  
  444. failure_route[missed_call] {
  445. if (t_was_cancelled()) {
  446. exit;
  447. }
  448.  
  449. # uncomment the following lines if you want to block client
  450. # redirect based on 3xx replies.
  451. ##if (t_check_status("3[0-9][0-9]")) {
  452. ##t_reply("404","Not found");
  453. ## exit;
  454. ##}
  455.  
  456.  
  457. }
  458.  
  459.  
  460.  
  461. local_route {
  462. if (is_method("BYE") && $DLG_dir=="UPSTREAM") {
  463.  
  464. acc_db_request("200 Dialog Timeout", "acc");
  465.  
  466. }
  467. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement