Advertisement
Guest User

Redir Lua script

a guest
Aug 21st, 2014
243
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. root@work:/usr/local/kamailio/etc/kamailio# cat ./routing.lua
  2.  
  3. function sleep(n)
  4. if n > 0 then
  5. os.execute("/bin/ping -i 1 -c " .. (tonumber(n) + 1) .. " localhost > /dev/null")
  6. end
  7. end
  8.  
  9.  
  10. function route_request(name)
  11.  
  12. local method = sr.pv.get("$rm")
  13. if method == "INVITE" then
  14.  
  15. sr.sl.send_reply("100", "Trying...")
  16.  
  17. sleep(5)
  18.  
  19. sr.hdr.append_to_reply("Contact: <sip:1111@1.1.1.1>;q=1\n")
  20.  
  21. sr.tm.t_newtran()
  22. sr.tm.t_reply("302", "Redirect")
  23.  
  24. elseif method == "CANCEL" then
  25. print("Got cancel")
  26.  
  27. elseif method == "ACK" then
  28. sr.tm.t_newtran()
  29. end
  30. end
  31.  
  32. root@work:/usr/local/kamailio/etc/kamailio#
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement