Advertisement
load-net

kamailio no dispatcher

May 30th, 2023
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 22.88 KB | None | 0 0
  1. #!KAMAILIO
  2. #
  3. # Kamailio (OpenSER) SIP Server v5.4 - default configuration script
  4. # - web: https://www.kamailio.org
  5. # - git: https://github.com/kamailio/kamailio
  6. #
  7. # Direct your questions about this file to: <[email protected]>
  8. #
  9. # Refer to the Core CookBook at https://www.kamailio.org/wiki/
  10. # for an explanation of possible statements, functions and parameters.
  11. #
  12. # Note: the comments can be:
  13. # - lines starting with #, but not the pre-processor directives,
  14. # which start with #!, like #!define, #!ifdef, #!endif, #!else, #!trydef,
  15. # #!subst, #!substdef, ...
  16. # - lines starting with //
  17. # - blocks enclosed in between /* */
  18. # Note: the config performs symmetric SIP signaling
  19. # - it sends the reply to the source address of the request
  20. # - remove the use of force_rport() for asymmetric SIP signaling
  21. #
  22. # Several features can be enabled using '#!define WITH_FEATURE' directives:
  23. #
  24. # *** To run in debug mode:
  25. #!define WITH_DEBUG
  26. # - debug level increased to 3, logs still sent to syslog
  27. # - debugger module loaded with cfgtrace endabled
  28. #
  29. # *** To enable mysql:
  30. # - define WITH_MYSQL
  31. #
  32. # *** To enable authentication execute:
  33. # - enable mysql
  34. #!define WITH_AUTH
  35. # - add users using 'kamctl' or 'kamcli'
  36. #
  37. # *** To enable IP authentication execute:
  38. # - enable mysql
  39. # - enable authentication
  40. #!define WITH_IPAUTH
  41. # - add IP addresses with group id '1' to 'address' table
  42. #
  43. # *** To enable persistent user location execute:
  44. # - enable mysql
  45. #!define WITH_USRLOCDB
  46. #
  47. # *** To enable presence server execute:
  48. # - enable mysql
  49. # - define WITH_PRESENCE
  50. # - if modified headers or body in config must be used by presence handling:
  51. # - define WITH_MSGREBUILD
  52. #
  53. # *** To enable nat traversal execute:
  54. #!define WITH_NAT
  55. # - option for NAT SIP OPTIONS keepalives: WITH_NATSIPPING
  56. # - install RTPProxy: http://www.rtpproxy.org
  57. # - start RTPProxy:
  58. # rtpproxy -l _your_public_ip_ -s udp:localhost:7722
  59. #
  60. # *** To use RTPEngine (instead of RTPProxy) for nat traversal execute:
  61. #!define WITH_RTPENGINE
  62. # - install RTPEngine: https://github.com/sipwise/rtpengine
  63. # - start RTPEngine:
  64. # rtpengine --listen-ng=127.0.0.1:2223 ...
  65. #
  66. # *** To enable PSTN gateway routing execute:
  67. # - define WITH_PSTN
  68. # - set the value of pstn.gw_ip
  69. # - check route[PSTN] for regexp routing condition
  70. #
  71. # *** To enable database aliases lookup execute:
  72. # - enable mysql
  73. # - define WITH_ALIASDB
  74. #
  75. # *** To enable speed dial lookup execute:
  76. # - enable mysql
  77. # - define WITH_SPEEDDIAL
  78. #
  79. # *** To enable multi-domain support execute:
  80. # - enable mysql
  81. # - define WITH_MULTIDOMAIN
  82. #
  83. # *** To enable TLS support execute:
  84. # - adjust CFGDIR/tls.cfg as needed
  85. # - define WITH_TLS
  86. #
  87. # *** To enable JSONRPC over HTTP(S) support execute:
  88. # - define WITH_JSONRPC
  89. # - adjust event_route[xhttp:request] for access policy
  90. #
  91. # *** To enable anti-flood detection execute:
  92. # - adjust pike and htable=>ipban settings as needed (default is
  93. # block if more than 16 requests in 2 seconds and ban for 300 seconds)
  94. # - define WITH_ANTIFLOOD
  95. #
  96. # *** To block 3XX redirect replies execute:
  97. # - define WITH_BLOCK3XX
  98. #
  99. # *** To block 401 and 407 authentication replies execute:
  100. # - define WITH_BLOCK401407
  101. #
  102. # *** To enable VoiceMail routing execute:
  103. # - define WITH_VOICEMAIL
  104. # - set the value of voicemail.srv_ip
  105. # - adjust the value of voicemail.srv_port
  106. #
  107. # *** To enhance accounting execute:
  108. # - enable mysql
  109. # - define WITH_ACCDB
  110. # - add following columns to database
  111. #!ifdef ACCDB_COMMENT
  112. ALTER TABLE acc ADD COLUMN src_user VARCHAR(64) NOT NULL DEFAULT '';
  113. ALTER TABLE acc ADD COLUMN src_domain VARCHAR(128) NOT NULL DEFAULT '';
  114. ALTER TABLE acc ADD COLUMN src_ip varchar(64) NOT NULL default '';
  115. ALTER TABLE acc ADD COLUMN dst_ouser VARCHAR(64) NOT NULL DEFAULT '';
  116. ALTER TABLE acc ADD COLUMN dst_user VARCHAR(64) NOT NULL DEFAULT '';
  117. ALTER TABLE acc ADD COLUMN dst_domain VARCHAR(128) NOT NULL DEFAULT '';
  118. ALTER TABLE missed_calls ADD COLUMN src_user VARCHAR(64) NOT NULL DEFAULT '';
  119. ALTER TABLE missed_calls ADD COLUMN src_domain VARCHAR(128) NOT NULL DEFAULT '';
  120. ALTER TABLE missed_calls ADD COLUMN src_ip varchar(64) NOT NULL default '';
  121. ALTER TABLE missed_calls ADD COLUMN dst_ouser VARCHAR(64) NOT NULL DEFAULT '';
  122. ALTER TABLE missed_calls ADD COLUMN dst_user VARCHAR(64) NOT NULL DEFAULT '';
  123. ALTER TABLE missed_calls ADD COLUMN dst_domain VARCHAR(128) NOT NULL DEFAULT '';
  124. #!endif
  125.  
  126. ####### Include Local Config If Exists #########
  127. import_file "kamailio-local.cfg"
  128.  
  129. ####### Defined Values #########
  130.  
  131. # *** Value defines - IDs used later in config
  132. #!ifdef WITH_DEBUG
  133. #!define DBGLEVEL 3
  134. #!else
  135. #!define DBGLEVEL 2
  136. #!endif
  137.  
  138. #!ifdef WITH_MYSQL
  139. # - database URL - used to connect to database server by modules such
  140. # as: auth_db, acc, usrloc, a.s.o.
  141. #!trydef DBURL "mysql://kamailio:kamailiorw@localhost/kamailio"
  142. #!endif
  143.  
  144. #!ifdef WITH_MULTIDOMAIN
  145. # - the value for 'use_domain' parameters
  146. #!define MULTIDOMAIN 1
  147. #!else
  148. #!define MULTIDOMAIN 0
  149. #!endif
  150.  
  151. # - flags
  152. # FLT_ - per transaction (message) flags
  153. # FLB_ - per branch flags
  154. #!define FLT_ACC 1
  155. #!define FLT_ACCMISSED 2
  156. #!define FLT_ACCFAILED 3
  157. #!define FLT_NATS 5
  158.  
  159. #!define FLB_NATB 6
  160. #!define FLB_NATSIPPING 7
  161.  
  162. ####### Global Parameters #########
  163.  
  164. /* LOG Levels: 3=DBG, 2=INFO, 1=NOTICE, 0=WARN, -1=ERR, ... */
  165. debug=3
  166.  
  167. /* set to 'yes' to print log messages to terminal or use '-E' cli option */
  168. log_stderror=no
  169.  
  170. memdbg=5
  171. memlog=5
  172.  
  173. log_facility=LOG_LOCAL0
  174. log_prefix="{$mt $hdr(CSeq) $ci} "
  175.  
  176. /* number of SIP routing processes for each UDP socket
  177. * - value inherited by tcp_children and sctp_children when not set explicitely */
  178. children=8
  179.  
  180. /* uncomment the next line to disable TCP (default on) */
  181. disable_tcp=yes
  182.  
  183. /* number of SIP routing processes for all TCP/TLS sockets */
  184. tcp_children=8
  185.  
  186. /* uncomment the next line to disable the auto discovery of local aliases
  187. * based on reverse DNS on IPs (default on) */
  188. # auto_aliases=no
  189.  
  190. /* add local domain aliases - it can be set many times */
  191. alias="udp:b4oad.sytes.net:5060"
  192.  
  193. /* listen sockets - if none set, Kamailio binds to all local IP addresses
  194. * - basic prototype (full prototype can be found in Wiki - Core Cookbook):
  195. * listen=[proto]:[localip]:[lport] advertise [publicip]:[pport]
  196. * - it can be set many times to add more sockets to listen to */
  197.  
  198. #listen=udp:192.168.20.33
  199. listen=udp:192.168.20.33:5060 advertise b4oad.sytes.net:5060
  200.  
  201. #listen=udp:0.0.0.0:5060
  202. mhomed=1
  203.  
  204. #!define tswitch 1
  205. #!define fswitch 2
  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. loadmodule "htable.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", 2)
  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.  
  502. modparam("htable", "htable", "auth=>size=10;autoexpire=1800;")
  503. modparam("htable", "htable", "ipban=>size=10;autoexpire=300;initval=0;")
  504. modparam("auth_db", "load_credentials", "$avp(pass)=password")
  505. #!endif
  506.  
  507. #!ifdef WITH_DEBUG
  508. # ----- debugger params -----
  509. modparam("debugger", "cfgtrace", 1)
  510. modparam("debugger", "log_level_name", "exec")
  511. #!endif
  512.  
  513. ###################
  514.  
  515. # ----- dialog params -----
  516. modparam("dialog", "dlg_flag", 0)
  517. modparam("dialog", "default_timeout", 21600)
  518. modparam("dialog", "db_url", DBURL)
  519. modparam("dialog", "db_mode", 1)
  520. modparam("dialog", "send_bye", 1)
  521. modparam("dialog", "ka_timer", 3)
  522. modparam("dialog", "ka_interval", 30)
  523. modparam("dialog", "ka_failed_limit", 1)
  524. modparam("dialog", "track_cseq_updates", 1)
  525.  
  526. ###################
  527.  
  528. modparam("uac", "reg_db_url", DBURL)
  529. #modparam("uac","auth_username_avp","$avp(auser)")
  530. #modparam("uac","auth_password_avp","$avp(apass)")
  531. #modparam("uac","auth_realm_avp","$avp(arealm)")
  532.  
  533. modparam("uac", "reg_db_table", "uacreg")
  534. modparam("uac", "reg_timer_interval",20)
  535. modparam("uac", "reg_retry_interval",120)
  536. modparam("uac", "reg_contact_addr", "83.106.78.64:5060")
  537. modparam("uac", "reg_active", 1)
  538. modparam("uac", "restore_mode", "auto")
  539.  
  540.  
  541. ##################
  542.  
  543. # Dispatcher (rus-kamailio-conf)
  544. loadmodule "dispatcher.so"
  545. modparam("dispatcher", "flags", 2)
  546. modparam("dispatcher", "ds_probing_mode", 1)
  547. modparam("dispatcher", "ds_ping_interval", 10) # ds_ping_interval — мы задаем периодичность отправки healtcheck
  548. modparam("dispatcher", "ds_probing_threshold", 4) #В приведенном примере, прежде чем SIP сервер (хост) из dispatcher списка станет недоступным, необходимо отправить два неудачных запроса.
  549. modparam("dispatcher", "ds_inactive_threshold", 4)
  550. modparam("dispatcher", "db_url", DBURL)
  551.  
  552.  
  553. ###################
  554.  
  555.  
  556.  
  557.  
  558.  
  559.  
  560. ####### Routing Logic ########
  561.  
  562. /* Main SIP request routing logic
  563. * - processing of any incoming SIP request starts with this route
  564. * - note: this is the same as route { ... } */
  565.  
  566.  
  567.  
  568. ###################################################################
  569.  
  570. request_route {
  571. route(REQINIT);
  572.  
  573. if (is_method("CANCEL")) {
  574. if (t_check_trans()) {
  575. route(RELAY);
  576. }
  577. exit;
  578. }
  579.  
  580. if (is_method("INVITE") || is_method("REGISTER")) {
  581. route(NAT);
  582. }
  583.  
  584. if (is_method("REGISTER")) {
  585. route(AUTH);
  586. }
  587.  
  588. route(DIALOG);
  589. }
  590.  
  591. #################################################################
  592.  
  593. route[REQINIT] {
  594. if($sht(ipban=>$si) > 5) {
  595. exit;
  596. }
  597. force_rport;
  598. }
  599.  
  600. ################################################################
  601.  
  602. route[AUTH] {
  603. if (sht_match_name("auth", "eq", "$Au")) {
  604. if (!pv_auth_check("$fd", "$sht(auth=>$Au)", "0", "1")) {
  605. auth_challenge("$fd", "1");
  606. $sht(ipban=>$si) = $sht(ipban=>$si) + 1;
  607. exit;
  608. }
  609. consume_credentials();
  610. $sht(ipban=>$si) = $null;
  611. if (is_method("REGISTER")) {
  612. save("location");
  613. exit;
  614. }
  615. } else {
  616. if (!auth_check("$fd", "subscriber", "1")) {
  617. auth_challenge("$fd", "1");
  618. $sht(ipban=>$si) = $sht(ipban=>$si) + 1;
  619. exit;
  620. }
  621. $sht(auth=>$Au) = $avp(pass);
  622. $sht(ipban=>$si) = $null;
  623. consume_credentials();
  624. if (is_method("REGISTER")) {
  625. save("location");
  626. exit;
  627. }
  628. }
  629. }
  630.  
  631. ###########################################################
  632. /*
  633. route[NAT] {
  634. if (nat_uac_test("19")) {
  635. if (is_method("REGISTER")) {
  636. set_contact_alias();
  637. } else {
  638. if(is_first_hop()) {
  639. if (!ds_is_from_list("1", "2")) {
  640. set_contact_alias();
  641. }
  642. }
  643. }
  644. }
  645. return;
  646. }
  647.  
  648. */
  649.  
  650. route[NAT] {
  651. if (nat_uac_test("19")) {
  652. if (is_method("REGISTER")) {
  653. set_contact_alias();
  654. } else {
  655. if(is_first_hop()) {
  656. set_contact_alias();
  657. }
  658. }
  659. }
  660. return;
  661. }
  662.  
  663. #########################################################
  664. /*
  665. route[DIALOG] {
  666. if (!ds_is_from_list("1", "2")) {
  667. setflag(tswitch);
  668. if (is_method("INVITE")) {
  669. route(AUTH);
  670. handle_ruri_alias();
  671. record_route();
  672. route(RELAY);
  673. }
  674. } else {
  675. setflag(fswitch);
  676. if (is_method("INVITE")) {
  677. if (!lookup("location")) {
  678. sl_send_reply("403", "Forbidden");
  679. exit;
  680. }
  681. handle_ruri_alias();
  682. record_route();
  683. route(RELAY);
  684. }
  685. }
  686. if (has_totag()) {
  687. if (loose_route()) {
  688. handle_ruri_alias();
  689. route(RELAY);
  690. }
  691. }
  692. if (is_method("ACK")) {
  693. if ( t_check_trans() ) {
  694. route(RELAY);
  695. exit;
  696. } else {
  697. exit;
  698. }
  699. }
  700. }
  701. */
  702. route[DIALOG] {
  703. if (is_method("INVITE")) {
  704. route(AUTH);
  705. if (!lookup("location")) {
  706. sl_send_reply("403", "Forbidden");
  707. exit;
  708. }
  709. handle_ruri_alias();
  710. record_route();
  711. route(RELAY);
  712. }
  713. if (has_totag()) {
  714. if (loose_route()) {
  715. handle_ruri_alias();
  716. route(RELAY);
  717. }
  718. }
  719. if (is_method("ACK")) {
  720. if ( t_check_trans() ) {
  721. route(RELAY);
  722. exit;
  723. } else {
  724. exit;
  725. }
  726. }
  727. }
  728. ########################################################
  729. /*
  730. route[RELAY] {
  731. if (has_body("application/sdp")) {
  732. rtpengine_manage("replace-session-connection replace-origin ICE=remove direction=internal direction=external");
  733. }
  734. t_on_reply("REPLY");
  735. if (isflagset(fswitch)) {
  736. t_relay();
  737. }
  738. if (isflagset(tswitch)) {
  739. if (is_method("INVITE")) {
  740. ds_select_dst("1", "4");
  741. } t_relay();
  742. }
  743. }
  744. */
  745. route[RELAY] {
  746. if (has_body("application/sdp")) {
  747. rtpengine_manage("replace-session-connection replace-origin ICE=remove direction=internal direction=external");
  748. }
  749. t_on_reply("REPLY");
  750. t_relay();
  751. }
  752.  
  753. #######################################################
  754.  
  755. onreply_route[REPLY] {
  756. route(NAT);
  757. if (has_body("application/sdp")) {
  758. rtpengine_manage("replace-session-connection replace-origin ICE=remove direction=internal direction=external");
  759. }
  760. }
  761.  
  762.  
  763.  
  764.  
  765.  
  766.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement