Advertisement
Guest User

Config

a guest
Jul 4th, 2012
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.60 KB | None | 0 0
  1. route{
  2.  
  3.  
  4. if (!mf_process_maxfwd_header("10")) {
  5. sl_send_reply("483","Too Many Hops");
  6. exit;
  7. }
  8.  
  9.  
  10. if($ua=~"friendly-scanner"){
  11. drop();
  12. }
  13.  
  14.  
  15.  
  16.  
  17. if ($Ri == "192.168.88.1") {
  18. ### - Call from Internal Network
  19. ### - if $Ri is equal to the IP address set on our Internal Interface then
  20. ### - the SIP message came from an internal device
  21.  
  22. route(FromInternal);
  23.  
  24. }
  25.  
  26. if ($Ri == "99.XX.XX.161") {
  27. ### - Call from External Network
  28. ### - if $Ri is equal to the IP address set on our Outside Interface then
  29. ### - the SIP message came from the internet
  30. if ($si == "50.XX.XX.156") {
  31. ### - We want to make sure the SIP message
  32. ### - came from our SIP PBX in the cloud
  33. ### - so $si needs to equal our IP address
  34.  
  35. route(FromExternal);
  36. }
  37. }
  38.  
  39.  
  40. exit;
  41. }
  42.  
  43. route[FromInternal] {
  44.  
  45. if (is_method("REGISTER")){
  46.  
  47.  
  48.  
  49. ### - We want to save the internal
  50. ### - devices contact uri so that when messages
  51. ### - come from the PBX we know how to route to the device
  52. save("irock.com","mr","$fu");
  53. };
  54.  
  55. if(!is_method("REGISTER|MESSAGE")){
  56. record_route();
  57. };
  58.  
  59.  
  60. if (has_totag()) {
  61. # sequential request withing a dialog should
  62. # take the path determined by record-routing
  63. if (loose_route()) {
  64.  
  65. if (is_method("BYE")) {
  66. #setflag(1); # do accounting ...
  67. #setflag(3); # ... even if the transaction fails
  68. } else if (is_method("INVITE")) {
  69. # even if in most of the cases is useless, do RR for
  70. # re-INVITEs alos, as some buggy clients do change route set
  71. # during the dialog.
  72. record_route();
  73. }
  74.  
  75.  
  76. force_send_socket(99.XX.XX.161:5060);
  77. t_relay("udp:50.XX.XX.156:5060");
  78. } else {
  79.  
  80. if ( is_method("ACK") ) {
  81. if ( t_check_trans() ) {
  82. # non loose-route, but stateful ACK; must be an ACK after
  83. # a 487 or e.g. 404 from upstream server
  84. force_send_socket(99.XX.XX.161:5060);
  85. t_relay("udp:50.XX.XX.156:5060");
  86. exit;
  87. } else {
  88. # ACK without matching transaction ->
  89. # ignore and discard
  90. exit;
  91. }
  92. }
  93.  
  94. sl_send_reply("404","Not here");
  95. }
  96. exit;
  97. }
  98.  
  99.  
  100. # preloaded route checking
  101. if (loose_route()) {
  102. xlog("L_ERR",
  103. "Attempt to route with preloaded Route's [$fu/$tu/$ru/$ci]");
  104. if (!is_method("ACK"))
  105. sl_send_reply("403","Preload Route denied");
  106. exit;
  107. }
  108.  
  109.  
  110. lookup("irock.com");
  111.  
  112. force_send_socket(99.XX.XX.161:5060);
  113. t_relay("udp:50.XX.XX.156:5060");
  114.  
  115. exit;
  116. }
  117.  
  118. route[FromExternal] {
  119.  
  120. if (has_totag()) {
  121. # sequential request withing a dialog should
  122. # take the path determined by record-routing
  123. if (loose_route()) {
  124. if (is_method("BYE")) {
  125. #setflag(1); # do accounting ...
  126. #setflag(3); # ... even if the transaction fails
  127. } else if (is_method("INVITE")) {
  128. # even if in most of the cases is useless, do RR for
  129. # re-INVITEs alos, as some buggy clients do change route set
  130. # during the dialog.
  131. record_route();
  132. }
  133. # route it out to whatever destination was set by loose_route()
  134. # in $du (destination URI).
  135. t_relay();
  136. } else {
  137.  
  138. if ( is_method("ACK") ) {
  139. if ( t_check_trans() ) {
  140. # non loose-route, but stateful ACK; must be an ACK after
  141. # a 487 or e.g. 404 from upstream server
  142. t_relay();
  143. exit;
  144. } else {
  145. # ACK without matching transaction ->
  146. # ignore and discard
  147. exit;
  148. }
  149. }
  150. sl_send_reply("404","Not here");
  151. }
  152. exit;
  153. }
  154.  
  155.  
  156. lookup("irock.com");
  157.  
  158. ### - SIP message is from our SIP Proxy
  159. t_relay();
  160.  
  161. exit;
  162. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement