Advertisement
Guest User

opensips

a guest
Dec 16th, 2013
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.84 KB | None | 0 0
  1. #
  2. # $Id: opensips.cfg 9742 2013-02-05 10:24:48Z vladut-paiu $
  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.  
  21. debug=3
  22. log_stderror=no
  23. log_facility=LOG_LOCAL0
  24.  
  25. fork=yes
  26. children=4
  27.  
  28. /* uncomment the following lines to enable debugging */
  29. #debug=6
  30. #fork=no
  31. #log_stderror=yes
  32.  
  33. /* uncomment the next line to enable the auto temporary blacklisting of
  34. not available destinations (default disabled) */
  35. #disable_dns_blacklist=no
  36.  
  37. /* uncomment the next line to enable IPv6 lookup after IPv4 dns
  38. lookup failures (default disabled) */
  39. #dns_try_ipv6=yes
  40.  
  41. /* comment the next line to enable the auto discovery of local aliases
  42. based on revers DNS on IPs */
  43. auto_aliases=no
  44.  
  45.  
  46. listen=udp:10.10.10.123:5060 # CUSTOMIZE ME
  47.  
  48.  
  49. disable_tcp=yes
  50.  
  51. disable_tls=yes
  52.  
  53. ################################
  54. ####### Modules Section ########
  55. ################################
  56.  
  57. #set module path
  58. mpath="/usr/local/server/pbx//lib64/opensips/modules/"
  59.  
  60. #### SIGNALING module
  61. loadmodule "signaling.so"
  62.  
  63. #### StateLess module
  64. loadmodule "sl.so"
  65.  
  66. #### Transaction Module
  67. loadmodule "tm.so"
  68. modparam("tm", "fr_timer", 5)
  69. modparam("tm", "fr_inv_timer", 30)
  70. modparam("tm", "restart_fr_on_each_reply", 0)
  71. modparam("tm", "onreply_avp_mode", 1)
  72.  
  73. #### Record Route Module
  74. loadmodule "rr.so"
  75. /* do not append from tag to the RR (no need for this script) */
  76. modparam("rr", "append_fromtag", 0)
  77.  
  78. #### MAX ForWarD module
  79. loadmodule "maxfwd.so"
  80.  
  81. #### SIP MSG OPerationS module
  82. loadmodule "sipmsgops.so"
  83.  
  84. #### FIFO Management Interface
  85. loadmodule "mi_fifo.so"
  86. modparam("mi_fifo", "fifo_name", "/tmp/opensips_fifo")
  87. modparam("mi_fifo", "fifo_mode", 0666)
  88.  
  89. #### URI module
  90. loadmodule "uri.so"
  91. modparam("uri", "use_uri_table", 0)
  92.  
  93. #### USeR LOCation module
  94. loadmodule "usrloc.so"
  95. modparam("usrloc", "nat_bflag", "NAT")
  96. modparam("usrloc", "db_mode", 0)
  97.  
  98. #### REGISTRAR module
  99. loadmodule "registrar.so"
  100. modparam("registrar", "tcp_persistent_flag", "TCP_PERSISTENT")
  101.  
  102. /* uncomment the next line not to allow more than 10 contacts per AOR */
  103. #modparam("registrar", "max_contacts", 10)
  104.  
  105. #### ACCounting module
  106. loadmodule "acc.so"
  107. /* what special events should be accounted ? */
  108. modparam("acc", "early_media", 0)
  109. modparam("acc", "report_cancels", 0)
  110. /* by default we do not adjust the direct of the sequential requests.
  111. if you enable this parameter, be sure the enable "append_fromtag"
  112. in "rr" module */
  113. modparam("acc", "detect_direction", 0)
  114. modparam("acc", "failed_transaction_flag", "ACC_FAILED")
  115. /* account triggers (flags) */
  116. modparam("acc", "log_flag", "ACC_DO")
  117. modparam("acc", "log_missed_flag", "ACC_MISSED")
  118.  
  119.  
  120. #### MySQL module
  121. loadmodule "db_mysql.so"
  122.  
  123. #### AUTH module
  124. loadmodule "auth.so"
  125. /*modparam("usrloc", "db_mode", 0); #THIS LINE MUST TO BE COMMENTED
  126. */
  127. modparam("usrloc", "db_mode", 2)
  128. modparam("usrloc", "db_url", "mysql://opensips:opensipsrw@localhost/opensips")
  129.  
  130. #### AUTHDB module
  131. loadmodule "auth_db.so"
  132. /* uncomment the following lines if you want to enable the DB based authentication */
  133. modparam("auth_db", "calculate_ha1", 1)
  134. modparam("auth_db", "password_column", "password")
  135. modparam("auth_db", "db_url", "mysql://opensips:opensipsrw@localhost/opensips")
  136. modparam("auth_db", "load_credentials", "")
  137.  
  138. #### DB Alias module
  139. #loadmodule "alias_db.so"
  140. #modparam("alias_db", "db_url", "mysql://opensips:opensipsrw@localhost/opensips")
  141.  
  142. #### Domain module
  143. #loadmodule "domain.so"
  144. #modparam("domain", "db_url", "mysql://opensips:opensipsrw@localhost/opensips")
  145. #modparam("domain", "db_mode", 1) # Use caching
  146.  
  147. #### XCAP module
  148. loadmodule "xcap.so"
  149. modparam("xcap", "db_url", "mysql://opensips:opensipsrw@localhost/opensips")
  150. #modparam("xcap", "xcap_table", "xcap")
  151. modparam("xcap", "integrated_xcap_server", 1)
  152.  
  153. loadmodule "xcap_client.so"
  154.  
  155.  
  156. #### Presence module
  157. loadmodule "presence.so"
  158. loadmodule "presence_xml.so"
  159. modparam("presence", "db_url", "mysql://opensips:opensipsrw@localhost/opensips")
  160. modparam("presence", "server_address", "sip:10.10.10.123:5060")
  161. #modparam("presence_xml", "force_active", 1)
  162. /*Presence module table configuration.*/
  163. #modparam("presence", "presentity_table", "presentity")
  164. #modparam("presence", "active_watchers_table", "active_watchers")
  165. #modparam("presence", "watchers_table", "watchers")
  166. /*The period at which to clean the expired subscription dialogs.*/
  167. #modparam("presence", "clean_period", 100)
  168. /*The period at which to synchronize cached subscriber info with the database.*/
  169. #modparam("presence", "db_update_period", 100)
  170. /*The extra time to store a subscription/publication.*/
  171. #modparam("presence", "expires_offset", 10)
  172. /*The the maximum admissible expires value for SUBSCRIBE and PUBLISH messages.*/
  173. #modparam("presence", "max_expires_subscribe", 3600)
  174. #modparam("presence", "max_expires_publish", 3600)
  175. /*Setting this parameter enables a fallback to db mode of operation on cache miss event.*/
  176. modparam("presence", "fallback2db", 1)
  177. /*The size of the hash table to store subscription dialogs and publish records. This parameter will be used as the power of 2 when computing table size.*/
  178. #modparam("presence", "subs_htable_size", 11)
  179. #modparam("presence", "pres_htable_size", 11)
  180. /*The number of days to keep the record of a subscription in server database if the subscription is in pending or waiting state*/
  181. #modparam("presence", "waiting_subs_daysno", 10)
  182. /*If this parameter is set, when no published info is found for a user, the presence server will generate a dummy body with status 'closed' and use it when sending Notify, instead of notifying with no body.*/
  183. modparam("presence", "notify_offline_body", 1)
  184.  
  185.  
  186. #### Msilo module
  187. loadmodule "msilo.so"
  188. modparam("msilo", "db_url", "mysql://opensips:opensipsrw@localhost/opensips")
  189. #modparam("msilo", "db_table", "silo")
  190. #modparam("msilo", "sc_mid", "id")
  191. /*The body of the notification message. It can contain pseudo-variables.*/
  192. #modparam("msilo","contact_hdr","Contact: registrar@localhost:5060;msilo=yes\r\n")
  193. #modparam("msilo","content_type_hdr","Content-Type: text/plain\r\n")
  194. #modparam("msilo", "offline_message", "*** User $rU is offline!")
  195. /*Expire time of stored messages - seconds. When this time passed, the message is silently discarded from database.*/
  196. #modparam("msilo", "expire_time", 36000) # 36000 secs = 10 hrs
  197.  
  198.  
  199.  
  200.  
  201.  
  202. ##############################
  203. ####### Routing Logic ########
  204. ##############################
  205.  
  206. # main request routing logic
  207.  
  208. route {
  209. # Preventing loops in routes ...
  210. if (! mf_process_maxfwd_header("10")) {
  211. sl_send_reply("483", "Too Many Hops");
  212. exit;
  213. }
  214.  
  215. if (msg:len >= 2048 ) {
  216. sl_send_reply("513", "Message too big");
  217. exit;
  218. };
  219.  
  220. # For processing sequence requests ...
  221. if (has_totag()) {
  222. # sequential request withing a dialog should
  223. # take the path determined by record-routing
  224. if (loose_route()) {
  225. if (is_method("BYE")) {
  226. setflag(ACC_DO); # do accounting ...
  227. setflag(ACC_FAILED); # ... even if the transaction fails
  228. } else if (is_method("INVITE")) {
  229. # even if in most of the cases is useless, do RR for
  230. # re-INVITEs alos, as some buggy clients do change route set
  231. # during the dialog.
  232. record_route();
  233. }
  234.  
  235. # route it out to whatever destination was set by loose_route()
  236. # in $du (destination URI).
  237. route(relay);
  238. } else {
  239. if (is_method("SUBSCRIBE") && $rd == "10.10.10.123") {
  240. # in-dialog subscribe requests
  241. route(presence);
  242. exit;
  243. } else if ( is_method("ACK") ) {
  244. if ( t_check_trans() ) {
  245. # non loose-route, but stateful ACK; must be an ACK after
  246. # a 487 or e.g. 404 from upstream server
  247. t_relay();
  248. exit;
  249. } else {
  250. # ACK without matching transaction ->
  251. # ignore and discard
  252. exit;
  253. }
  254. }
  255. sl_send_reply("404","Not here");
  256. }
  257. exit;
  258. }
  259.  
  260. # CANCEL processing
  261. # Only need to be routed to the destination where we already routed the INVITE ...
  262. if (is_method("CANCEL"))
  263. {
  264. if (t_check_trans())
  265. t_relay();
  266. exit;
  267. }
  268.  
  269. # Determine if a specific request belongs to a transaction.
  270. # In this point of the script, the function is being used to stop the script if the request is a retransmission.
  271. t_check_trans();
  272.  
  273. # Perform authentication in NON-REGISTER requests ...
  274. if ( !is_method("REGISTER") && from_uri==myself) {
  275. #if (!proxy_authorize("", "subscriber")) {
  276. # proxy_challenge("", "0");
  277. # exit;
  278. #}
  279. #if (!db_check_from()) {
  280. # sl_send_reply("403","Forbidden auth ID");
  281. # exit;
  282. #}
  283.  
  284. # Prevent the credentials from relaying to the destination ...
  285. #consume_credentials();
  286.  
  287. # caller authenticated ... woow
  288. }
  289.  
  290. # Preloaded route checking
  291. if (loose_route()) {
  292. xlog("L_ERR", "Attempt to route with preloaded Route's [$fu/$tu/$ru/$ci]");
  293. if (!is_method("ACK"))
  294. sl_send_reply("403","Preload Route denied");
  295. exit;
  296. }
  297.  
  298. # Record routing
  299. if (!is_method("REGISTER|MESSAGE"))
  300. record_route();
  301.  
  302. # account only INVITEs
  303. if (is_method("INVITE")) {
  304. setflag(ACC_DO); # do accounting
  305. }
  306.  
  307. # If request is for some other domain, then relay it simply ...
  308. # Hence me is proxying this ...
  309. if (!uri==myself) {
  310. append_hf("P-hint: outbound\r\n");
  311. route(relay);
  312. }
  313.  
  314. # requests for my domain
  315. if (is_method("PUBLISH|SUBSCRIBE"))
  316. {
  317. route(presence);
  318. # sl_send_reply("503", "Service Unavailable");
  319. # exit;
  320. }
  321.  
  322. if (is_method("REGISTER"))
  323. {
  324. # authenticate the REGISTER requests (uncomment to enable auth)
  325. #if (!www_authorize("", "subscriber")) {
  326. # www_challenge("", "0");
  327. # exit;
  328. #}
  329.  
  330. #if (!db_check_to()) {
  331. # sl_send_reply("403","Forbidden auth ID");
  332. # exit;
  333. #}
  334.  
  335. #if ( 0 ) setflag(TCP_PERSISTENT);
  336.  
  337. if (!save("location"))
  338. sl_reply_error();
  339.  
  340. log("REGISTER received -> dumping messages with MSILO\n");
  341. # MSILO - dumping user's offline messages
  342. if (m_dump())
  343. log("MSILO: offline messages dumped - if they were\n");
  344. else
  345. log("MSILO: no offline messages dumped\n");
  346.  
  347. exit;
  348. }
  349.  
  350. if ($rU==NULL) {
  351. # request with no Username in RURI
  352. sl_send_reply("484","Address Incomplete");
  353. exit;
  354. }
  355.  
  356. # apply DB based aliases (uncomment to enable)
  357. #alias_db_lookup("dbaliases");
  358.  
  359. # do lookup with method filtering, and if destination is not found ...
  360. if (!lookup("location","m")) {
  361. if (! t_newtran()) {
  362. sl_reply_error();
  363. exit;
  364. };
  365.  
  366. # we do not care about anything else but MESSAGEs from here now ...
  367. if (!method=="MESSAGE")
  368. {
  369. if (!t_reply("404", "Not found"))
  370. {
  371. sl_reply_error();
  372. }
  373. exit;
  374. };
  375. log("MESSAGE received -> storing using MSILO\n");
  376. # MSILO - storing as offline message
  377. if (m_store("$ru")) {
  378. log("MSILO: offline message stored\n");
  379. if (!t_reply("202", "Accepted")) {
  380. sl_reply_error();
  381. }
  382. } else {
  383. log("MSILO: offline message NOT stored\n");
  384. if (!t_reply("503", "Service Unavailable")) {
  385. sl_reply_error();
  386. }
  387. }
  388.  
  389. exit;
  390. }
  391.  
  392. # when routing via usrloc, log the missed calls also
  393. setflag(ACC_MISSED);
  394. route(relay);
  395. }
  396.  
  397.  
  398. route[relay] {
  399. # for INVITEs enable some additional helper routes
  400. if (is_method("INVITE")) {
  401. t_on_branch("per_branch_ops");
  402. t_on_reply("handle_nat");
  403. t_on_failure("missed_call");
  404. }
  405.  
  406. if (!t_relay()) {
  407. send_reply("500", "Internal Error");
  408. }
  409. exit;
  410. }
  411.  
  412. # Presence route
  413. route[presence] {
  414. if (!t_newtran()) {
  415. sl_reply_error();
  416. exit;
  417. };
  418.  
  419. if(is_method("PUBLISH")) {
  420. if($hdr(Sender)!= NULL)
  421. handle_publish("$hdr(Sender)");
  422. else
  423. handle_publish();
  424. }
  425. else if( is_method("SUBSCRIBE")) {
  426. handle_subscribe();
  427. }
  428.  
  429. exit;
  430. }
  431.  
  432.  
  433.  
  434. branch_route[per_branch_ops] {
  435. xlog("new branch at $ru\n");
  436. }
  437.  
  438.  
  439. onreply_route[handle_nat] {
  440.  
  441. xlog("incoming reply\n");
  442. }
  443.  
  444.  
  445. failure_route[missed_call] {
  446.  
  447. if (is_method("MESSAGE"))
  448. {
  449. log(1,"MSILO:the downstream UA doesn't support MESSAGEs\n");
  450. # we have changed the R-URI with the contact address, ignore it now
  451. if (m_store("$ou")) {
  452. log("MSILO: offline message stored\n");
  453. t_reply("202", "Accepted");
  454. } else {
  455. log("MSILO: offline message NOT stored\n");
  456. t_reply("503", "Service Unavailable");
  457. };
  458. exit;
  459. };
  460.  
  461. if (t_was_cancelled()) {
  462. exit;
  463. }
  464.  
  465. # uncomment the following lines if you want to block client
  466. # redirect based on 3xx replies.
  467. ##if (t_check_status("3[0-9][0-9]")) {
  468. ##t_reply("404","Not found");
  469. ## exit;
  470. ##}
  471.  
  472. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement