Advertisement
load-net

kamilio_start

Apr 5th, 2023
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 19.79 KB | None | 0 0
  1. #https://blog.ipcalls24.com/invite-in-kamailio/
  2.  
  3.  
  4.  
  5. #!KAMAILIO
  6. #
  7. # Kamailio (OpenSER) SIP Server v5.4 - default configuration script
  8. # - web: https://www.kamailio.org
  9. # - git: https://github.com/kamailio/kamailio
  10. #
  11. # Direct your questions about this file to: <sr-users@lists.kamailio.org>
  12. #
  13. # Refer to the Core CookBook at https://www.kamailio.org/wiki/
  14. # for an explanation of possible statements, functions and parameters.
  15. #
  16. # Note: the comments can be:
  17. # - lines starting with #, but not the pre-processor directives,
  18. # which start with #!, like #!define, #!ifdef, #!endif, #!else, #!trydef,
  19. # #!subst, #!substdef, ...
  20. # - lines starting with //
  21. # - blocks enclosed in between /* */
  22. # Note: the config performs symmetric SIP signaling
  23. # - it sends the reply to the source address of the request
  24. # - remove the use of force_rport() for asymmetric SIP signaling
  25. #
  26. # Several features can be enabled using '#!define WITH_FEATURE' directives:
  27. #
  28. # *** To run in debug mode:
  29. #!define WITH_DEBUG
  30. # - debug level increased to 3, logs still sent to syslog
  31. # - debugger module loaded with cfgtrace endabled
  32. #
  33. # *** To enable mysql:
  34. # - define WITH_MYSQL
  35. #
  36. # *** To enable authentication execute:
  37. # - enable mysql
  38. #!define WITH_AUTH
  39. # - add users using 'kamctl' or 'kamcli'
  40. #
  41. # *** To enable IP authentication execute:
  42. # - enable mysql
  43. # - enable authentication
  44. #!define WITH_IPAUTH
  45. # - add IP addresses with group id '1' to 'address' table
  46. #
  47. # *** To enable persistent user location execute:
  48. # - enable mysql
  49. #!define WITH_USRLOCDB
  50. #
  51. # *** To enable presence server execute:
  52. # - enable mysql
  53. # - define WITH_PRESENCE
  54. # - if modified headers or body in config must be used by presence handling:
  55. # - define WITH_MSGREBUILD
  56. #
  57. # *** To enable nat traversal execute:
  58. #!define WITH_NAT
  59. # - option for NAT SIP OPTIONS keepalives: WITH_NATSIPPING
  60. # - install RTPProxy: http://www.rtpproxy.org
  61. # - start RTPProxy:
  62. # rtpproxy -l _your_public_ip_ -s udp:localhost:7722
  63. #
  64. # *** To use RTPEngine (instead of RTPProxy) for nat traversal execute:
  65. #!define WITH_RTPENGINE
  66. # - install RTPEngine: https://github.com/sipwise/rtpengine
  67. # - start RTPEngine:
  68. # rtpengine --listen-ng=127.0.0.1:2223 ...
  69. #
  70. # *** To enable PSTN gateway routing execute:
  71. # - define WITH_PSTN
  72. # - set the value of pstn.gw_ip
  73. # - check route[PSTN] for regexp routing condition
  74. #
  75. # *** To enable database aliases lookup execute:
  76. # - enable mysql
  77. # - define WITH_ALIASDB
  78. #
  79. # *** To enable speed dial lookup execute:
  80. # - enable mysql
  81. # - define WITH_SPEEDDIAL
  82. #
  83. # *** To enable multi-domain support execute:
  84. # - enable mysql
  85. # - define WITH_MULTIDOMAIN
  86. #
  87. # *** To enable TLS support execute:
  88. # - adjust CFGDIR/tls.cfg as needed
  89. # - define WITH_TLS
  90. #
  91. # *** To enable JSONRPC over HTTP(S) support execute:
  92. # - define WITH_JSONRPC
  93. # - adjust event_route[xhttp:request] for access policy
  94. #
  95. # *** To enable anti-flood detection execute:
  96. # - adjust pike and htable=>ipban settings as needed (default is
  97. # block if more than 16 requests in 2 seconds and ban for 300 seconds)
  98. # - define WITH_ANTIFLOOD
  99. #
  100. # *** To block 3XX redirect replies execute:
  101. # - define WITH_BLOCK3XX
  102. #
  103. # *** To block 401 and 407 authentication replies execute:
  104. # - define WITH_BLOCK401407
  105. #
  106. # *** To enable VoiceMail routing execute:
  107. # - define WITH_VOICEMAIL
  108. # - set the value of voicemail.srv_ip
  109. # - adjust the value of voicemail.srv_port
  110. #
  111. # *** To enhance accounting execute:
  112. # - enable mysql
  113. # - define WITH_ACCDB
  114. # - add following columns to database
  115. #!ifdef ACCDB_COMMENT
  116. ALTER TABLE acc ADD COLUMN src_user VARCHAR(64) NOT NULL DEFAULT '';
  117. ALTER TABLE acc ADD COLUMN src_domain VARCHAR(128) NOT NULL DEFAULT '';
  118. ALTER TABLE acc ADD COLUMN src_ip varchar(64) NOT NULL default '';
  119. ALTER TABLE acc ADD COLUMN dst_ouser VARCHAR(64) NOT NULL DEFAULT '';
  120. ALTER TABLE acc ADD COLUMN dst_user VARCHAR(64) NOT NULL DEFAULT '';
  121. ALTER TABLE acc ADD COLUMN dst_domain VARCHAR(128) NOT NULL DEFAULT '';
  122. ALTER TABLE missed_calls ADD COLUMN src_user VARCHAR(64) NOT NULL DEFAULT '';
  123. ALTER TABLE missed_calls ADD COLUMN src_domain VARCHAR(128) NOT NULL DEFAULT '';
  124. ALTER TABLE missed_calls ADD COLUMN src_ip varchar(64) NOT NULL default '';
  125. ALTER TABLE missed_calls ADD COLUMN dst_ouser VARCHAR(64) NOT NULL DEFAULT '';
  126. ALTER TABLE missed_calls ADD COLUMN dst_user VARCHAR(64) NOT NULL DEFAULT '';
  127. ALTER TABLE missed_calls ADD COLUMN dst_domain VARCHAR(128) NOT NULL DEFAULT '';
  128. #!endif
  129.  
  130. ####### Include Local Config If Exists #########
  131. import_file "kamailio-local.cfg"
  132.  
  133. ####### Defined Values #########
  134.  
  135. # *** Value defines - IDs used later in config
  136. #!ifdef WITH_DEBUG
  137. #!define DBGLEVEL 3
  138. #!else
  139. #!define DBGLEVEL 2
  140. #!endif
  141.  
  142. #!ifdef WITH_MYSQL
  143. # - database URL - used to connect to database server by modules such
  144. # as: auth_db, acc, usrloc, a.s.o.
  145. #!trydef DBURL "mysql://kamailio:kamailiorw@localhost/kamailio"
  146. #!endif
  147.  
  148. #!ifdef WITH_MULTIDOMAIN
  149. # - the value for 'use_domain' parameters
  150. #!define MULTIDOMAIN 1
  151. #!else
  152. #!define MULTIDOMAIN 0
  153. #!endif
  154.  
  155. # - flags
  156. # FLT_ - per transaction (message) flags
  157. # FLB_ - per branch flags
  158. #!define FLT_ACC 1
  159. #!define FLT_ACCMISSED 2
  160. #!define FLT_ACCFAILED 3
  161. #!define FLT_NATS 5
  162.  
  163. #!define FLB_NATB 6
  164. #!define FLB_NATSIPPING 7
  165.  
  166. ####### Global Parameters #########
  167.  
  168. /* LOG Levels: 3=DBG, 2=INFO, 1=NOTICE, 0=WARN, -1=ERR, ... */
  169. debug=DBGLEVEL
  170.  
  171. /* set to 'yes' to print log messages to terminal or use '-E' cli option */
  172. log_stderror=no
  173.  
  174. memdbg=5
  175. memlog=5
  176.  
  177. log_facility=LOG_LOCAL0
  178. log_prefix="{$mt $hdr(CSeq) $ci} "
  179.  
  180. /* number of SIP routing processes for each UDP socket
  181. * - value inherited by tcp_children and sctp_children when not set explicitely */
  182. children=8
  183.  
  184. /* uncomment the next line to disable TCP (default on) */
  185. disable_tcp=yes
  186.  
  187. /* number of SIP routing processes for all TCP/TLS sockets */
  188. # tcp_children=8
  189.  
  190. /* uncomment the next line to disable the auto discovery of local aliases
  191. * based on reverse DNS on IPs (default on) */
  192. # auto_aliases=no
  193.  
  194. /* add local domain aliases - it can be set many times */
  195. alias="pdl.sytes.net"
  196.  
  197. /* listen sockets - if none set, Kamailio binds to all local IP addresses
  198. * - basic prototype (full prototype can be found in Wiki - Core Cookbook):
  199. * listen=[proto]:[localip]:[lport] advertise [publicip]:[pport]
  200. * - it can be set many times to add more sockets to listen to */
  201.  
  202. #listen=udp:80.71.214.210:5060
  203. listen=udp:10.20.7.103:5060
  204. #listen=udp:0.0.0.0:5060
  205. mhomed=1
  206.  
  207. /* life time of TCP connection when there is no traffic
  208. * - a bit higher than registration expires to cope with UA behind NAT */
  209. tcp_connection_lifetime=3605
  210.  
  211. /* upper limit for TCP connections (it includes the TLS connections) */
  212. tcp_max_connections=2048
  213.  
  214. #!ifdef WITH_JSONRPC
  215. tcp_accept_no_cl=yes
  216. #!endif
  217.  
  218. #!ifdef WITH_TLS
  219. #enable_tls=yes
  220.  
  221. /* upper limit for TLS connections */
  222. tls_max_connections=2048
  223. #!endif
  224.  
  225. /* set it to yes to enable sctp and load sctp.so module */
  226. enable_sctp=no
  227.  
  228. ####### Custom Parameters #########
  229.  
  230. /* These parameters can be modified runtime via RPC interface
  231. * - see the documentation of 'cfg_rpc' module.
  232. *
  233. * Format: group.id = value 'desc' description
  234. * Access: $sel(cfg_get.group.id) or @cfg_get.group.id */
  235.  
  236. #!ifdef WITH_PSTN
  237. /* PSTN GW Routing
  238. *
  239. * - pstn.gw_ip: valid IP or hostname as string value, example:
  240. * pstn.gw_ip = "10.0.0.101" desc "My PSTN GW Address"
  241. *
  242. * - by default is empty to avoid misrouting */
  243. pstn.gw_ip = "" desc "PSTN GW Address"
  244. pstn.gw_port = "" desc "PSTN GW Port"
  245. #!endif
  246.  
  247. #!ifdef WITH_VOICEMAIL
  248. /* VoiceMail Routing on offline, busy or no answer
  249. *
  250. * - by default Voicemail server IP is empty to avoid misrouting */
  251. voicemail.srv_ip = "" desc "VoiceMail IP Address"
  252. voicemail.srv_port = "5060" desc "VoiceMail Port"
  253. #!endif
  254.  
  255. ####### Modules Section ########
  256.  
  257. /* set paths to location of modules */
  258. # mpath="/usr/lib/x86_64-linux-gnu/kamailio/modules/"
  259.  
  260. #!ifdef WITH_MYSQL
  261. #loadmodule "db_mysql.so"
  262. #!endif
  263.  
  264. #!ifdef WITH_JSONRPC
  265. loadmodule "xhttp.so"
  266. #!endif
  267. loadmodule "jsonrpcs.so"
  268. loadmodule "kex.so"
  269. loadmodule "corex.so"
  270. loadmodule "tm.so"
  271. loadmodule "tmx.so"
  272. loadmodule "sl.so"
  273. loadmodule "rr.so"
  274. loadmodule "pv.so"
  275. loadmodule "maxfwd.so"
  276. loadmodule "usrloc.so"
  277. loadmodule "registrar.so"
  278. loadmodule "textops.so"
  279. loadmodule "textopsx.so"
  280. loadmodule "siputils.so"
  281. loadmodule "xlog.so"
  282. loadmodule "sanity.so"
  283. loadmodule "ctl.so"
  284. loadmodule "cfg_rpc.so"
  285. loadmodule "acc.so"
  286. loadmodule "counters.so"
  287. loadmodule "db_postgres.so"
  288. loadmodule "dialog.so"
  289. loadmodule "uac.so"
  290.  
  291. #!define DBURL "postgres://kamailio:kamailiorw@10.20.7.123:5432/kamailio"
  292.  
  293. #!ifdef WITH_AUTH
  294. loadmodule "auth.so"
  295. loadmodule "auth_db.so"
  296. #!ifdef WITH_IPAUTH
  297. loadmodule "permissions.so"
  298. #!endif
  299. #!endif
  300.  
  301. #!ifdef WITH_ALIASDB
  302. loadmodule "alias_db.so"
  303. #!endif
  304.  
  305. #!ifdef WITH_SPEEDDIAL
  306. loadmodule "speeddial.so"
  307. #!endif
  308.  
  309. #!ifdef WITH_MULTIDOMAIN
  310. loadmodule "domain.so"
  311. #!endif
  312.  
  313. #!ifdef WITH_PRESENCE
  314. loadmodule "presence.so"
  315. loadmodule "presence_xml.so"
  316. #!endif
  317.  
  318. #!ifdef WITH_NAT
  319. loadmodule "nathelper.so"
  320. #!ifdef WITH_RTPENGINE
  321. loadmodule "rtpengine.so"
  322. #!else
  323. loadmodule "rtpproxy.so"
  324. #!endif
  325. #!endif
  326.  
  327. #!ifdef WITH_TLS
  328. loadmodule "tls.so"
  329. #!endif
  330.  
  331. #!ifdef WITH_ANTIFLOOD
  332. loadmodule "htable.so"
  333. loadmodule "pike.so"
  334. #!endif
  335.  
  336. #!ifdef WITH_DEBUG
  337. loadmodule "debugger.so"
  338. #!endif
  339.  
  340. # ----------------- setting module-specific parameters ---------------
  341.  
  342. # ----- jsonrpcs params -----
  343. modparam("jsonrpcs", "pretty_format", 1)
  344. /* set the path to RPC fifo control file */
  345. # modparam("jsonrpcs", "fifo_name", "/run/kamailio/kamailio_rpc.fifo")
  346. /* set the path to RPC unix socket control file */
  347. # modparam("jsonrpcs", "dgram_socket", "/run/kamailio/kamailio_rpc.sock")
  348. #!ifdef WITH_JSONRPC
  349. modparam("jsonrpcs", "transport", 7)
  350. #!endif
  351.  
  352. # ----- ctl params -----
  353. /* set the path to RPC unix socket control file */
  354. # modparam("ctl", "binrpc", "unix:/run/kamailio/kamailio_ctl")
  355.  
  356. # ----- sanity params -----
  357. modparam("sanity", "autodrop", 0)
  358.  
  359. # ----- tm params -----
  360. # auto-discard branches from previous serial forking leg
  361. modparam("tm", "failure_reply_mode", 3)
  362. # default retransmission timeout: 30sec
  363. modparam("tm", "fr_timer", 30000)
  364. # default invite retransmission timeout after 1xx: 120sec
  365. modparam("tm", "fr_inv_timer", 120000)
  366.  
  367. # ----- rr params -----
  368. # set next param to 1 to add value to ;lr param (helps with some UAs)
  369. modparam("rr", "enable_full_lr", 0)
  370. # do not append from tag to the RR (no need for this script)
  371. modparam("rr", "append_fromtag", 1)
  372.  
  373. # ----- registrar params -----
  374. modparam("registrar", "method_filtering", 1)
  375. /* uncomment the next line to disable parallel forking via location */
  376. # modparam("registrar", "append_branches", 0)
  377. /* uncomment the next line not to allow more than 10 contacts per AOR */
  378. # modparam("registrar", "max_contacts", 10)
  379. /* max value for expires of registrations */
  380. modparam("registrar", "max_expires", 3600)
  381. /* set it to 1 to enable GRUU */
  382. modparam("registrar", "gruu_enabled", 0)
  383. /* set it to 0 to disable Path handling */
  384. modparam("registrar", "use_path", 1)
  385. /* save Path even if not listed in Supported header */
  386. modparam("registrar", "path_mode", 0)
  387.  
  388. # ----- acc params -----
  389. /* what special events should be accounted ? */
  390. modparam("acc", "early_media", 0)
  391. modparam("acc", "report_ack", 0)
  392. modparam("acc", "report_cancels", 0)
  393. /* by default ww do not adjust the direct of the sequential requests.
  394. * if you enable this parameter, be sure the enable "append_fromtag"
  395. * in "rr" module */
  396. modparam("acc", "detect_direction", 0)
  397. /* account triggers (flags) */
  398. modparam("acc", "log_flag", FLT_ACC)
  399. modparam("acc", "log_missed_flag", FLT_ACCMISSED)
  400. modparam("acc", "log_extra",
  401. "src_user=$fU;src_domain=$fd;src_ip=$si;"
  402. "dst_ouser=$tU;dst_user=$rU;dst_domain=$rd")
  403. modparam("acc", "failed_transaction_flag", FLT_ACCFAILED)
  404. /* enhanced DB accounting */
  405. #!ifdef WITH_ACCDB
  406. modparam("acc", "db_flag", FLT_ACC)
  407. modparam("acc", "db_missed_flag", FLT_ACCMISSED)
  408. modparam("acc", "db_url", DBURL)
  409. modparam("acc", "db_extra",
  410. "src_user=$fU;src_domain=$fd;src_ip=$si;"
  411. "dst_ouser=$tU;dst_user=$rU;dst_domain=$rd")
  412. #!endif
  413.  
  414. # ----- usrloc params -----
  415. modparam("usrloc", "timer_interval", 60)
  416. modparam("usrloc", "timer_procs", 1)
  417. modparam("usrloc", "use_domain", MULTIDOMAIN)
  418. /* enable DB persistency for location entries */
  419. #!ifdef WITH_USRLOCDB
  420. modparam("usrloc", "db_url", DBURL)
  421. modparam("usrloc", "db_mode", 1)
  422. #!endif
  423.  
  424. # ----- auth_db params -----
  425. #!ifdef WITH_AUTH
  426. modparam("auth_db", "db_url", DBURL)
  427. modparam("auth_db", "calculate_ha1", yes)
  428. modparam("auth_db", "password_column", "password")
  429. modparam("auth_db", "load_credentials", "")
  430. modparam("auth_db", "use_domain", MULTIDOMAIN)
  431.  
  432. # ----- permissions params -----
  433. #!ifdef WITH_IPAUTH
  434. modparam("permissions", "db_url", DBURL)
  435. modparam("permissions", "db_mode", 1)
  436. #!endif
  437.  
  438. #!endif
  439.  
  440. # ----- alias_db params -----
  441. #!ifdef WITH_ALIASDB
  442. modparam("alias_db", "db_url", DBURL)
  443. modparam("alias_db", "use_domain", MULTIDOMAIN)
  444. #!endif
  445.  
  446. # ----- speeddial params -----
  447. #!ifdef WITH_SPEEDDIAL
  448. modparam("speeddial", "db_url", DBURL)
  449. modparam("speeddial", "use_domain", MULTIDOMAIN)
  450. #!endif
  451.  
  452. # ----- domain params -----
  453. #!ifdef WITH_MULTIDOMAIN
  454. modparam("domain", "db_url", DBURL)
  455. /* register callback to match myself condition with domains list */
  456. modparam("domain", "register_myself", 1)
  457. #!endif
  458.  
  459. #!ifdef WITH_PRESENCE
  460. # ----- presence params -----
  461. modparam("presence", "db_url", DBURL)
  462.  
  463. # ----- presence_xml params -----
  464. modparam("presence_xml", "db_url", DBURL)
  465. modparam("presence_xml", "force_active", 1)
  466. #!endif
  467.  
  468. #!ifdef WITH_NAT
  469. #!ifdef WITH_RTPENGINE
  470. # ----- rtpengine params -----
  471. modparam("rtpengine", "rtpengine_sock", "udp:127.0.0.1:2223")
  472. #!else
  473. # ----- rtpproxy params -----
  474. modparam("rtpproxy", "rtpproxy_sock", "udp:127.0.0.1:7722")
  475. #!endif
  476. # ----- nathelper params -----
  477. modparam("nathelper", "natping_interval", 30)
  478. modparam("nathelper", "ping_nated_only", 1)
  479. modparam("nathelper", "sipping_bflag", FLB_NATSIPPING)
  480. modparam("nathelper", "sipping_from", "sip:pinger@kamailio.org")
  481.  
  482. # params needed for NAT traversal in other modules
  483. modparam("nathelper|registrar", "received_avp", "$avp(RECEIVED)")
  484. modparam("usrloc", "nat_bflag", FLB_NATB)
  485. #!endif
  486.  
  487. #!ifdef WITH_TLS
  488. # ----- tls params -----
  489. modparam("tls", "config", "/etc/kamailio/tls.cfg")
  490. #!endif
  491.  
  492. #!ifdef WITH_ANTIFLOOD
  493. # ----- pike params -----
  494. modparam("pike", "sampling_time_unit", 2)
  495. modparam("pike", "reqs_density_per_unit", 16)
  496. modparam("pike", "remove_latency", 4)
  497.  
  498. # ----- htable params -----
  499. /* ip ban htable with autoexpire after 5 minutes */
  500. modparam("htable", "htable", "ipban=>size=10;autoexpire=300;initval=0;")
  501. #modparam("auth_db", "load_credentials", "$avp(pass)=password")
  502. #!endif
  503.  
  504. #!ifdef WITH_DEBUG
  505. # ----- debugger params -----
  506. modparam("debugger", "cfgtrace", 1)
  507. modparam("debugger", "log_level_name", "exec")
  508. #!endif
  509.  
  510. ###################
  511.  
  512. # ----- dialog params -----
  513. modparam("dialog", "dlg_flag", 0)
  514. modparam("dialog", "default_timeout", 21600)
  515. modparam("dialog", "db_url", DBURL)
  516. modparam("dialog", "db_mode", 1)
  517. modparam("dialog", "send_bye", 1)
  518. modparam("dialog", "ka_timer", 3)
  519. modparam("dialog", "ka_interval", 30)
  520. modparam("dialog", "ka_failed_limit", 1)
  521. modparam("dialog", "track_cseq_updates", 1)
  522.  
  523. ###################
  524.  
  525. modparam("uac", "reg_db_url", DBURL)
  526. #modparam("uac","auth_username_avp","$avp(auser)")
  527. #modparam("uac","auth_password_avp","$avp(apass)")
  528. #modparam("uac","auth_realm_avp","$avp(arealm)")
  529.  
  530. modparam("uac", "reg_db_table", "uacreg")
  531. modparam("uac", "reg_timer_interval",20)
  532. modparam("uac", "reg_retry_interval",120)
  533. modparam("uac", "reg_contact_addr", "80.79.224.210:5060")
  534. modparam("uac", "reg_active", 1)
  535. modparam("uac", "restore_mode", "auto")
  536.  
  537.  
  538. ##################
  539.  
  540. # Dispatcher (rus-kamailio-conf)
  541. loadmodule "dispatcher.so"
  542. modparam("dispatcher", "flags", 2)
  543. modparam("dispatcher", "ds_probing_mode", 1)
  544. modparam("dispatcher", "ds_ping_interval", 10) # ds_ping_interval — мы задаем периодичность отправки healtcheck
  545. modparam("dispatcher", "ds_probing_threshold", 4) #В приведенном примере, прежде чем SIP сервер (хост) из dispatcher списка станет недоступным, необходимо отправить два неудачных запроса.
  546. modparam("dispatcher", "ds_inactive_threshold", 4)
  547. modparam("dispatcher", "db_url", DBURL)
  548.  
  549.  
  550. ###################
  551.  
  552.  
  553. ####### Routing Logic ########
  554.  
  555. /* Main SIP request routing logic
  556. * - processing of any incoming SIP request starts with this route
  557. * - note: this is the same as route { ... } */
  558.  
  559.  
  560.  
  561. ###################################################################
  562.  
  563. request_route {
  564. route(REQINIT);
  565.  
  566. if (is_method("CANCEL")) {
  567. if (t_check_trans()) {
  568. route(RELAY);
  569. }
  570. exit;
  571. }
  572.  
  573. if (is_method("INVITE") || is_method("REGISTER")) {
  574. route(NAT);
  575. }
  576.  
  577. if (is_method("REGISTER")) {
  578. route(AUTH);
  579. }
  580.  
  581. route(DIALOG);
  582. }
  583.  
  584. #################################################################
  585.  
  586. route[REQINIT] {
  587. force_rport();
  588. }
  589.  
  590. ################################################################
  591.  
  592. route[AUTH] {
  593. if (!auth_check("$fd", "subscriber", "1")) {
  594. force_rport();
  595. auth_challenge("$fd", "1");
  596. exit;
  597. }
  598. force_rport();
  599. if (is_method("REGISTER")) {
  600. save("location");
  601. exit;
  602. } else {
  603. return;
  604. }
  605. }
  606.  
  607. ###########################################################
  608.  
  609. route[NAT] {
  610. if (nat_uac_test("19")) {
  611. if (is_method("REGISTER")) {
  612. set_contact_alias();
  613. } else {
  614. if(is_first_hop()) {
  615. set_contact_alias();
  616. }
  617. }
  618. }
  619. return;
  620. }
  621.  
  622. #########################################################
  623.  
  624. route[DIALOG] {
  625. if (is_method("INVITE")) {
  626. route(AUTH);
  627. if (!lookup("location")) {
  628. sl_send_reply("403", "Forbidden");
  629. exit;
  630. }
  631. handle_ruri_alias();
  632. record_route();
  633. route(RELAY);
  634. }
  635. if (has_totag()) {
  636. if (loose_route()) {
  637. handle_ruri_alias();
  638. route(RELAY);
  639. }
  640. }
  641. if (is_method("ACK")) {
  642. if ( t_check_trans() ) {
  643. route(RELAY);
  644. exit;
  645. } else {
  646. exit;
  647. }
  648. }
  649. }
  650.  
  651. ########################################################
  652.  
  653. route[RELAY] {
  654. if (has_body("application/sdp")) {
  655. rtpengine_manage("replace-session-connection replace-origin ICE=remove direction=internal direction=external");
  656. }
  657. t_on_reply("REPLY");
  658. t_relay();
  659. }
  660.  
  661.  
  662. #######################################################
  663.  
  664. onreply_route[REPLY] {
  665. route(NAT);
  666. if (has_body("application/sdp")) {
  667. rtpengine_manage("replace-session-connection replace-origin ICE=remove direction=internal direction=external");
  668. }
  669. }
  670.  
  671.  
  672.  
  673.  
  674.  
  675.  
  676.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement