basitengr

im kamailio.cfg

Apr 9th, 2018
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 17.33 KB | None | 0 0
  1. #!KAMAILIO
  2. #
  3. # Kamailio (OpenSER) SIP Server v5.1 - default configuration script
  4.  
  5. # - define WITH_DEBUG
  6. #!define WITH_MYSQL
  7. #!define WITH_AUTH
  8. #!define WITH_USRLOCDB
  9. #!define WITH_PRESENCE
  10. #!define WITH_MESSAGE
  11.  
  12. ####### Defined Values #########
  13.  
  14. # *** Value defines - IDs used later in config
  15. #!ifdef WITH_MYSQL
  16. #!ifndef DBURL
  17. #!define DBURL "mysql://kamailio:kamailiorw@localhost/kamailio"
  18. #!endif
  19. #!endif
  20. #!ifdef WITH_MULTIDOMAIN
  21. # - the value for 'use_domain' parameters
  22. #!define MULTIDOMAIN 1
  23. #!else
  24. #!define MULTIDOMAIN 0
  25. #!endif
  26.  
  27. # - flags
  28. #   FLT_ - per transaction (message) flags
  29. #   FLB_ - per branch flags
  30. #!define FLT_ACC 1
  31. #!define FLT_ACCMISSED 2
  32. #!define FLT_ACCFAILED 3
  33. #!define FLT_NATS 5
  34.  
  35. #!define FLB_NATB 6
  36. #!define FLB_NATSIPPING 7
  37.  
  38. ####### Global Parameters #########
  39.  
  40. ### LOG Levels: 3=DBG, 2=INFO, 1=NOTICE, 0=WARN, -1=ERR
  41. #!ifdef WITH_DEBUG
  42. debug=4
  43. log_stderror=no
  44. #!else
  45. debug=2
  46. log_stderror=no
  47. #!endif
  48.  
  49. memdbg=5
  50. memlog=5
  51.  
  52. log_facility=LOG_LOCAL0
  53. log_name="imServer"
  54. log_prefix="{$fU@$si:$sp} {$mt $hdr(CSeq)} "
  55. log_prefix_mode=0
  56.  
  57. /* number of SIP routing processes */
  58. children=4
  59.  
  60. #check_via=no      # (cmd. line: -v)
  61. #dns=off           # (cmd. line: -r)
  62. #rev_dns=off       # (cmd. line: -R)
  63.  
  64. /* uncomment the next line to disable TCP (default on) */
  65. # disable_tcp=yes
  66.  
  67. /* uncomment the next line to disable the auto discovery of local aliases
  68.  * based on reverse DNS on IPs (default on) */
  69. auto_aliases=no
  70.  
  71. /* add local domain aliases */
  72. alias="192.168.10.18"
  73. port=9060
  74. /* uncomment and configure the following line if you want Kamailio to
  75.  * bind on a specific interface/port/proto (default bind on all available) */
  76. # listen=udp:10.0.0.10:5060
  77.  
  78. /* life time of TCP connection when there is no traffic
  79.  * - a bit higher than registration expires to cope with UA behind NAT */
  80. tcp_connection_lifetime=3605
  81.  
  82. ####### Modules Section ########
  83.  
  84. /* set paths to location of modules */
  85. mpath="/usr/local/lib64/kamailio/modules/"
  86.  
  87. #!ifdef WITH_MYSQL
  88. loadmodule "db_mysql.so"
  89. #!endif
  90.  
  91. loadmodule "tm.so"
  92. loadmodule "tmx.so"
  93. loadmodule "jsonrpcs.so"
  94. loadmodule "kex.so"
  95. loadmodule "corex.so"
  96. loadmodule "sl.so"
  97. loadmodule "rr.so"
  98. loadmodule "pv.so"
  99. loadmodule "maxfwd.so"
  100. loadmodule "usrloc.so"
  101. loadmodule "registrar.so"
  102. loadmodule "textops.so"
  103. loadmodule "siputils.so"
  104. loadmodule "xlog.so"
  105. loadmodule "sanity.so"
  106. loadmodule "ctl.so"
  107. loadmodule "cfg_rpc.so"
  108. loadmodule "acc.so"
  109. loadmodule "counters.so"
  110.  
  111. #!ifdef WITH_AUTH
  112. loadmodule "auth.so"
  113. loadmodule "auth_db.so"
  114. #!endif
  115.  
  116. #!ifdef WITH_MULTIDOMAIN
  117. loadmodule "domain.so"
  118. #!endif
  119.  
  120. #!ifdef WITH_PRESENCE
  121. loadmodule "presence.so"
  122. loadmodule "presence_xml.so"
  123. #!endif
  124.  
  125. #!ifdef WITH_NAT
  126. loadmodule "nathelper.so"
  127. loadmodule "rtpproxy.so"
  128. #!endif
  129.  
  130. #!ifdef WITH_XMLRPC
  131. loadmodule "xmlrpc.so"
  132. #!endif
  133.  
  134. #!ifdef WITH_DEBUG
  135. loadmodule "debugger.so"
  136. #!endif
  137.  
  138. #!ifdef WITH_MESSAGE
  139. loadmodule "msilo.so"
  140. #!endif
  141.  
  142.  
  143. # ----------------- setting module-specific parameters ---------------
  144. #------- xlog params -------
  145. modparam("xlog", "prefix", "")
  146.  
  147. # ----- jsonrpcs params -----
  148. modparam("jsonrpcs", "pretty_format", 1)
  149.  
  150. # ----- tm params -----
  151. # auto-discard branches from previous serial forking leg
  152. modparam("tm", "failure_reply_mode", 3)
  153. # default retransmission timeout: 10sec
  154. modparam("tm", "fr_timer", 10)
  155. # default invite retransmission timeout after 1xx: 15sec
  156. modparam("tm", "fr_inv_timer", 15)
  157. modparam("tm", "wt_timer", 10 )
  158.  
  159. # ----- rr params -----
  160. # set next param to 1 to add value to ;lr param (helps with some UAs)
  161. modparam("rr", "enable_full_lr", 0)
  162. # do not append from tag to the RR (no need for this script)
  163. modparam("rr", "append_fromtag", 0)
  164.  
  165. # ----- registrar params -----
  166. modparam("registrar", "method_filtering", 1)
  167. /* uncomment the next line to disable parallel forking via location */
  168. # modparam("registrar", "append_branches", 0)
  169. /* uncomment the next line not to allow more than 10 contacts per AOR */
  170. # modparam("registrar", "max_contacts", 10)
  171. modparam("registrar", "default_expires", 120)
  172. /* max value for expires of registrations */
  173. modparam("registrar", "max_expires", 3600)
  174. /* set it to 1 to enable GRUU */
  175. modparam("registrar", "gruu_enabled", 0)
  176.  
  177. # ----- acc params -----
  178. /* what special events should be accounted ? */
  179. modparam("acc", "early_media", 0)
  180. modparam("acc", "report_ack", 0)
  181. modparam("acc", "report_cancels", 0)
  182. /* by default ww do not adjust the direct of the sequential requests.
  183.  * if you enable this parameter, be sure the enable "append_fromtag"
  184.  * in "rr" module */
  185. modparam("acc", "detect_direction", 0)
  186. /* account triggers (flags) */
  187. modparam("acc", "log_flag", FLT_ACC)
  188. modparam("acc", "log_missed_flag", FLT_ACCMISSED)
  189. modparam("acc", "log_extra",
  190.     "src_user=$fU;src_domain=$fd;src_ip=$si;"
  191.     "dst_ouser=$tU;dst_user=$rU;dst_domain=$rd")
  192. modparam("acc", "failed_transaction_flag", FLT_ACCFAILED)
  193. /* enhanced DB accounting */
  194. #!ifdef WITH_ACCDB
  195. modparam("acc", "db_flag", FLT_ACC)
  196. modparam("acc", "db_missed_flag", FLT_ACCMISSED)
  197. modparam("acc", "db_url", DBURL)
  198. modparam("acc", "db_extra",
  199.     "src_user=$fU;src_domain=$fd;src_ip=$si;"
  200.     "dst_ouser=$tU;dst_user=$rU;dst_domain=$rd")
  201. #!endif
  202.  
  203. # ----- usrloc params -----
  204. /* enable DB persistency for location entries */
  205. #!ifdef WITH_USRLOCDB
  206. modparam("usrloc", "db_url", DBURL)
  207. modparam("usrloc", "db_mode", 0)
  208. modparam("usrloc", "use_domain", MULTIDOMAIN)
  209. #!endif
  210.  
  211. # ----- auth_db params -----
  212. #!ifdef WITH_AUTH
  213. modparam("auth_db", "db_url", DBURL)
  214. modparam("auth_db", "calculate_ha1", yes)
  215. modparam("auth_db", "password_column", "password")
  216. modparam("auth_db", "load_credentials", "")
  217. modparam("auth_db", "use_domain", MULTIDOMAIN)
  218.  
  219. #!endif
  220.  
  221. # ----- alias_db params -----
  222. #!ifdef WITH_ALIASDB
  223. modparam("alias_db", "db_url", DBURL)
  224. modparam("alias_db", "use_domain", MULTIDOMAIN)
  225. #!endif
  226.  
  227. # ----- domain params -----
  228. #!ifdef WITH_MULTIDOMAIN
  229. modparam("domain", "db_url", DBURL)
  230. /* register callback to match myself condition with domains list */
  231. modparam("domain", "register_myself", 1)
  232. #!endif
  233.  
  234. #!ifdef WITH_PRESENCE
  235. # ----- presence params -----
  236. modparam("presence", "db_url", DBURL)
  237.  
  238. # ----- presence_xml params -----
  239. modparam("presence_xml", "db_url", DBURL)
  240. modparam("presence_xml", "force_active", 1)
  241. #!endif
  242.  
  243. #!ifdef WITH_MESSAGE
  244. # ----- msilo params -----
  245. modparam("msilo", "db_url", DBURL)
  246. modparam("msilo", "db_table", "silo")
  247. modparam("msilo", "sc_mid", "id")
  248. modparam("msilo","from_address","sip:registrar@192.168.10.18:9060")
  249. modparam("msilo","contact_hdr","Contact: registrar@192.168.10.18:9060;msilo=yes\r\n")
  250. modparam("msilo","content_type_hdr","Content-Type: text/plain\r\n")
  251. #modparam("msilo","offline_message","*** User $rU is offline!")
  252. #modparam("msilo", "expire_time", 3600) // discard offline messages after 1 hr
  253. #modparam("msilo", "check_time", 10)
  254. #!endif
  255.  
  256. #!ifdef WITH_NAT
  257. # ----- rtpproxy params -----
  258. modparam("rtpproxy", "rtpproxy_sock", "udp:127.0.0.1:7722")
  259.  
  260. # ----- nathelper params -----
  261. modparam("nathelper", "natping_interval", 30)
  262. modparam("nathelper", "ping_nated_only", 1)
  263. modparam("nathelper", "sipping_bflag", FLB_NATSIPPING)
  264. modparam("nathelper", "sipping_from", "sip:pinger@kamailio.org")
  265.  
  266. # params needed for NAT traversal in other modules
  267. modparam("nathelper|registrar", "received_avp", "$avp(RECEIVED)")
  268. modparam("usrloc", "nat_bflag", FLB_NATB)
  269. #!endif
  270.  
  271. #!ifdef WITH_XMLRPC
  272. # ----- xmlrpc params -----
  273. modparam("xmlrpc", "route", "XMLRPC");
  274. modparam("xmlrpc", "url_match", "^/RPC")
  275. #!endif
  276.  
  277. #!ifdef WITH_DEBUG
  278. # ----- debugger params -----
  279. modparam("debugger", "cfgtrace", 1)
  280. modparam("debugger", "log_level_name", "exec")
  281. #!endif
  282.  
  283. ####### Routing Logic ########
  284. request_route {
  285.  
  286.     # NAT detection
  287.     route(NATDETECT);
  288.  
  289.     # handle retransmissions
  290.     if (!is_method("ACK")) {
  291.         if(t_precheck_trans()) {
  292.             t_check_trans();
  293.             exit;
  294.         }
  295.         t_check_trans();
  296.     }
  297.  
  298.     # handle requests within SIP dialogs
  299.     route(WITHINDLG);
  300.  
  301.     # authentication
  302.     route(AUTH);
  303.  
  304.     # record routing for dialog forming requests (in case they are routed)
  305.     # - remove preloaded route headers
  306.     remove_hf("Route");
  307.     if (is_method("INVITE|SUBSCRIBE")) {
  308.         record_route();
  309.     }
  310.  
  311.     # handle presence related requests
  312.     route(PRESENCE);
  313.  
  314.     # handle registrations
  315.     route(REGISTRAR);
  316.  
  317.  
  318. #!ifdef WITH_MESSAGE
  319.     # backup r-uri for m_dump() in case of delivery failure
  320.     $avp(11) = $ru;
  321.     xlogl("L_NOTICE", "[$rm] MSILO: copied ru:$ru to avp(11) and rd:$rd \n");
  322.  
  323.     if (is_method("MESSAGE")) {
  324.         route(MSILO_MESSAGE);
  325.     }
  326. #!endif
  327.  
  328.     if ($rU==$null) {
  329.         # request with no Username in RURI
  330.         sl_send_reply("484","Address Incomplete");
  331.         exit;
  332.     }
  333.  
  334.     # user location service
  335.     route(LOCATION);
  336. }
  337.  
  338. route[MSILO_MESSAGE] {
  339.     xlogl("L_NOTICE", "[$rm] Received message: [[$rb]]\n");
  340.     xlogl("L_NOTICE", "[$rm] r-uri: $ru d-uri: $du \n");
  341.  
  342.     # domestic SIP destinations are handled using our USRLOC DB
  343.     if ( !lookup("location") ) {
  344.         if (!t_newtran()) {
  345.             xlogl("L_ERROR", "[$rm] -> ERROR creating new transaction \n");
  346.             sl_reply_error();
  347.             exit;
  348.         };
  349.         xlogl("L_NOTICE", "[$rm] -> Storing MSILO_MESSAGE \n [$ru]-[$tu]-[$ou] \n ");
  350.         if (m_store("$ru")) {
  351.             xlogl("L_NOTICE", "MSILO: offline message stored! \n");
  352.             if (!t_reply("202", "Accpeted and Strored")) {
  353.                 xlogl("L_ERROR", "MSILO: ERROR sending 202 reply... \n");
  354.                 sl_reply_error();
  355.             }
  356.         } else {
  357.             xlogl("L_ERROR", "MSILO: offline message NOT stored... \n");
  358.             if (!t_reply("503", "Service Unavailable")) {
  359.                 sl_reply_error();
  360.             }
  361.         }
  362. //      t_relay();
  363. //        t_reply("202", "Accepted");
  364.     } else {
  365.         xlogl("L_NOTICE", "[$rm] -> loaction found. Relying message [[$rb]] to the UAC \n");
  366.         //t_relay();
  367.         route(RELAY);
  368.         exit;
  369.     }
  370.     exit;
  371. }
  372.  
  373. # Handle SIP registrations
  374. route[REGISTRAR] {
  375.     if (!is_method("REGISTER")) return; // discard all non-REGISTER methods
  376.  
  377.     if(isflagset(FLT_NATS)) {
  378.         setbflag(FLB_NATB);
  379. #!ifdef WITH_NATSIPPING
  380.         setbflag(FLB_NATSIPPING); //# do SIP NAT pinging
  381. #!endif
  382.     }
  383.  
  384. #!ifdef WITH_MESSAGE
  385.  
  386.     $avp(received) = "sip:" + $si + ":" + $sp + ";transport=" + $proto;
  387.     xlogl("L_INFO", "[$rm] -> UAC actual location $avp(received) \n");
  388.     if (!save("location",0x04)) {
  389.         xlogl("L_ERROR", "[$rm] -> Unable to save user location \n");
  390.         sl_reply_error();
  391.     }
  392.     else {
  393.         xlogl("L_INFO", "[$rm] -> dumping messages with MSILO \n");
  394.         # MSILO - dumping user's offline messages to user
  395.         //if (m_dump("$fu")) {
  396.         if (m_dump()) {
  397.             xlogl("L_NOTICE", "MSILO: offline messages for $fu dumped - if they were \n");
  398.         }
  399.         else {
  400.             xlogl("L_NOTICE", "MSILO: no offline messages dumped \n");
  401.         };
  402.     }
  403. #!endif
  404.  
  405.     exit;
  406. }
  407.  
  408. # User location service
  409. route[LOCATION] {
  410.  
  411.     $avp(oexten) = $rU;
  412.     if (!lookup("location")) {
  413.         $var(rc) = $rc;
  414.         route(TOVOICEMAIL);
  415.         if (!t_newtran()) {
  416.             xlogl("L_ERROR", "[$rm] -> ERR creating new transaction");
  417.             sl_reply_error();
  418.             exit;
  419.         }
  420.         switch ($var(rc)) {
  421.             case -1:
  422.             case -3:
  423.                 send_reply("404", "Not Found");
  424.                 exit;
  425.             case -2:
  426.                 send_reply("405", "Method Not Allowed");
  427.                 exit;
  428.         }
  429. // place route(MSILO_MESSAGE) here
  430.     }
  431.  
  432.     # when routing via usrloc, log the missed calls also
  433.     if (is_method("INVITE")) {
  434.         setflag(FLT_ACCMISSED);
  435.     }
  436.  
  437.     route(RELAY);
  438.     exit;
  439. }
  440.  
  441. # Presence server processing
  442. route[PRESENCE] {
  443.     if(!is_method("PUBLISH|SUBSCRIBE")) return;
  444.  
  445.     if(is_method("SUBSCRIBE") && $hdr(Event)=="message-summary") {
  446.         route(TOVOICEMAIL);
  447.         # returns here if no voicemail server is configured
  448.         sl_send_reply("404", "No voicemail service");
  449.         exit;
  450.     }
  451.  
  452. #!ifdef WITH_PRESENCE
  453.     if (!t_newtran()) {
  454.         sl_reply_error();
  455.         exit;
  456.     }
  457.  
  458.     if(is_method("PUBLISH")) {
  459.         handle_publish();
  460.         t_release();
  461.     } else if(is_method("SUBSCRIBE")) {
  462.         handle_subscribe();
  463.         t_release();
  464.     }
  465.     exit;
  466. #!endif
  467.  
  468.     # if presence enabled, this part will not be executed
  469.     if (is_method("PUBLISH") || $rU==$null) {
  470.         sl_send_reply("404", "Not here");
  471.         exit;
  472.     }
  473.     return;
  474. }
  475.  
  476. # IP authorization and user authentication
  477. route[AUTH] {
  478. #!ifdef WITH_AUTH
  479.     if (is_method("REGISTER|MESSAGE") || from_uri==myself) {
  480.         xlogl("L_NOTICE", "[$rm] -> Auth requested from $fU \n");
  481.  
  482. #!ifdef WITH_MESSAGE
  483.         if(is_method("MESSAGE")) {
  484.             xlogl("L_NOTICE", "[$rm] -> is_method(MESSAGE) for $fU \n");
  485.             if(src_ip==myself) {
  486.                 xlogl("L_NOTICE", "[$rm] -> src_ip == myself for $fU \n");
  487.                 xlogl("L_NOTICE", "[$rm] -> UAS will deliver stored messages for $fU \n");
  488.                 if (!sl_send_reply("202", "Accepted and Delivering")) {
  489.                     sl_reply_error();
  490.                 }
  491.                 return;
  492.             }
  493.         }
  494. #!endif
  495.  
  496.         # authenticate requests
  497.         if (!auth_check("$fd", "subscriber", "1")) {
  498.             auth_challenge("$fd", "0");
  499.             xlogl("L_NOTICE", "[$rm] -> Auth Challenge sent for $fU \n");
  500.             exit;
  501.         }
  502.         # user authenticated - remove auth header
  503.         if(!is_method("REGISTER|PUBLISH")) {
  504.             consume_credentials();
  505.             xlogl("L_NOTICE", "[$rm] -> Auth request Accpeted for $fU credentials consumed \n");
  506.         }
  507.     }
  508.     # if caller is not local subscriber, then check if it calls
  509.     # a local destination, otherwise deny, not an open relay here
  510.     if (from_uri!=myself && uri!=myself) {
  511.         xlogl("L_NOTICE", "[$rm] -> request not relaying \n");
  512.         sl_send_reply("403","Not relaying");
  513.         exit;
  514.     }
  515.  
  516. #!endif
  517.     return;
  518. }
  519.  
  520. # Wrapper for relaying requests
  521. route[RELAY] {
  522.     # enable additional event routes for forwarded requests
  523.     # - serial forking, RTP relaying handling, a.s.o.
  524.     if (is_method("INVITE|BYE|SUBSCRIBE|UPDATE")) {
  525.         if(!t_is_set("branch_route")) t_on_branch("MANAGE_BRANCH");
  526.     }
  527.     if (is_method("INVITE|SUBSCRIBE|UPDATE|MESSAGE")) {
  528.         if(!t_is_set("onreply_route")) t_on_reply("MANAGE_REPLY");
  529.     }
  530.     //if (is_method("INVITE|MESSAGE")) {
  531.     //  if(!t_is_set("failure_route")) t_on_failure("MANAGE_FAILURE");
  532.     //}
  533.  
  534.     if (!t_relay()) {
  535.         sl_reply_error();
  536.     }
  537.     exit;
  538. }
  539.  
  540. # Handle requests within SIP dialogs
  541. route[WITHINDLG] {
  542.     if (!has_totag()) return;
  543.  
  544.     # sequential request withing a dialog should
  545.     # take the path determined by record-routing
  546.     if (loose_route()) {
  547.         route(DLGURI);
  548.         if (is_method("BYE")) {
  549.             setflag(FLT_ACC); # do accounting ...
  550.             setflag(FLT_ACCFAILED); # ... even if the transaction fails
  551.         } else if ( is_method("ACK") ) {
  552.             # ACK is forwarded statelessly
  553.             route(NATMANAGE);
  554.         } else if ( is_method("NOTIFY") ) {
  555.             # Add Record-Route for in-dialog NOTIFY as per RFC 6665.
  556.             record_route();
  557.         }
  558.         route(RELAY);
  559.         exit;
  560.     }
  561.  
  562.     if (is_method("SUBSCRIBE") && uri == myself) {
  563.         # in-dialog subscribe requests
  564.         route(PRESENCE);
  565.         exit;
  566.     }
  567.     if ( is_method("ACK") ) {
  568.         if ( t_check_trans() ) {
  569.             # no loose-route, but stateful ACK;
  570.             # must be an ACK after a 487
  571.             # or e.g. 404 from upstream server
  572.             route(RELAY);
  573.             exit;
  574.         } else {
  575.             # ACK without matching transaction ... ignore and discard
  576.             exit;
  577.         }
  578.     }
  579.     sl_send_reply("404","Not here");
  580.     exit;
  581. }
  582.  
  583. # Caller NAT detection
  584. route[NATDETECT] {
  585. #!ifdef WITH_NAT
  586.     force_rport();
  587.     if (nat_uac_test("19")) {
  588.         if (is_method("REGISTER")) {
  589.             fix_nated_register();
  590.         } else {
  591.             if(is_first_hop()) {
  592.                 set_contact_alias();
  593.             }
  594.         }
  595.         setflag(FLT_NATS);
  596.     }
  597. #!endif
  598.     return;
  599. }
  600.  
  601. # RTPProxy control and signaling updates for NAT traversal
  602. route[NATMANAGE] {
  603. #!ifdef WITH_NAT
  604.     if (is_request()) {
  605.         if(has_totag()) {
  606.             if(check_route_param("nat=yes")) {
  607.                 setbflag(FLB_NATB);
  608.             }
  609.         }
  610.     }
  611.     if (!(isflagset(FLT_NATS) || isbflagset(FLB_NATB))) return;
  612.  
  613.     if(nat_uac_test("8")) {
  614.         rtpproxy_manage("co");
  615.     } else {
  616.         rtpproxy_manage("cor");
  617.     }
  618.  
  619.     if (is_request()) {
  620.         if (!has_totag()) {
  621.             if(t_is_branch_route()) {
  622.                 add_rr_param(";nat=yes");
  623.             }
  624.         }
  625.     }
  626.     if (is_reply()) {
  627.         if(isbflagset(FLB_NATB)) {
  628.             if(is_first_hop())
  629.                 set_contact_alias();
  630.         }
  631.     }
  632. #!endif
  633.     return;
  634. }
  635.  
  636. # URI update for dialog requests
  637. route[DLGURI] {
  638. #!ifdef WITH_NAT
  639.     if(!isdsturiset()) {
  640.         handle_ruri_alias();
  641.     }
  642. #!endif
  643.     return;
  644. }
  645.  
  646. # XMLRPC routing
  647. #!ifdef WITH_XMLRPC
  648. route[XMLRPC] {
  649.     # allow XMLRPC from localhost
  650.     if ((method=="POST" || method=="GET") && (src_ip==127.0.0.1)) {
  651.         # close connection only for xmlrpclib user agents (there is a bug in
  652.         # xmlrpclib: it waits for EOF before interpreting the response).
  653.         if ($hdr(User-Agent) =~ "xmlrpclib")
  654.             set_reply_close();
  655.         set_reply_no_connect();
  656.         dispatch_rpc();
  657.         exit;
  658.     }
  659.     send_reply("403", "Forbidden");
  660.     exit;
  661. }
  662. #!endif
  663.  
  664. # Routing to voicemail server
  665. route[TOVOICEMAIL] {
  666.     return;
  667. }
  668.  
  669. # Manage outgoing branches
  670. branch_route[MANAGE_BRANCH] {
  671.     xlogl("L_INFO", "new branch [$T_branch_idx] to $ru\n");
  672.     route(NATMANAGE);
  673. }
  674.  
  675. # Manage incoming replies
  676. onreply_route[MANAGE_REPLY] {
  677.     xlogl("L_INFO", "[$rm] Incoming reply \n");
  678.     if(status=~"[12][0-9][0-9]") {
  679.         route(NATMANAGE);
  680.     }
  681. }
  682.  
  683. # Manage failure routing cases
  684. failure_route[MANAGE_FAILURE] {
  685.     route(NATMANAGE);
  686.  
  687.     if (t_is_canceled()) exit;
  688.  
  689. #!ifdef WITH_MESSAGE
  690.     if (method=="MESSAGE") {
  691.         xlogl("L_NOTICE", "MSILO: the downstream UA doesn't support MESSAGEs...\n");
  692.     # we have changed the R-URI with the contact address, ignore it now
  693.         if (m_store("$ou")){
  694. //      if (m_store("$avp(11)")){
  695.             xlogl("L_NOTICE", "MSILO: offline message stored for $ou ! \n");
  696.             t_reply("202", "Accepted in failure_route");
  697.         }
  698.         else {
  699.             xlogl("L_ERROR", "MSILO: offline message NOT stored...for $ou \n");
  700.             t_reply("503", "Service Unavailable");
  701.         };
  702.     }
  703. #!endif
  704. }
Add Comment
Please, Sign In to add comment