exec.cfg 930 B

123456789101112131415161718192021222324252627282930313233343536
  1. #!KAMAILIO
  2. #
  3. # this example shows use of ser as stateless redirect server
  4. # which rewrites URIs using an exernal utility
  5. #
  6. # ------------------ module loading ----------------------------------
  7. loadmodule "exec.so"
  8. loadmodule "sl.so"
  9. loadmodule "xlog.so"
  10. # ------------------------- request routing logic -------------------
  11. # main routing logic
  12. request_route {
  13. # for testing purposes, simply okay all REGISTERs
  14. if (method=="REGISTER") {
  15. xlog("REGISTER");
  16. sl_send_reply("200", "ok");
  17. break;
  18. };
  19. # first dump the message to a file using cat command
  20. exec_msg("printenv SRCIP > /tmp/exectest.txt; cat >> /tmp/exectest.txt");
  21. # and then rewrite URI using external utility
  22. # note that the last echo command trashes input parameter
  23. if (exec_dset("echo sip:[email protected];echo sip:[email protected];echo>/dev/null")) {
  24. sl_send_reply("300", "Redirect");
  25. } else {
  26. sl_reply_error();
  27. xlog("rewriting failed\n");
  28. };
  29. }