Maksym_Shcherbakov

https://blog.ipcalls24.com/invite-in-kamailio/

Feb 14th, 2021
1,490
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.67 KB | None | 0 0
  1. #!define DBURL "postgres://kamailio:secret_password@localhost:5433/kamailio"
  2.  
  3.  
  4. loadmodule "pv.so"
  5. loadmodule "ctl.so"
  6. loadmodule "jsonrpcs.so"
  7. loadmodule "tm.so"
  8. loadmodule "textops.so"
  9. loadmodule "sl.so"
  10. loadmodule "usrloc.so"
  11. loadmodule "registrar.so"
  12. loadmodule "auth.so"
  13. loadmodule "db_postgres.so"
  14. loadmodule "auth_db.so"
  15. loadmodule "siputils.so"
  16. loadmodule "nathelper.so"
  17.  
  18. loadmodule "rr.so"
  19.  
  20. #############[Подключение к БД]###########
  21. modparam("auth_db", "db_url", DBURL); # указываем URL для подключения, берем его из ранее созданной директивы DBURL
  22.  
  23. request_route {
  24.         route(REQINIT);
  25.  
  26.         if (is_method("CANCEL")) {
  27.                 if (t_check_trans()) {
  28.                         route(RELAY);
  29.                 }
  30.                 exit;
  31.         }
  32.  
  33.         if (is_method("INVITE") || is_method("REGISTER")) {
  34.                 route(NAT);
  35.         }
  36.  
  37.         if (is_method("REGISTER")) {
  38.                 route(AUTH);
  39.         }
  40.  
  41.         route(DIALOG);
  42. }
  43.  
  44. route[REQINIT] {
  45.         force_rport;
  46. }
  47.  
  48. route[AUTH] {
  49.                 if (!auth_check("$fd", "subscriber", "1")) {
  50.                         auth_challenge("$fd", "1");
  51.                         exit;
  52.                 }
  53.                 if (is_method("REGISTER")) {
  54.                         save("location");
  55.                         exit;
  56.                 } else {
  57.                         return;
  58.                 }
  59. }
  60.  
  61. route[NAT] {
  62.         if (nat_uac_test("19")) {
  63.                 if (is_method("REGISTER")) {
  64.                         set_contact_alias();
  65.                 } else {
  66.                         if(is_first_hop()) {
  67.                                 set_contact_alias();
  68.                         }
  69.                 }
  70.         }
  71.         return;
  72. }
  73.  
  74. route[DIALOG] {
  75.         if (is_method("INVITE")) {
  76.                 route(AUTH);
  77.                 if (!lookup("location")) {
  78.                         sl_send_reply("403", "Forbidden");
  79.                         exit;
  80.                 }
  81.                 handle_ruri_alias();
  82.                 record_route();
  83.                 route(RELAY);
  84.         }
  85.         if (has_totag()) {
  86.                 if (loose_route()) {
  87.                         handle_ruri_alias();
  88.                         route(RELAY);
  89.                 }
  90.         }
  91.         if (is_method("ACK")) {
  92.                 if ( t_check_trans() ) {
  93.                         route(RELAY);
  94.                         exit;
  95.                 } else {
  96.                         exit;
  97.                 }
  98.         }
  99. }
  100.  
  101. route[RELAY] {
  102.         t_on_reply("REPLY");
  103.         t_relay();
  104. }
  105.  
  106. onreply_route[REPLY] {
  107.         route(NAT);
  108. }
Advertisement
Add Comment
Please, Sign In to add comment