load-net

GY_KAMA

Jun 20th, 2023
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 14.49 KB | None | 0 0
  1. #!KAMAILIO
  2. #
  3. #!define WITH_DEBUG
  4. #!define WITH_AUTH
  5. #!define WITH_IPAUTH
  6. #!define WITH_USRLOCDB
  7. #!define WITH_NAT
  8. #!define WITH_RTPENGINE
  9. #!ifdef ACCDB_COMMENT
  10. ALTER TABLE acc ADD COLUMN src_user VARCHAR(64) NOT NULL DEFAULT '';
  11. ALTER TABLE acc ADD COLUMN src_domain VARCHAR(128) NOT NULL DEFAULT '';
  12. ALTER TABLE acc ADD COLUMN src_ip varchar(64) NOT NULL default '';
  13. ALTER TABLE acc ADD COLUMN dst_ouser VARCHAR(64) NOT NULL DEFAULT '';
  14. ALTER TABLE acc ADD COLUMN dst_user VARCHAR(64) NOT NULL DEFAULT '';
  15. ALTER TABLE acc ADD COLUMN dst_domain VARCHAR(128) NOT NULL DEFAULT '';
  16. ALTER TABLE missed_calls ADD COLUMN src_user VARCHAR(64) NOT NULL DEFAULT '';
  17. ALTER TABLE missed_calls ADD COLUMN src_domain VARCHAR(128) NOT NULL DEFAULT '';
  18. ALTER TABLE missed_calls ADD COLUMN src_ip varchar(64) NOT NULL default '';
  19. ALTER TABLE missed_calls ADD COLUMN dst_ouser VARCHAR(64) NOT NULL DEFAULT '';
  20. ALTER TABLE missed_calls ADD COLUMN dst_user VARCHAR(64) NOT NULL DEFAULT '';
  21. ALTER TABLE missed_calls ADD COLUMN dst_domain VARCHAR(128) NOT NULL DEFAULT '';
  22. #!endif
  23.  
  24. ####### Include Local Config If Exists #########
  25. import_file "kamailio-local.cfg"
  26.  
  27. ####### Defined Values #########
  28.  
  29. # *** Value defines - IDs used later in config
  30. #!ifdef WITH_DEBUG
  31. #!define DBGLEVEL 3
  32. #!else
  33. #!define DBGLEVEL 2
  34. #!endif
  35.  
  36. #!ifdef WITH_MYSQL
  37. #!trydef DBURL "mysql://kamailio:kamailiorw@localhost/kamailio"
  38. #!endif
  39.  
  40. #!ifdef WITH_MULTIDOMAIN
  41. #!define MULTIDOMAIN 1
  42. #!else
  43. #!define MULTIDOMAIN 0
  44. #!endif
  45.  
  46. #!define FLT_ACC 1
  47. #!define FLT_ACCMISSED 2
  48. #!define FLT_ACCFAILED 3
  49. #!define FLT_NATS 5
  50.  
  51. #!define FLB_NATB 6
  52. #!define FLB_NATSIPPING 7
  53.  
  54. ####### Global Parameters #########
  55.  
  56. /* LOG Levels: 3=DBG, 2=INFO, 1=NOTICE, 0=WARN, -1=ERR, ... */
  57.  
  58. debug=0
  59.  
  60. /* set to 'yes' to print log messages to terminal or use '-E' cli option */
  61. log_stderror=no
  62.  
  63. memdbg=5
  64. memlog=5
  65.  
  66. log_facility=LOG_LOCAL0
  67. log_prefix="{$mt $hdr(CSeq) $ci} "
  68.  
  69. children=8
  70.  
  71. disable_tcp=yes
  72.  
  73. tcp_children=8
  74.  
  75. auto_aliases=no
  76.  
  77.  
  78.  
  79. #!define FLAG_FROM_SWITCH 1
  80. #!define FLAG_FROM_USER 2
  81.  
  82. #!define IPADDRESS "10.20.7.115"
  83. listen=udp:10.20.7.115:5060 advertise 139.164.166.44:5060
  84.  
  85. mhomed=1
  86.  
  87. #!define tswitch 1
  88. #!define fswitch 2
  89.  
  90. /* life time of TCP connection when there is no traffic
  91. * - a bit higher than registration expires to cope with UA behind NAT */
  92. tcp_connection_lifetime=3605
  93.  
  94. /* upper limit for TCP connections (it includes the TLS connections) */
  95. tcp_max_connections=2048
  96.  
  97. #!ifdef WITH_JSONRPC
  98. tcp_accept_no_cl=yes
  99. #!endif
  100.  
  101. #!ifdef WITH_TLS
  102. #enable_tls=yes
  103.  
  104. /* upper limit for TLS connections */
  105. tls_max_connections=2048
  106. #!endif
  107.  
  108. /* set it to yes to enable sctp and load sctp.so module */
  109. enable_sctp=no
  110.  
  111. ####### Custom Parameters #########
  112.  
  113. /* These parameters can be modified runtime via RPC interface
  114. * - see the documentation of 'cfg_rpc' module.
  115. *
  116. * Format: group.id = value 'desc' description
  117. * Access: $sel(cfg_get.group.id) or @cfg_get.group.id */
  118.  
  119. #!ifdef WITH_PSTN
  120. /* PSTN GW Routing
  121. *
  122. * - pstn.gw_ip: valid IP or hostname as string value, example:
  123. * pstn.gw_ip = "10.0.0.101" desc "My PSTN GW Address"
  124. *
  125. * - by default is empty to avoid misrouting */
  126. pstn.gw_ip = "" desc "PSTN GW Address"
  127. pstn.gw_port = "" desc "PSTN GW Port"
  128. #!endif
  129.  
  130. #!ifdef WITH_VOICEMAIL
  131. /* VoiceMail Routing on offline, busy or no answer
  132. *
  133. * - by default Voicemail server IP is empty to avoid misrouting */
  134. voicemail.srv_ip = "" desc "VoiceMail IP Address"
  135. voicemail.srv_port = "5060" desc "VoiceMail Port"
  136. #!endif
  137.  
  138. ####### Modules Section ########
  139.  
  140. /* set paths to location of modules */
  141. mpath="/usr/lib/x86_64-linux-gnu/kamailio/modules/"
  142.  
  143. #!ifdef WITH_MYSQL
  144. #loadmodule "db_mysql.so"
  145. #!endif
  146.  
  147. #!ifdef WITH_JSONRPC
  148. loadmodule "xhttp.so"
  149. #!endif
  150. loadmodule "jsonrpcs.so"
  151. loadmodule "kex.so"
  152. loadmodule "corex.so"
  153. loadmodule "tm.so"
  154. loadmodule "tmx.so"
  155. loadmodule "sl.so"
  156. loadmodule "rr.so"
  157. loadmodule "pv.so"
  158. loadmodule "maxfwd.so"
  159. loadmodule "usrloc.so"
  160. loadmodule "registrar.so"
  161. loadmodule "textops.so"
  162. loadmodule "textopsx.so"
  163. loadmodule "siputils.so"
  164. loadmodule "xlog.so"
  165. loadmodule "sanity.so"
  166. loadmodule "ctl.so"
  167. loadmodule "cfg_rpc.so"
  168. loadmodule "acc.so"
  169. loadmodule "counters.so"
  170. loadmodule "db_postgres.so"
  171. loadmodule "dialog.so"
  172. loadmodule "uac.so"
  173. loadmodule "htable.so"
  174. loadmodule "path.so"
  175. #loadmodule "xlog.so"
  176.  
  177. #!define DBURL "postgres://kamailio:[email protected]:5432/kamailio"
  178.  
  179. #!ifdef WITH_AUTH
  180. loadmodule "auth.so"
  181. loadmodule "auth_db.so"
  182. #!ifdef WITH_IPAUTH
  183. loadmodule "permissions.so"
  184. #!endif
  185. #!endif
  186.  
  187. #!ifdef WITH_ALIASDB
  188. loadmodule "alias_db.so"
  189. #!endif
  190.  
  191. #!ifdef WITH_SPEEDDIAL
  192. loadmodule "speeddial.so"
  193. #!endif
  194.  
  195. #!ifdef WITH_MULTIDOMAIN
  196. loadmodule "domain.so"
  197. #!endif
  198.  
  199. #!ifdef WITH_PRESENCE
  200. loadmodule "presence.so"
  201. loadmodule "presence_xml.so"
  202. #!endif
  203.  
  204. #!ifdef WITH_NAT
  205. loadmodule "nathelper.so"
  206. #!ifdef WITH_RTPENGINE
  207. loadmodule "rtpengine.so"
  208. #!else
  209. loadmodule "rtpproxy.so"
  210. #!endif
  211. #!endif
  212.  
  213. #!ifdef WITH_TLS
  214. loadmodule "tls.so"
  215. #!endif
  216.  
  217. #!ifdef WITH_ANTIFLOOD
  218. loadmodule "htable.so"
  219. loadmodule "pike.so"
  220. #!endif
  221.  
  222. #!ifdef WITH_DEBUG
  223. loadmodule "debugger.so"
  224. #!endif
  225.  
  226. # ----------------- setting module-specific parameters ---------------
  227.  
  228. # ----- jsonrpcs params -----
  229. modparam("jsonrpcs", "pretty_format", 1)
  230. /* set the path to RPC fifo control file */
  231. # modparam("jsonrpcs", "fifo_name", "/run/kamailio/kamailio_rpc.fifo")
  232. /* set the path to RPC unix socket control file */
  233. # modparam("jsonrpcs", "dgram_socket", "/run/kamailio/kamailio_rpc.sock")
  234. #!ifdef WITH_JSONRPC
  235. modparam("jsonrpcs", "transport", 7)
  236. #!endif
  237.  
  238. # ----- ctl params -----
  239. /* set the path to RPC unix socket control file */
  240. # modparam("ctl", "binrpc", "unix:/run/kamailio/kamailio_ctl")
  241.  
  242. # ----- sanity params -----
  243. modparam("sanity", "autodrop", 0)
  244.  
  245. # ----- tm params -----
  246. # auto-discard branches from previous serial forking leg
  247. modparam("tm", "failure_reply_mode", 3)
  248. # default retransmission timeout: 30sec
  249. modparam("tm", "fr_timer", 30000)
  250. # default invite retransmission timeout after 1xx: 120sec
  251. modparam("tm", "fr_inv_timer", 120000)
  252.  
  253. # ----- rr params -----
  254. # set next param to 1 to add value to ;lr param (helps with some UAs)
  255. modparam("rr", "enable_full_lr", 0)
  256. # do not append from tag to the RR (no need for this script)
  257. modparam("rr", "append_fromtag", 1)
  258.  
  259. # ----- registrar params -----
  260. modparam("registrar", "method_filtering", 1)
  261. /* uncomment the next line to disable parallel forking via location */
  262. # modparam("registrar", "append_branches", 0)
  263. /* uncomment the next line not to allow more than 10 contacts per AOR */
  264. # modparam("registrar", "max_contacts", 10)
  265. /* max value for expires of registrations */
  266. modparam("registrar", "max_expires", 3600)
  267. /* set it to 1 to enable GRUU */
  268. modparam("registrar", "gruu_enabled", 0)
  269. /* set it to 0 to disable Path handling */
  270. modparam("registrar", "use_path", 1)
  271. /* save Path even if not listed in Supported header */
  272. modparam("registrar", "path_mode", 0)
  273.  
  274. # ----- acc params -----
  275. /* what special events should be accounted ? */
  276. modparam("acc", "early_media", 0)
  277. modparam("acc", "report_ack", 0)
  278. modparam("acc", "report_cancels", 0)
  279. /* by default ww do not adjust the direct of the sequential requests.
  280. * if you enable this parameter, be sure the enable "append_fromtag"
  281. * in "rr" module */
  282. modparam("acc", "detect_direction", 0)
  283. /* account triggers (flags) */
  284. modparam("acc", "log_flag", FLT_ACC)
  285. modparam("acc", "log_missed_flag", FLT_ACCMISSED)
  286. modparam("acc", "log_extra",
  287. "src_user=$fU;src_domain=$fd;src_ip=$si;"
  288. "dst_ouser=$tU;dst_user=$rU;dst_domain=$rd")
  289. modparam("acc", "failed_transaction_flag", FLT_ACCFAILED)
  290. /* enhanced DB accounting */
  291. #!ifdef WITH_ACCDB
  292. modparam("acc", "db_flag", FLT_ACC)
  293. modparam("acc", "db_missed_flag", FLT_ACCMISSED)
  294. modparam("acc", "db_url", DBURL)
  295. modparam("acc", "db_extra",
  296. "src_user=$fU;src_domain=$fd;src_ip=$si;"
  297. "dst_ouser=$tU;dst_user=$rU;dst_domain=$rd")
  298. #!endif
  299.  
  300. # ----- usrloc params -----
  301. modparam("usrloc", "timer_interval", 60)
  302. modparam("usrloc", "timer_procs", 1)
  303. modparam("usrloc", "use_domain", MULTIDOMAIN)
  304. /* enable DB persistency for location entries */
  305. #!ifdef WITH_USRLOCDB
  306. modparam("usrloc", "db_url", DBURL)
  307. modparam("usrloc", "db_mode", 2)
  308. #!endif
  309.  
  310. # ----- auth_db params -----
  311. #!ifdef WITH_AUTH
  312. modparam("auth_db", "db_url", DBURL)
  313. modparam("auth_db", "calculate_ha1", yes)
  314. modparam("auth_db", "password_column", "password")
  315. modparam("auth_db", "load_credentials", "")
  316. modparam("auth_db", "use_domain", MULTIDOMAIN)
  317.  
  318. # ----- permissions params -----
  319. #!ifdef WITH_IPAUTH
  320. modparam("permissions", "db_url", DBURL)
  321. modparam("permissions", "db_mode", 1)
  322. #!endif
  323.  
  324. #!endif
  325.  
  326. # ----- alias_db params -----
  327. #!ifdef WITH_ALIASDB
  328. modparam("alias_db", "db_url", DBURL)
  329. modparam("alias_db", "use_domain", MULTIDOMAIN)
  330. #!endif
  331.  
  332. # ----- speeddial params -----
  333. #!ifdef WITH_SPEEDDIAL
  334. modparam("speeddial", "db_url", DBURL)
  335. modparam("speeddial", "use_domain", MULTIDOMAIN)
  336. #!endif
  337.  
  338. # ----- domain params -----
  339. #!ifdef WITH_MULTIDOMAIN
  340. modparam("domain", "db_url", DBURL)
  341. /* register callback to match myself condition with domains list */
  342. modparam("domain", "register_myself", 1)
  343. #!endif
  344.  
  345. #!ifdef WITH_PRESENCE
  346. # ----- presence params -----
  347. modparam("presence", "db_url", DBURL)
  348.  
  349. # ----- presence_xml params -----
  350. modparam("presence_xml", "db_url", DBURL)
  351. modparam("presence_xml", "force_active", 1)
  352. #!endif
  353.  
  354. #!ifdef WITH_NAT
  355. #!ifdef WITH_RTPENGINE
  356. # ----- rtpengine params -----
  357. modparam("rtpengine", "rtpengine_sock", "udp:127.0.0.1:2223")
  358. #!else
  359. # ----- rtpproxy params -----
  360. modparam("rtpproxy", "rtpproxy_sock", "udp:127.0.0.1:7722")
  361. #!endif
  362. # ----- nathelper params -----
  363. modparam("nathelper", "natping_interval", 30)
  364. modparam("nathelper", "ping_nated_only", 1)
  365. modparam("nathelper", "sipping_bflag", FLB_NATSIPPING)
  366. modparam("nathelper", "sipping_from", "sip:[email protected]")
  367.  
  368. # params needed for NAT traversal in other modules
  369. modparam("nathelper|registrar", "received_avp", "$avp(RECEIVED)")
  370. modparam("usrloc", "nat_bflag", FLB_NATB)
  371. #!endif
  372.  
  373. #!ifdef WITH_TLS
  374. # ----- tls params -----
  375. modparam("tls", "config", "/etc/kamailio/tls.cfg")
  376. #!endif
  377.  
  378. #!ifdef WITH_ANTIFLOOD
  379. # ----- pike params -----
  380. modparam("pike", "sampling_time_unit", 2)
  381. modparam("pike", "reqs_density_per_unit", 16)
  382. modparam("pike", "remove_latency", 4)
  383.  
  384. # ----- htable params -----
  385. /* ip ban htable with autoexpire after 5 minutes */
  386.  
  387. modparam("htable", "htable", "auth=>size=10;autoexpire=1800;")
  388. modparam("htable", "htable", "ipban=>size=10;autoexpire=300;initval=0;")
  389. modparam("auth_db", "load_credentials", "$avp(pass)=password")
  390. #!endif
  391.  
  392. #!ifdef WITH_DEBUG
  393. # ----- debugger params -----
  394. modparam("debugger", "cfgtrace", 1)
  395. modparam("debugger", "log_level_name", "exec")
  396. #!endif
  397.  
  398. ###################
  399.  
  400. # ----- dialog params -----
  401. modparam("dialog", "dlg_flag", 0)
  402. modparam("dialog", "default_timeout", 21600)
  403. modparam("dialog", "db_url", DBURL)
  404. modparam("dialog", "db_mode", 1)
  405. modparam("dialog", "send_bye", 1)
  406. modparam("dialog", "ka_timer", 3)
  407. modparam("dialog", "ka_interval", 30)
  408. modparam("dialog", "ka_failed_limit", 1)
  409. modparam("dialog", "track_cseq_updates", 1)
  410.  
  411. ###################
  412.  
  413. modparam("uac", "reg_db_url", DBURL)
  414. #modparam("uac","auth_username_avp","$avp(auser)")
  415. #modparam("uac","auth_password_avp","$avp(apass)")
  416. #modparam("uac","auth_realm_avp","$avp(arealm)")
  417.  
  418. modparam("uac", "reg_db_table", "uacreg")
  419. modparam("uac", "reg_timer_interval",20)
  420. modparam("uac", "reg_retry_interval",120)
  421. modparam("uac", "reg_contact_addr", "109.194.166.44:5060")
  422. modparam("uac", "reg_active", 1)
  423. modparam("uac", "restore_mode", "auto")
  424.  
  425.  
  426. ##################
  427.  
  428. # Dispatcher (rus-kamailio-conf)
  429. loadmodule "dispatcher.so"
  430. modparam("dispatcher", "flags", 2)
  431. modparam("dispatcher", "ds_probing_mode", 1)
  432. modparam("dispatcher", "ds_ping_interval", 10)
  433. modparam("dispatcher", "ds_probing_threshold", 4) неудачных запроса.
  434. modparam("dispatcher", "ds_inactive_threshold", 4)
  435. modparam("dispatcher", "db_url", DBURL)
  436.  
  437.  
  438. ###################
  439.  
  440.  
  441.  
  442.  
  443.  
  444.  
  445. ####### Routing Logic ########
  446.  
  447.  
  448.  
  449. route {
  450. xlog("L_INFO","{$rm} arrived from $si:$sp");
  451. route (SANITY_CHECK) ;
  452.  
  453. if (is_method("CANCEL")) {
  454. if (t_check_trans()) {
  455. t_relay();
  456. }
  457. exit;
  458. }
  459.  
  460. route(CHECK_SOURCE_IP) ;
  461. route(WITHINDLG);
  462. t_check_trans();
  463.  
  464. if (is_method("INVITE | REFER")) {
  465. record_route();
  466. }
  467.  
  468. if (is_method("REGISTER")) {
  469. add_path();
  470. }
  471.  
  472. if (isflagset(FLAG_FROM_SWITCH)) {
  473. t_on_reply("EXTERNAL_REPLY");
  474.  
  475. } else {
  476.  
  477. if (!ds_select_dst("1", "4")) {
  478. send_reply("404", "No destination");
  479. exit;
  480. }
  481.  
  482. }
  483.  
  484. #xlog("L_TNFO","{$rm} should be sent to ($ru)");
  485. route (RELAY);
  486.  
  487. }
  488.  
  489.  
  490. route[SANITY_CHECK]
  491. {
  492. if (!sanity_check()) {
  493. xlog("L_WARN", "$ci|end|message is insane");
  494. exit;
  495. }
  496.  
  497. if (!mf_process_maxfwd_header("10")) {
  498. xlog("L_WARN", "$ci]end|too much hops, not enough barley");
  499. send_reply("483", "Too Many Hops");
  500. exit;
  501. }
  502.  
  503. if ($ua == "friendly-scanner" ||
  504. $ua == "sundoyddr" ||
  505. $ua =~ "sipcli" ) {
  506. xlog("L_WARN", "$ci|end|dropping message with user-agent $ua");
  507. exit;
  508. }
  509.  
  510. if ($si+":"+$sp == IPADDRESS+":5060") {
  511. xlog("L_WARN", "$ci|end|dropping message");
  512. exit;
  513.  
  514. }
  515. }
  516.  
  517. route[CHECK_SOURCE_IP] {
  518. if ( ds_is_from_list(1) ) {
  519.  
  520. setflag(FLAG_FROM_SWITCH);
  521. } else {
  522. setflag(FLAG_FROM_USER);
  523. }
  524. }
  525.  
  526.  
  527. route[WITHINDLG]
  528. {
  529. if (has_totag()) {
  530. if (loose_route()) {
  531. route(RELAY) ;
  532. } else {
  533. if (is_method("NOTIFY")) {
  534. route(RELAY) ;
  535. }
  536. if (is_method("SUBSCRIBE") && uri == myself) {
  537. exit;
  538. }
  539. if (is_method("ACK")) {
  540. if (t_check_trans()) {
  541. t_relay();
  542. exit;
  543. } else {
  544. exit;
  545. }
  546. }
  547. sl_send_reply("404","Not here");
  548. }
  549. exit;
  550. }
  551. }
  552.  
  553. onreply_route[EXTERNAL_REPLY]
  554. {
  555. route (NAT_TEST_AND_CORRECT);
  556. }
  557.  
  558.  
  559. route[NAT_TEST_AND_CORRECT]
  560. {
  561. if (nat_uac_test("3")) {
  562. if (is_method("REGISTER")) {
  563. fix_nated_register();
  564. } else {
  565. fix_nated_contact();
  566. }
  567. force_rport();
  568. }
  569. if (has_body("application/sdp") && nat_uac_test("8")) {
  570. fix_nated_sdp("10");
  571. }
  572. }
  573.  
  574.  
  575. route[RELAY] {
  576. xlog(" ----IN RELAY----------$$ru=$ru, $$du=$du--------\n");
  577.  
  578. if (!t_relay()) {
  579. sl_reply_error();
  580. }
  581. exit;
  582. }
  583.  
  584.  
Advertisement
Add Comment
Please, Sign In to add comment