Advertisement
load-net

kama_contine

Apr 19th, 2023
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 20.62 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: <[email protected]>
  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. #!define tswitch 1
  207. #!define fswitch 2
  208. /* life time of TCP connection when there is no traffic
  209. * - a bit higher than registration expires to cope with UA behind NAT */
  210. tcp_connection_lifetime=3605
  211.  
  212. /* upper limit for TCP connections (it includes the TLS connections) */
  213. tcp_max_connections=2048
  214.  
  215. #!ifdef WITH_JSONRPC
  216. tcp_accept_no_cl=yes
  217. #!endif
  218.  
  219. #!ifdef WITH_TLS
  220. #enable_tls=yes
  221.  
  222. /* upper limit for TLS connections */
  223. tls_max_connections=2048
  224. #!endif
  225.  
  226. /* set it to yes to enable sctp and load sctp.so module */
  227. enable_sctp=no
  228.  
  229. ####### Custom Parameters #########
  230.  
  231. /* These parameters can be modified runtime via RPC interface
  232. * - see the documentation of 'cfg_rpc' module.
  233. *
  234. * Format: group.id = value 'desc' description
  235. * Access: $sel(cfg_get.group.id) or @cfg_get.group.id */
  236.  
  237. #!ifdef WITH_PSTN
  238. /* PSTN GW Routing
  239. *
  240. * - pstn.gw_ip: valid IP or hostname as string value, example:
  241. * pstn.gw_ip = "10.0.0.101" desc "My PSTN GW Address"
  242. *
  243. * - by default is empty to avoid misrouting */
  244. pstn.gw_ip = "" desc "PSTN GW Address"
  245. pstn.gw_port = "" desc "PSTN GW Port"
  246. #!endif
  247.  
  248. #!ifdef WITH_VOICEMAIL
  249. /* VoiceMail Routing on offline, busy or no answer
  250. *
  251. * - by default Voicemail server IP is empty to avoid misrouting */
  252. voicemail.srv_ip = "" desc "VoiceMail IP Address"
  253. voicemail.srv_port = "5060" desc "VoiceMail Port"
  254. #!endif
  255.  
  256. ####### Modules Section ########
  257.  
  258. /* set paths to location of modules */
  259. # mpath="/usr/lib/x86_64-linux-gnu/kamailio/modules/"
  260.  
  261. #!ifdef WITH_MYSQL
  262. #loadmodule "db_mysql.so"
  263. #!endif
  264.  
  265. #!ifdef WITH_JSONRPC
  266. loadmodule "xhttp.so"
  267. #!endif
  268. loadmodule "jsonrpcs.so"
  269. loadmodule "kex.so"
  270. loadmodule "corex.so"
  271. loadmodule "tm.so"
  272. loadmodule "tmx.so"
  273. loadmodule "sl.so"
  274. loadmodule "rr.so"
  275. loadmodule "pv.so"
  276. loadmodule "maxfwd.so"
  277. loadmodule "usrloc.so"
  278. loadmodule "registrar.so"
  279. loadmodule "textops.so"
  280. loadmodule "textopsx.so"
  281. loadmodule "siputils.so"
  282. loadmodule "xlog.so"
  283. loadmodule "sanity.so"
  284. loadmodule "ctl.so"
  285. loadmodule "cfg_rpc.so"
  286. loadmodule "acc.so"
  287. loadmodule "counters.so"
  288. loadmodule "db_postgres.so"
  289. loadmodule "dialog.so"
  290. loadmodule "uac.so"
  291.  
  292. #!define DBURL "postgres://kamailio:[email protected]:5432/kamailio"
  293.  
  294. #!ifdef WITH_AUTH
  295. loadmodule "auth.so"
  296. loadmodule "auth_db.so"
  297. #!ifdef WITH_IPAUTH
  298. loadmodule "permissions.so"
  299. #!endif
  300. #!endif
  301.  
  302. #!ifdef WITH_ALIASDB
  303. loadmodule "alias_db.so"
  304. #!endif
  305.  
  306. #!ifdef WITH_SPEEDDIAL
  307. loadmodule "speeddial.so"
  308. #!endif
  309.  
  310. #!ifdef WITH_MULTIDOMAIN
  311. loadmodule "domain.so"
  312. #!endif
  313.  
  314. #!ifdef WITH_PRESENCE
  315. loadmodule "presence.so"
  316. loadmodule "presence_xml.so"
  317. #!endif
  318.  
  319. #!ifdef WITH_NAT
  320. loadmodule "nathelper.so"
  321. #!ifdef WITH_RTPENGINE
  322. loadmodule "rtpengine.so"
  323. #!else
  324. loadmodule "rtpproxy.so"
  325. #!endif
  326. #!endif
  327.  
  328. #!ifdef WITH_TLS
  329. loadmodule "tls.so"
  330. #!endif
  331.  
  332. #!ifdef WITH_ANTIFLOOD
  333. loadmodule "htable.so"
  334. loadmodule "pike.so"
  335. #!endif
  336.  
  337. #!ifdef WITH_DEBUG
  338. loadmodule "debugger.so"
  339. #!endif
  340.  
  341. # ----------------- setting module-specific parameters ---------------
  342.  
  343. # ----- jsonrpcs params -----
  344. modparam("jsonrpcs", "pretty_format", 1)
  345. /* set the path to RPC fifo control file */
  346. # modparam("jsonrpcs", "fifo_name", "/run/kamailio/kamailio_rpc.fifo")
  347. /* set the path to RPC unix socket control file */
  348. # modparam("jsonrpcs", "dgram_socket", "/run/kamailio/kamailio_rpc.sock")
  349. #!ifdef WITH_JSONRPC
  350. modparam("jsonrpcs", "transport", 7)
  351. #!endif
  352.  
  353. # ----- ctl params -----
  354. /* set the path to RPC unix socket control file */
  355. # modparam("ctl", "binrpc", "unix:/run/kamailio/kamailio_ctl")
  356.  
  357. # ----- sanity params -----
  358. modparam("sanity", "autodrop", 0)
  359.  
  360. # ----- tm params -----
  361. # auto-discard branches from previous serial forking leg
  362. modparam("tm", "failure_reply_mode", 3)
  363. # default retransmission timeout: 30sec
  364. modparam("tm", "fr_timer", 30000)
  365. # default invite retransmission timeout after 1xx: 120sec
  366. modparam("tm", "fr_inv_timer", 120000)
  367.  
  368. # ----- rr params -----
  369. # set next param to 1 to add value to ;lr param (helps with some UAs)
  370. modparam("rr", "enable_full_lr", 0)
  371. # do not append from tag to the RR (no need for this script)
  372. modparam("rr", "append_fromtag", 1)
  373.  
  374. # ----- registrar params -----
  375. modparam("registrar", "method_filtering", 1)
  376. /* uncomment the next line to disable parallel forking via location */
  377. # modparam("registrar", "append_branches", 0)
  378. /* uncomment the next line not to allow more than 10 contacts per AOR */
  379. # modparam("registrar", "max_contacts", 10)
  380. /* max value for expires of registrations */
  381. modparam("registrar", "max_expires", 3600)
  382. /* set it to 1 to enable GRUU */
  383. modparam("registrar", "gruu_enabled", 0)
  384. /* set it to 0 to disable Path handling */
  385. modparam("registrar", "use_path", 1)
  386. /* save Path even if not listed in Supported header */
  387. modparam("registrar", "path_mode", 0)
  388.  
  389. # ----- acc params -----
  390. /* what special events should be accounted ? */
  391. modparam("acc", "early_media", 0)
  392. modparam("acc", "report_ack", 0)
  393. modparam("acc", "report_cancels", 0)
  394. /* by default ww do not adjust the direct of the sequential requests.
  395. * if you enable this parameter, be sure the enable "append_fromtag"
  396. * in "rr" module */
  397. modparam("acc", "detect_direction", 0)
  398. /* account triggers (flags) */
  399. modparam("acc", "log_flag", FLT_ACC)
  400. modparam("acc", "log_missed_flag", FLT_ACCMISSED)
  401. modparam("acc", "log_extra",
  402. "src_user=$fU;src_domain=$fd;src_ip=$si;"
  403. "dst_ouser=$tU;dst_user=$rU;dst_domain=$rd")
  404. modparam("acc", "failed_transaction_flag", FLT_ACCFAILED)
  405. /* enhanced DB accounting */
  406. #!ifdef WITH_ACCDB
  407. modparam("acc", "db_flag", FLT_ACC)
  408. modparam("acc", "db_missed_flag", FLT_ACCMISSED)
  409. modparam("acc", "db_url", DBURL)
  410. modparam("acc", "db_extra",
  411. "src_user=$fU;src_domain=$fd;src_ip=$si;"
  412. "dst_ouser=$tU;dst_user=$rU;dst_domain=$rd")
  413. #!endif
  414.  
  415. # ----- usrloc params -----
  416. modparam("usrloc", "timer_interval", 60)
  417. modparam("usrloc", "timer_procs", 1)
  418. modparam("usrloc", "use_domain", MULTIDOMAIN)
  419. /* enable DB persistency for location entries */
  420. #!ifdef WITH_USRLOCDB
  421. modparam("usrloc", "db_url", DBURL)
  422. modparam("usrloc", "db_mode", 1)
  423. #!endif
  424.  
  425. # ----- auth_db params -----
  426. #!ifdef WITH_AUTH
  427. modparam("auth_db", "db_url", DBURL)
  428. modparam("auth_db", "calculate_ha1", yes)
  429. modparam("auth_db", "password_column", "password")
  430. modparam("auth_db", "load_credentials", "")
  431. modparam("auth_db", "use_domain", MULTIDOMAIN)
  432.  
  433. # ----- permissions params -----
  434. #!ifdef WITH_IPAUTH
  435. modparam("permissions", "db_url", DBURL)
  436. modparam("permissions", "db_mode", 1)
  437. #!endif
  438.  
  439. #!endif
  440.  
  441. # ----- alias_db params -----
  442. #!ifdef WITH_ALIASDB
  443. modparam("alias_db", "db_url", DBURL)
  444. modparam("alias_db", "use_domain", MULTIDOMAIN)
  445. #!endif
  446.  
  447. # ----- speeddial params -----
  448. #!ifdef WITH_SPEEDDIAL
  449. modparam("speeddial", "db_url", DBURL)
  450. modparam("speeddial", "use_domain", MULTIDOMAIN)
  451. #!endif
  452.  
  453. # ----- domain params -----
  454. #!ifdef WITH_MULTIDOMAIN
  455. modparam("domain", "db_url", DBURL)
  456. /* register callback to match myself condition with domains list */
  457. modparam("domain", "register_myself", 1)
  458. #!endif
  459.  
  460. #!ifdef WITH_PRESENCE
  461. # ----- presence params -----
  462. modparam("presence", "db_url", DBURL)
  463.  
  464. # ----- presence_xml params -----
  465. modparam("presence_xml", "db_url", DBURL)
  466. modparam("presence_xml", "force_active", 1)
  467. #!endif
  468.  
  469. #!ifdef WITH_NAT
  470. #!ifdef WITH_RTPENGINE
  471. # ----- rtpengine params -----
  472. modparam("rtpengine", "rtpengine_sock", "udp:127.0.0.1:2223")
  473. #!else
  474. # ----- rtpproxy params -----
  475. modparam("rtpproxy", "rtpproxy_sock", "udp:127.0.0.1:7722")
  476. #!endif
  477. # ----- nathelper params -----
  478. modparam("nathelper", "natping_interval", 30)
  479. modparam("nathelper", "ping_nated_only", 1)
  480. modparam("nathelper", "sipping_bflag", FLB_NATSIPPING)
  481. modparam("nathelper", "sipping_from", "sip:[email protected]")
  482.  
  483. # params needed for NAT traversal in other modules
  484. modparam("nathelper|registrar", "received_avp", "$avp(RECEIVED)")
  485. modparam("usrloc", "nat_bflag", FLB_NATB)
  486. #!endif
  487.  
  488. #!ifdef WITH_TLS
  489. # ----- tls params -----
  490. modparam("tls", "config", "/etc/kamailio/tls.cfg")
  491. #!endif
  492.  
  493. #!ifdef WITH_ANTIFLOOD
  494. # ----- pike params -----
  495. modparam("pike", "sampling_time_unit", 2)
  496. modparam("pike", "reqs_density_per_unit", 16)
  497. modparam("pike", "remove_latency", 4)
  498.  
  499. # ----- htable params -----
  500. /* ip ban htable with autoexpire after 5 minutes */
  501. modparam("htable", "htable", "ipban=>size=10;autoexpire=300;initval=0;")
  502. #modparam("auth_db", "load_credentials", "$avp(pass)=password")
  503. #!endif
  504.  
  505. #!ifdef WITH_DEBUG
  506. # ----- debugger params -----
  507. modparam("debugger", "cfgtrace", 1)
  508. modparam("debugger", "log_level_name", "exec")
  509. #!endif
  510.  
  511. ###################
  512.  
  513. # ----- dialog params -----
  514. modparam("dialog", "dlg_flag", 0)
  515. modparam("dialog", "default_timeout", 21600)
  516. modparam("dialog", "db_url", DBURL)
  517. modparam("dialog", "db_mode", 1)
  518. modparam("dialog", "send_bye", 1)
  519. modparam("dialog", "ka_timer", 3)
  520. modparam("dialog", "ka_interval", 30)
  521. modparam("dialog", "ka_failed_limit", 1)
  522. modparam("dialog", "track_cseq_updates", 1)
  523.  
  524. ###################
  525.  
  526. modparam("uac", "reg_db_url", DBURL)
  527. #modparam("uac","auth_username_avp","$avp(auser)")
  528. #modparam("uac","auth_password_avp","$avp(apass)")
  529. #modparam("uac","auth_realm_avp","$avp(arealm)")
  530.  
  531. modparam("uac", "reg_db_table", "uacreg")
  532. modparam("uac", "reg_timer_interval",20)
  533. modparam("uac", "reg_retry_interval",120)
  534. modparam("uac", "reg_contact_addr", "80.79.224.210:5060")
  535. modparam("uac", "reg_active", 1)
  536. modparam("uac", "restore_mode", "auto")
  537.  
  538.  
  539. ##################
  540. #psql -h 10.20.7.123 -U kamailio -W kamailio -c "INSERT INTO dispatcher (setid, destination, description) values ('1', 'sip:10.20.7.110:5060', 'ab 1');"
  541.  
  542. # Dispatcher (rus-kamailio-conf)
  543. loadmodule "dispatcher.so"
  544. modparam("dispatcher", "flags", 2)
  545. modparam("dispatcher", "ds_probing_mode", 1)
  546. modparam("dispatcher", "ds_ping_interval", 10) # ds_ping_interval — мы задаем периодичность отправки healtcheck
  547. modparam("dispatcher", "ds_probing_threshold", 4) #В приведенном примере, прежде чем SIP сервер (хост) из dispatcher списка станет недоступным, необходимо отправить два неудачных запроса.
  548. modparam("dispatcher", "ds_inactive_threshold", 4)
  549. modparam("dispatcher", "db_url", DBURL)
  550.  
  551.  
  552. ###################
  553.  
  554.  
  555. ####### Routing Logic ########
  556.  
  557. /* Main SIP request routing logic
  558. * - processing of any incoming SIP request starts with this route
  559. * - note: this is the same as route { ... } */
  560.  
  561.  
  562.  
  563. ###################################################################
  564.  
  565. request_route {
  566. route(REQINIT);
  567.  
  568. if (is_method("CANCEL")) {
  569. if (t_check_trans()) {
  570. route(RELAY);
  571. }
  572. exit;
  573. }
  574.  
  575. if (is_method("INVITE") || is_method("REGISTER")) {
  576. route(NAT);
  577. }
  578.  
  579. if (is_method("REGISTER")) {
  580. route(AUTH);
  581. }
  582.  
  583. route(DIALOG);
  584. }
  585.  
  586. #################################################################
  587.  
  588. route[REQINIT] {
  589. force_rport();
  590. }
  591.  
  592. ################################################################
  593.  
  594. route[AUTH] {
  595. if (!auth_check("$fd", "subscriber", "1")) {
  596. force_rport();
  597. auth_challenge("$fd", "1");
  598. exit;
  599. }
  600. force_rport();
  601. if (is_method("REGISTER")) {
  602. save("location");
  603. exit;
  604. } else {
  605. return;
  606. }
  607. }
  608.  
  609. ###########################################################
  610.  
  611. route[NAT] {
  612. if (nat_uac_test("19")) {
  613. if (is_method("REGISTER")) {
  614. set_contact_alias();
  615. } else {
  616. if(is_first_hop()) {
  617. set_contact_alias();
  618. }
  619. }
  620. }
  621. return;
  622. }
  623.  
  624. #########################################################
  625.  
  626. route[DIALOG] {
  627. if (!ds_is_from_list("1", "2")) {
  628. setflag(tswitch);
  629. if (is_method("INVITE")) {
  630. route(AUTH);
  631. handle_ruri_alias();
  632. record_route();
  633. route(RELAY);
  634. }
  635. } else {
  636. setflag(fswitch);
  637. if (is_method("INVITE")) {
  638. if (!lookup("location")) {
  639. sl_send_reply("403", "Forbidden");
  640. exit;
  641. }
  642. handle_ruri_alias();
  643. record_route();
  644. route(RELAY);
  645. }
  646. }
  647. if (has_totag()) {
  648. if (loose_route()) {
  649. handle_ruri_alias();
  650. route(RELAY);
  651. }
  652. }
  653. if (is_method("ACK")) {
  654. if ( t_check_trans() ) {
  655. route(RELAY);
  656. exit;
  657. } else {
  658. exit;
  659. }
  660. }
  661. }
  662.  
  663. ########################################################
  664.  
  665. route[RELAY] {
  666. if (has_body("application/sdp")) {
  667. rtpengine_manage("replace-session-connection replace-origin ICE=remove direction=internal direction=external");
  668. }
  669. t_on_reply("REPLY");
  670. if (isflagset(fswitch)) {
  671. t_relay();
  672. }
  673. if (isflagset(tswitch)) {
  674. if (is_method("INVITE")) {
  675. ds_select_dst("1", "4");
  676. }
  677. t_relay();
  678. }
  679. }
  680.  
  681. #######################################################
  682.  
  683. onreply_route[REPLY] {
  684. route(NAT);
  685. if (has_body("application/sdp")) {
  686. rtpengine_manage("replace-session-connection replace-origin ICE=remove direction=internal direction=external");
  687. }
  688. }
  689.  
  690.  
  691.  
  692.  
  693.  
  694.  
  695.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement