openser.cfg 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. ##
  2. ## openser.cfg -- OpenSER server configuration
  3. ##
  4. #
  5. # GLOBAL CONFIGURATION PARAMETERS
  6. #
  7. # process configuration
  8. debug=1
  9. log_stderror=no
  10. fork=yes
  11. check_via=no
  12. dns=no
  13. rev_dns=no
  14. children=4
  15. user="@l_rusr@"
  16. group="@l_rgrp@"
  17. fifo="@l_prefix@/var/openser/openser.fifo"
  18. workdir="@l_prefix@/var/openser"
  19. # network configuration
  20. alias="sip.example.com"
  21. listen="127.0.0.1"
  22. port=5060
  23. #
  24. # EXTENSION MODULE LOADING
  25. #
  26. #loadmodule "@l_prefix@/lib/openser/modules/dbtext.so"
  27. loadmodule "@l_prefix@/lib/openser/modules/sl.so"
  28. loadmodule "@l_prefix@/lib/openser/modules/tm.so"
  29. loadmodule "@l_prefix@/lib/openser/modules/rr.so"
  30. loadmodule "@l_prefix@/lib/openser/modules/maxfwd.so"
  31. loadmodule "@l_prefix@/lib/openser/modules/usrloc.so"
  32. loadmodule "@l_prefix@/lib/openser/modules/registrar.so"
  33. loadmodule "@l_prefix@/lib/openser/modules/textops.so"
  34. #loadmodule "@l_prefix@/lib/openser/modules/auth.so"
  35. #loadmodule "@l_prefix@/lib/openser/modules/auth_db.so"
  36. #loadmodule "@l_prefix@/lib/openser/modules/nathelper.so"
  37. #
  38. # EXTENSION MODULE CONFIGURATION
  39. #
  40. # module rr:
  41. modparam("rr", "enable_full_lr", 1)
  42. # module usrloc:
  43. modparam("usrloc", "db_mode", 0)
  44. #modparam("usrloc", "db_mode", 2)
  45. #modparam("usrloc|auth_db", "db_url", "dbtext://@l_prefix@/var/openser/db")
  46. # module auth:
  47. #modparam("auth_db", "calculate_ha1", 1)
  48. #modparam("auth_db", "password_column", "password")
  49. #modparam("auth_db", "user_column", "username")
  50. #modparam("auth_db", "domain_column", "domain")
  51. # module nathelper:
  52. #modparam("registrar", "nat_flag", 6)
  53. #modparam("nathelper", "natping_interval", 30)
  54. #modparam("nathelper", "ping_nated_only", 1)
  55. #modparam("nathelper", "rtpproxy_sock", "unix:@l_prefix@/var/openser/openser_rtpproxy.sock")
  56. #modparam("nathelper", "rtpproxy_disable", 0)
  57. #modparam("nathelper", "rtpproxy_disable_tout", 20)
  58. #modparam("nathelper", "sipping_from", "sip:pinger@sip.example.com")
  59. #
  60. # MAIN ROUTING LOGIC
  61. #
  62. route{
  63. # initial sanity checks -- messages with
  64. # max_forwards==0, or excessively long requests
  65. if (!mf_process_maxfwd_header("10")) {
  66. sl_send_reply("483", "Too Many Hops");
  67. exit;
  68. };
  69. if (msg:len >= max_len) {
  70. sl_send_reply("513", "Message too big");
  71. exit;
  72. };
  73. #if (method == "INVITE" && uri != myself) {
  74. # sl_send_reply("403", "No relaying");
  75. # exit;
  76. #};
  77. # NAT: special handling for NAT'ed clients; first, NAT test is
  78. # executed: it looks for via!=received and RFC1918 addresses in
  79. # Contact (may fail if line-folding is used); also, the received
  80. # test should, if completed, should check all vias for presence of
  81. # received.
  82. #if (nat_uac_test("3")) {
  83. # # allow RR-ed requests, as these may indicate that NAT-enabled
  84. # # aproxy takes care of it; unless it is REGISTER
  85. # if (method == "REGISTER" || ! search("^Record-Route:")) {
  86. # log("LOG: Someone trying to register from private IP, rewriting\n");
  87. # fix_nated_contact(); # rewrite contact with source IP of signalling
  88. # if (method == "INVITE") {
  89. # fix_nated_sdp("1"); # add direction=active to SDP
  90. # };
  91. # force_rport(); # add rport parameter to topmost Via
  92. # setflag(6); # mark as NAT'ed
  93. # };
  94. #};
  95. # we record-route all messages -- to make sure that
  96. # subsequent messages will go through our proxy; that's
  97. # particularly good if upstream and downstream entities
  98. # use different transport protocol
  99. if (method != "REGISTER") {
  100. record_route();
  101. };
  102. # subsequent messages withing a dialog should take the
  103. # path determined by record-routing
  104. if (loose_route()) {
  105. # mark routing logic in request
  106. append_hf("P-hint: rr-enforced\r\n");
  107. route(1);
  108. };
  109. if (uri != myself) {
  110. # mark routing logic in request
  111. append_hf("P-hint: outbound\r\n");
  112. route(1);
  113. };
  114. # if the request is for other domain use USRLOC
  115. # (in case, it does not work, use the following command
  116. # with proper names and addresses in it)
  117. if (uri == myself) {
  118. if (method == "REGISTER") {
  119. # uncomment this if you want to use digest authentication
  120. #if (!www_authorize("sip.example.com", "subscriber")) {
  121. # www_challenge("sip.example.com", "0");
  122. # exit;
  123. #};
  124. save("location");
  125. exit;
  126. };
  127. lookup("aliases");
  128. if (uri != myself) {
  129. append_hf("P-hint: outbound alias\r\n");
  130. route(1);
  131. };
  132. # native SIP destinations are handled using our USRLOC DB
  133. if (!lookup("location")) {
  134. sl_send_reply("404", "Not Found");
  135. exit;
  136. };
  137. append_hf("P-hint: usrloc applied\r\n");
  138. };
  139. route(1);
  140. }
  141. route[1] {
  142. # disable RFC1918 peers
  143. if (uri =~ "[@:](192\.168\.|10\.|172\.(1[6-9]|2[0-9]|3[0-1])\.)" && !search("^Route:")) {
  144. sl_send_reply("479", "We don't forward to RFC 1918 IPv4 addresses");
  145. exit;
  146. };
  147. # NAT: if client or server know to be behind a NAT, enable relay
  148. #if (isflagset(6)) {
  149. # force_rtp_proxy();
  150. #};
  151. # NAT: processing of replies; apply to all transactions
  152. #t_on_reply("1");
  153. # send it out now; use stateful forwarding as it works reliably even for UDP2TCP
  154. if (!t_relay()) {
  155. sl_reply_error();
  156. };
  157. }
  158. #onreply_route[1] {
  159. # NAT: is it a NAT'ed transaction ?
  160. # otherwise, is it a transaction behind a NAT and we did not
  161. # know at time of request processing ? (RFC1918 contacts)
  162. #if (isflagset(6) && status =~ "(183)|2[0-9][0-9]") {
  163. # fix_nated_contact();
  164. # force_rtp_proxy();
  165. #} else if (nat_uac_test("1")) {
  166. # fix_nated_contact();
  167. #};
  168. #}