Guest User

Untitled

a guest
May 30th, 2023
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.32 KB | None | 0 0
  1. log_level=4
  2. log_stderror=no
  3. log_facility=LOG_LOCAL5
  4. #log_stderror=yes # (cmd line: -E)
  5.  
  6. #TCP parameters
  7. tcp_workers=2
  8. #tcp_send_timeout=1
  9. tcp_connect_timeout=5
  10. memlog=2
  11. disable_dns_blacklist=no
  12.  
  13. tcp_max_connections=2048
  14. # Uncomment these lines to enter debugging mode
  15. #fork=no
  16. #log_stderror=yes
  17. #
  18.  
  19.  
  20. socket=udp:1.1.1.1:5060 AS "ec2-user.xxx.com":5060
  21.  
  22. socket=wss:1.1.1.1:443
  23.  
  24. #socket=wss:20.0.214.64:443
  25. #socket=ws:20.0.214.64:7063
  26.  
  27. #alias="freeswitch-registrar-10x-test.i3clogic.com"
  28.  
  29.  
  30. # ------------------ module loading ----------------------------------
  31.  
  32. #set module path
  33. mpath="/usr/local/lib64/opensips/modules/"
  34.  
  35. # Uncomment this if you want to use SQL database
  36. loadmodule "db_mysql.so"
  37.  
  38. loadmodule "sl.so"
  39. loadmodule "tm.so"
  40. loadmodule "rr.so"
  41. loadmodule "maxfwd.so"
  42. loadmodule "usrloc.so"
  43. loadmodule "signaling.so"
  44. loadmodule "registrar.so"
  45. loadmodule "textops.so"
  46. loadmodule "mi_fifo.so"
  47. #loadmodule "xlog.so"
  48. loadmodule "nathelper.so"
  49. loadmodule "path.so"
  50. loadmodule "domain.so"
  51.  
  52. modparam("path", "enable_double_path", 0)
  53.  
  54. #----proto_udp loading ----
  55. loadmodule "proto_udp.so"
  56.  
  57. #---- tcp protocol loading ----
  58. loadmodule "proto_tcp.so"
  59. #modparam("proto_tcp", "tcp_async", 0)
  60. # ----------------- setting module-specific parameters ---------------
  61. modparam("tm", "fr_timeout", 5)
  62.  
  63. #### SIP MSG OPerationS module
  64. loadmodule "sipmsgops.so"
  65.  
  66.  
  67. # -- mi_fifo params --
  68.  
  69. modparam("mi_fifo", "fifo_name", "/tmp/opensips_fifo")
  70.  
  71. # -- usrloc params --
  72.  
  73. modparam("usrloc", "db_url", "mysql://root:cccl0g1c@localhost/opensips")
  74. modparam("usrloc", "working_mode_preset", "sql-only")
  75. #modparam("usrloc", "use_domain", 1)
  76.  
  77. ### domain module ...
  78.  
  79. modparam("domain", "db_url", "mysql://root:cccl0g1c@localhost/opensips")
  80. modparam("domain", "db_mode", 1)
  81.  
  82.  
  83. # -- rr params --
  84. # add value to ;lr param to make some broken UAs happy
  85. #modparam("rr", "enable_full_lr", 1)
  86.  
  87. modparam("registrar", "tcp_persistent_flag", "TCP_PERSIST_DURATION")
  88.  
  89.  
  90. modparam("registrar|nathelper", "received_avp", "$avp(rcv)")
  91.  
  92.  
  93.  
  94. #### RTPengine protocol
  95. loadmodule "rtpengine.so"
  96.  
  97. ### adding aws rtpengine
  98. modparam("rtpengine", "db_url", "mysql://root:cccl0g1c@localhost/opensips")
  99.  
  100. modparam("rtpengine", "rtpengine_disable_tout", 10)
  101. modparam("rtpengine", "rtpengine_tout", 2)
  102.  
  103. #--- loading tls module -----
  104. loadmodule "proto_tls.so"
  105. modparam("proto_tls", "tls_handshake_timeout", 300050)
  106. #### WebSocket and WebSocketSecure protocol
  107. loadmodule "proto_wss.so"
  108. modparam("proto_wss", "wss_port", 443)
  109. modparam("proto_wss", "wss_max_msg_chunks", 8)
  110.  
  111. loadmodule "tls_openssl.so"
  112.  
  113. loadmodule "proto_ws.so"
  114.  
  115. # Certificate management
  116. loadmodule "tls_mgm.so"
  117.  
  118. #modparam("tls_mgm", "tls_library", "openssl")
  119.  
  120. modparam("tls_mgm", "server_domain", "*.xxx.com")
  121. modparam("tls_mgm", "match_ip_address", "[*.xxx.com]1.1.1.1:443")
  122.  
  123. modparam("tls_mgm", "certificate", "[*.i3clogic.com]/usr/local/etc/opensips/tls/xxx2023.crt")
  124. modparam("tls_mgm", "private_key", "[*.i3clogic.com]/usr/local/etc/opensips/tls/xxx.key")
  125.  
  126.  
  127. modparam("tls_mgm", "require_cert", "[*.i3clogic.com]0")
  128. modparam("tls_mgm", "verify_cert", "[*.i3clogic.com]0")
  129.  
  130.  
  131.  
  132. #loading auth module
  133. loadmodule "auth.so"
  134. loadmodule "auth_db.so"
  135.  
  136. #modparam("auth_db", "db_url", "mysql://root:cccl0g1c@localhost/opensips")
  137.  
  138.  
  139. modparam("auth", "username_spec", "$var(username)")
  140. modparam("auth", "password_spec", "$avp(password)")
  141.  
  142.  
  143. modparam("auth", "disable_nonce_check", 1)
  144. modparam("auth", "nonce_expire", 900)
  145. modparam("auth", "calculate_ha1", 1)
  146.  
  147. modparam("auth_db", "calculate_ha1", yes)
  148. modparam("auth_db", "user_column", "username")
  149.  
  150. modparam("auth_db", "use_domain", 1)
  151.  
  152. modparam("auth_db", "domain_column", "domain")
  153. modparam("auth_db", "password_column", "password")
  154. modparam("auth_db", "load_credentials", "$avp(password)=password")
  155.  
  156.  
  157.  
  158.  
  159.  
  160. #--- load dynamic routing modul --------------
  161. loadmodule "drouting.so"
  162.  
  163. modparam("drouting", "db_url", "mysql://root:cccl0g1c@localhost/opensips")
  164. modparam("drouting", "use_domain", 1)
  165. modparam("drouting", "drd_table", "dr_gateways")
  166. modparam("drouting", "drr_table", "dr_rules")
  167. modparam("drouting", "drg_table", "dr_groups")
  168. modparam("drouting", "drc_table", "dr_carriers")
  169.  
  170. # ------------------------- request routing logic -------------------
  171.  
  172. # main routing logic
  173.  
  174. route{
  175.  
  176. # initial sanity checks -- messages with
  177. # max_forwards==0, or excessively long requests
  178. if (!mf_process_maxfwd_header(10)) {
  179.  
  180. sl_send_reply(483,"Too Many Hops");
  181. exit;
  182. };
  183.  
  184. if ($ml >= 8096 ) {
  185. sl_send_reply(513, "Message too big");
  186. exit;
  187. };
  188.  
  189. if ($rm=="SUBSCRIBE") {
  190. sl_send_reply(405, "Method not allowed");
  191. exit;
  192. }
  193.  
  194. # subsequent messages withing a dialog should take the
  195. # path determined by record-routing
  196. if (loose_route()) {
  197. # mark routing logic in request
  198. xlog("L_NOTICE", " Loose-Route ($rm) r-uri ($ru) : Contact : $ct :callID $ci \n");
  199. route(relay);
  200. exit;
  201. };
  202.  
  203.  
  204. # if(!is_domain_local($td)) {
  205. # xlog( "L_NOTICE", "Call ID:$ci: Method: $rm Invite-when-uri-notmyself" );
  206. # t_reply(403, "Service Blocked");
  207. # exit;
  208. # }
  209.  
  210. if (!$rm=="REGISTER")
  211. {
  212. record_route();
  213. xlog("L_NOTICE", " ($rm) :r-uri ($ru) : Contact : $ct :callID $ci \n");
  214.  
  215. }
  216.  
  217. if (is_domain_local("$td")){
  218. xlog("L_NOTICE", " gateway Route ($rm) r-uri ($ru) : Contact : $ct :callID $ci uri_host_local $rU \n");
  219.  
  220. if($rm=="REGISTER") {
  221. fix_nated_contact();
  222. # fix_nated_register();
  223.  
  224. xlog("SCRIPT: DB_AUTHentication done \n");
  225.  
  226.  
  227. # if (!proxy_authorize("$td", "subscriber")) {
  228. # proxy_challenge("$td", "auth");
  229. # exit;
  230. # };
  231. # consume_credentials();
  232.  
  233.  
  234.  
  235. if (!add_path()) {
  236. sl_send_reply(503, "Internal Path Error");
  237. exit;
  238. };
  239. sethostport("reg-domain.i3clogic.com:7061");
  240. route(1);
  241. exit;
  242.  
  243. }
  244.  
  245. if (is_method("CANCEL")) {
  246. if ( t_check_trans() )
  247. t_relay();
  248. exit;
  249. }
  250.  
  251.  
  252. if(is_method("INVITE")){
  253.  
  254. xlog( "L_NOTICE", " Inside INVITE BLOCK " );
  255. if(is_from_gw() || $rp==5060 || $rp==5505)
  256. {
  257. xlog( "L_NOTICE", "Call ID:$ci: Method: $rm invite-forwarded-to-fs " );
  258. sethostport("fs-domain.i3clogic.com:6060");
  259. route(byoc);
  260. exit;
  261. }
  262.  
  263. }
  264. }
  265. if($rp==5508 || $rp==5507 )
  266. {
  267. route(byoc);
  268. xlog( "L_NOTICE", "Call ID:$ci: Method: $rm Invite-from-FS-for-Byoc" );
  269. exit;
  270. }
  271. else{
  272. route(relay);
  273. exit;
  274. }
  275. }
  276.  
  277.  
  278. route[1] {
  279. xlog("L_NOTICE", " Route-Block ($rs) : Contact : $ct :callID $ci \n");
  280. t_on_reply("1");
  281. if (!t_relay()) {
  282. sl_reply_error();
  283. }
  284. exit;
  285.  
  286. }
  287.  
  288. onreply_route[1] {
  289. xlog("L_NOTICE", " On-Reply-Route ($rs) : Contact : $ct :callID $ci \n");
  290.  
  291. # if (nat_uac_test("32")) {
  292. # fix_nated_contact();
  293. # };
  294. }
  295.  
  296.  
  297. route[relay] {
  298. # for INVITEs enable some additional helper routes
  299.  
  300.  
  301. xlog( "L_NOTICE", " Inside relay_loop receive_protocol:$socket_in(proto) dest_protocol:$rP " );
  302.  
  303. if ($socket_in(proto) == "ws" || $socket_in(proto) == "wss")
  304. {
  305. xlog( "L_NOTICE", " Source flag set " );
  306. setflag("SRC_WS");
  307. }
  308. if($rP == "ws" || $rP == "wss")
  309. {
  310. xlog( "L_NOTICE", " Destinaion flag set " );
  311. setbflag("DST_WS");
  312. }
  313.  
  314.  
  315. if (is_method("INVITE")) {
  316. t_on_branch("handle_nat_srtp");
  317. t_on_reply("handle_nat_srtp");
  318. }
  319. else if ($rm=="BYE|CANCEL") {
  320. rtpengine_delete();
  321. }
  322.  
  323. if (!t_relay()) {
  324. send_reply(500,"Internal Error");
  325. };
  326. exit;
  327. }
  328.  
  329.  
  330.  
  331. branch_route[handle_nat_srtp] {
  332.  
  333. # if (nat_uac_test("1")) {
  334. # fix_nated_contact();
  335. # };
  336.  
  337. if (!$rm=="INVITE" || !has_body("application/sdp"))
  338. return;
  339. xlog( "L_NOTICE", "Source IP : $si To Uri : $tu From : $fU Request URI: $oU Call ID:$ci: In HANDLE_NAT_SRTP" );
  340.  
  341.  
  342. if (isflagset("SRC_WS") && isbflagset("DST_WS"))
  343. $var(rtpengine_flags) = "ICE=force-relay DTLS=passive";
  344. else if (isflagset("SRC_WS") && !isbflagset("DST_WS"))
  345. $var(rtpengine_flags) = "RTP/AVP replace-session-connection replace-origin ICE=remove";
  346. else if (!isflagset("SRC_WS") && isbflagset("DST_WS"))
  347. $var(rtpengine_flags) = "UDP/TLS/RTP/SAVPF rtcp-mux-offer ICE=force";
  348. else if (!isflagset("SRC_WS") && !isbflagset("DST_WS"))
  349. $var(rtpengine_flags) = "RTP/AVP replace-session-connection replace-origin ICE=remove";
  350.  
  351.  
  352. rtpengine_offer("$var(rtpengine_flags)");
  353. xlog( "L_NOTICE", "Call ID:$ci: RTPENGINE_OFFER_EXECUTED" );
  354.  
  355. }
  356.  
  357. onreply_route[handle_nat_srtp] {
  358.  
  359.  
  360. if (nat_uac_test(32)) {
  361. fix_nated_contact();
  362. };
  363.  
  364.  
  365. if (!has_body("application/sdp"))
  366. return;
  367.  
  368.  
  369.  
  370. if (isflagset("SRC_WS") && isbflagset("DST_WS"))
  371. $var(rtpengine_flags) = "ICE=force-relay DTLS=passive";
  372. else if (isflagset("SRC_WS") && !isbflagset("DST_WS"))
  373. $var(rtpengine_flags) = "UDP/TLS/RTP/SAVPF rtcp-mux-offer ICE=force";
  374. else if (!isflagset("SRC_WS") && isbflagset("DST_WS"))
  375. $var(rtpengine_flags) = "RTP/AVP replace-session-connection replace-origin ICE=remove";
  376. else if (!isflagset("SRC_WS") && !isbflagset("DST_WS"))
  377. $var(rtpengine_flags) = "RTP/AVP replace-session-connection replace-origin ICE=remove";
  378.  
  379.  
  380. rtpengine_answer("$var(rtpengine_flags)");
  381. xlog( "L_NOTICE", "Call ID:$ci: RTPENGINE_ANSWER_EXECUTED" );
  382.  
  383.  
  384. }
  385.  
  386. route[byoc] {
  387. # for INVITEs enable some additional helper routes
  388.  
  389.  
  390. xlog( "L_NOTICE", " Inside byoc_loop receive_protocol:$socket_in(proto) dest_protocol:$rP " );
  391.  
  392. if ($socket_in(proto) == "ws" || $socket_in(proto) == "wss")
  393. {
  394. xlog( "L_NOTICE", " Source flag set " );
  395. setflag("SRC_WS");
  396. }
  397. if($rP == "ws" || $rP == "wss")
  398. {
  399. xlog( "L_NOTICE", " Destinaion flag set " );
  400. setbflag("DST_WS");
  401. }
  402.  
  403.  
  404. if ($rm=="INVITE") {
  405. t_on_branch("handle_nat_byoc");
  406. t_on_reply("handle_nat_byoc");
  407. }
  408. else if ($rm=="BYE|CANCEL") {
  409. rtpengine_delete();
  410. }
  411.  
  412. if (!t_relay()) {
  413. send_reply(500,"Internal Error");
  414. };
  415. exit;
  416. }
  417.  
  418. branch_route[handle_nat_byoc] {
  419.  
  420. # if (nat_uac_test("1")) {
  421. # fix_nated_contact();
  422. # };
  423.  
  424. if (!$rm=="INVITE" || !has_body("application/sdp"))
  425. return;
  426. xlog( "L_NOTICE", "Source IP : $si To Uri : $tu From : $fU Request URI: $oU Call ID:$ci: In HANDLE_NAT_BYOC" );
  427.  
  428.  
  429. if (isflagset("SRC_WS") && isbflagset("DST_WS"))
  430. $var(rtpengine_flags) = "ICE=force-relay DTLS=passive";
  431. else if (isflagset("SRC_WS") && !isbflagset("DST_WS"))
  432. $var(rtpengine_flags) = "RTP/AVP replace-session-connection replace-origin ICE=remove";
  433. else if (!isflagset("SRC_WS") && isbflagset("DST_WS"))
  434. $var(rtpengine_flags) = "UDP/TLS/RTP/SAVPF rtcp-mux-offer ICE=force";
  435. else if (!isflagset("SRC_WS") && !isbflagset("DST_WS"))
  436. $var(rtpengine_flags) = "RTP/AVP replace-session-connection replace-origin ICE=remove";
  437.  
  438.  
  439. rtpengine_offer("$var(rtpengine_flags)");
  440. xlog( "L_NOTICE", "Call ID:$ci: RTPENGINE_OFFER_EXECUTED" );
  441.  
  442. }
  443.  
  444. onreply_route[handle_nat_byoc] {
  445.  
  446.  
  447. # if (nat_uac_test("32")) {
  448. # fix_nated_contact();
  449. # };
  450.  
  451.  
  452. if (!has_body("application/sdp"))
  453. return;
  454.  
  455. if (isflagset("SRC_WS") && isbflagset("DST_WS"))
  456. $var(rtpengine_flags) = "ICE=force-relay DTLS=passive";
  457. else if (isflagset("SRC_WS") && !isbflagset("DST_WS"))
  458. $var(rtpengine_flags) = "UDP/TLS/RTP/SAVPF rtcp-mux-offer ICE=force";
  459. else if (!isflagset("SRC_WS") && isbflagset("DST_WS"))
  460. $var(rtpengine_flags) = "RTP/AVP replace-session-connection replace-origin ICE=remove";
  461. else if (!isflagset("SRC_WS") && !isbflagset("DST_WS"))
  462. $var(rtpengine_flags) = "RTP/AVP replace-session-connection replace-origin ICE=remove";
  463.  
  464.  
  465. rtpengine_answer("$var(rtpengine_flags)");
  466. xlog( "L_NOTICE", "Call ID:$ci: RTPENGINE_ANSWER_EXECUTED" );
  467.  
  468.  
  469. }
  470.  
Advertisement
Add Comment
Please, Sign In to add comment