sip-router-basic.cfg 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. #
  2. # $Id$
  3. #
  4. # This a very basic config file w/ aliases and a named route but
  5. # w/o authentication, accounting, database, multi-domain support etc.
  6. # Please refer to sip-router.cfg for a more complete example
  7. #
  8. # Direct your questions about this file to: <[email protected]>.
  9. #
  10. # For more information about the various parameters, functions and statements
  11. # try http://sip-router.org/wiki/ .
  12. #
  13. #------------ Features -----------------------------------------------
  14. # Several extra features can be enabled by adding #!define WITH_<FEATURE>
  15. # statements to the config file, or by starting sr/ser with -A WITH_<FEATURE>.
  16. # E.g.: ser -f /etc/ser/sip-router-basic.cfg -A WITH_TLS
  17. # run in debug mode:
  18. ##!define WITH_DEBUG
  19. # enable tls support:
  20. ##!define WITH_TLS
  21. # started from compile directory (not installed)
  22. ##!define LOCAL_TEST_RUN
  23. # ----------- global configuration parameters ------------------------
  24. #!ifdef WITH_DEBUG
  25. debug=5
  26. log_stderror=yes
  27. fork=no
  28. #!else
  29. debug=2 # debug level (cmd line: -dddddddddd)
  30. #!endif
  31. #memdbg=10 # memory debug message level
  32. #memlog=10 # memory statistics log level
  33. #log_facility=LOG_LOCAL0 # sets the facility used for logging (see syslog(3))
  34. check_via=no # (cmd. line: -v)
  35. dns=no # (cmd. line: -r)
  36. rev_dns=no # (cmd. line: -R)
  37. #port=5060
  38. #children=4
  39. #user=sip-router
  40. #group=sip-router
  41. #disable_core=yes #disables core dumping
  42. #open_fd_limit=1024 # sets the open file descriptors limit
  43. #mhomed=yes # usefull for multihomed hosts, small performance penalty
  44. #disable_tcp=yes
  45. #tcp_accept_aliases=yes # accepts the tcp alias via option (see NEWS)
  46. sip_warning=yes
  47. #!ifdef WITH_TLS
  48. enable_tls=yes
  49. #!endif
  50. #
  51. # ------------------ module loading ----------------------------------
  52. #!ifdef LOCAL_TEST_RUN
  53. loadpath "modules:modules_s"
  54. #!else
  55. loadpath "/usr/lib/sip-router/modules:/usr/lib/sip-router/modules_s"
  56. #!endif
  57. loadmodule "tm"
  58. loadmodule "sl"
  59. loadmodule "rr"
  60. loadmodule "textops"
  61. loadmodule "maxfwd"
  62. loadmodule "usrloc"
  63. loadmodule "registrar"
  64. loadmodule "ctl"
  65. loadmodule "cfg_rpc"
  66. #!ifdef WITH_TLS
  67. loadmodule "tls"
  68. #!endif
  69. # ----------------- setting module-specific parameters ---------------
  70. # -- usrloc params --
  71. modparam("usrloc", "db_mode", 0)
  72. # -- rr params --
  73. # add value to ;lr param to make some broken UAs happy
  74. modparam("rr", "enable_full_lr", 1)
  75. # ctl params
  76. # by default ctl listens on unixs:/tmp/sip-router_ctl if no other address is
  77. # specified in modparams; this is also the default for sercmd
  78. modparam("ctl", "binrpc", "unixs:/tmp/ser_ctl")
  79. # listen on the "standard" fifo for backward compatibility
  80. modparam("ctl", "fifo", "fifo:/tmp/ser_fifo")
  81. # listen on tcp, localhost
  82. modparam("ctl", "binrpc", "tcp:127.0.0.1:2046")
  83. #!ifdef WITH_TLS
  84. modparam("tls", "verify_certificate", 0)
  85. #!ifdef LOCAL_TEST_RUN
  86. modparam("tls", "certificate", "./modules/tls/sip-router-selfsigned.pem")
  87. modparam("tls", "private_key", "./modules/tls/sip-router-selfsigned.key")
  88. #separate TLS config file
  89. #modparam("tls", "config", "./modules/tls/tls.cfg")
  90. #!else
  91. modparam("tls", "certificate", "ser-selfsigned.pem")
  92. modparam("tls", "private_key", "ser-selfsigned.key")
  93. #separate TLS config file
  94. #modparam("tls", "config", "tls.cfg")
  95. #!endif
  96. #!endif
  97. #!endif
  98. # ------------------------- request routing logic -------------------
  99. # main routing logic
  100. route{
  101. # initial sanity checks -- messages with
  102. # max_forwards==0, or excessively long requests
  103. if (!mf_process_maxfwd_header("10")) {
  104. sl_reply("483","Too Many Hops");
  105. break;
  106. }
  107. if (msg:len >= 4096 ) {
  108. sl_reply("513", "Message too big");
  109. break;
  110. }
  111. # we record-route all messages -- to make sure that
  112. # subsequent messages will go through our proxy; that's
  113. # particularly good if upstream and downstream entities
  114. # use different transport protocol
  115. if (!method=="REGISTER") record_route();
  116. # subsequent messages withing a dialog should take the
  117. # path determined by record-routing
  118. if (loose_route()) {
  119. # mark routing logic in request
  120. append_hf("P-hint: rr-enforced\r\n");
  121. route(FORWARD);
  122. break;
  123. }
  124. if (!uri==myself) {
  125. # mark routing logic in request
  126. append_hf("P-hint: outbound\r\n");
  127. route(FORWARD);
  128. break;
  129. }
  130. # if the request is for other domain use UsrLoc
  131. # (in case, it does not work, use the following command
  132. # with proper names and addresses in it)
  133. if (uri==myself) {
  134. if (method=="REGISTER") {
  135. save_contacts("location");
  136. break;
  137. }
  138. # native SIP destinations are handled using our USRLOC DB
  139. if (!lookup_contacts("location")) {
  140. sl_reply("404", "Not Found");
  141. break;
  142. }
  143. append_hf("P-hint: usrloc applied\r\n");
  144. }
  145. route(FORWARD);
  146. }
  147. route[FORWARD]
  148. {
  149. # send it out now; use stateful forwarding as it works reliably
  150. # even for UDP2TCP
  151. if (!t_relay()) {
  152. sl_reply_error();
  153. }
  154. }