From 68b7bd7c16fab00025709d3ae06d963527de8da9 Mon Sep 17 00:00:00 2001 From: David Wilkie Date: Tue, 24 Sep 2024 23:33:41 +0700 Subject: [PATCH] WIP --- .../gateway/client_gateway/opensips.cfg | 48 ++++++++++--------- .../gateway/public_gateway/opensips.cfg | 2 +- 2 files changed, 27 insertions(+), 23 deletions(-) diff --git a/components/gateway/client_gateway/opensips.cfg b/components/gateway/client_gateway/opensips.cfg index 1e7339f64..44bc9236e 100644 --- a/components/gateway/client_gateway/opensips.cfg +++ b/components/gateway/client_gateway/opensips.cfg @@ -1,13 +1,13 @@ ####### Global Parameters ######### /* uncomment the following lines to enable debugging */ -debug_mode=no +debug_mode=0 log_level=3 -xlog_level=2 -log_stderror=yes -log_facility=LOG_LOCAL0 - +xlog_level=3 +stderror_enabled=1 +stderror_log_format="json" +syslog_enabled=0 udp_workers=4 /* uncomment the next line to enable the auto temporary blacklisting of @@ -132,7 +132,7 @@ loadmodule "proto_udp.so" # main request routing logic route{ - xlog("L_NOTICE", "Receiving request, method: $rm, source: $si, sdomain: $rd, contact uri: $ct.fields(uri)\n"); + xlog("L_NOTICE", "Receiving request, method: $rm, source: $si, sdomain: $rd, contact uri: $ct.fields(uri)"); # https://kb.smartvox.co.uk/opensips/nat-contact-and-via-fixing-in-sip-part-2/ # https://www.cnblogs.com/zhangxianrong/p/14251867.html @@ -149,7 +149,7 @@ route{ # OPTIONS requests # https://opensips.org/html/docs/modules/3.4.x/options.html if (is_method("OPTIONS")) { - xlog("L_NOTICE", "Received OPTIONS from $fu\n"); + xlog("L_NOTICE", "Received OPTIONS from $fu"); options_reply(); exit; @@ -157,7 +157,7 @@ route{ if (is_method("REGISTER")) { if (isflagset("NAT_FLAG")) { - xlog("L_NOTICE", "NATed register\n"); + xlog("L_NOTICE", "NATed register"); # https://opensips.org/html/docs/modules/3.4.x/nathelper.html#func_fix_nated_register # The function creates a URI consisting of the source IP, port, and protocol # and stores the URI in an Attribute-Value-Pair. @@ -181,7 +181,7 @@ route{ } # store the registration and generate a SIP reply if (!save("location")) - xlog("failed to register AoR $tu\n"); + xlog("failed to register AoR $tu"); exit; } @@ -209,7 +209,7 @@ route{ # validate the sequential request against dialog if ( $DLG_status!=NULL && !validate_dialog() ) { - xlog("In-Dialog $rm from $si (callid=$ci) is not valid according to dialog\n"); + xlog("In-Dialog $rm from $si (callid=$ci) is not valid according to dialog"); fix_route_dialog(); } @@ -237,7 +237,7 @@ route{ # INVITE Requests if (is_domain_local($rd)) { - xlog("L_NOTICE", "Domain is local. INVITE for an inbound call\n"); + xlog("L_NOTICE", "Domain is local. INVITE for an inbound call"); setflag("INBOUND_FLAG"); # https://opensips.org/html/docs/modules/3.4.x/nathelper.html#func_nat_uac_test @@ -249,7 +249,7 @@ route{ # Note we don't need this check for outbound calls since we # can assume the contact is correct if (nat_uac_test("diff-ip-src-contact,diff-port-src-contact")) { - xlog("L_NOTICE", "Fixing nated contact\n "); + xlog("L_NOTICE", "Fixing nated contact"); fix_nated_contact(); } @@ -292,7 +292,7 @@ route{ # preloaded route checking if (loose_route()) { - xlog("L_ERR", "loose_route() returns true for invite!\n"); + xlog("L_ERR", "loose_route() returns true for invite!"); xlog("L_ERR", "Attempt to route with preloaded Route's [$fu/$tu/$ru/$ci]"); if (!is_method("ACK")) send_reply(403,"Preload Route denied"); @@ -331,13 +331,17 @@ route{ } if (isflagset("INBOUND_FLAG")) { - xlog("L_NOTICE", "Load balancing request on port $rp\n"); - xlog("L_NOTICE", "Starting LB with resources: gw\n"); + xlog("L_NOTICE", "Load balancing request on port $rp"); + xlog("L_NOTICE", "Starting LB with resources: gw"); - if ( !lb_start(1,"gw")) { + if ( lb_start(1,"gw")) { + xlog("L_NOTICE", "Load balancing call to $dd"); + $avp(lb_dest) = $dd; + } else { send_reply(500,"No Destination available"); exit; } + } t_on_failure("GW_FAILOVER"); } @@ -347,7 +351,7 @@ route{ } route[RELAY] { - xlog("L_NOTICE", "Engage Media Proxy in $rm\n"); + xlog("L_NOTICE", "Engage Media Proxy in $rm"); rtpengine_manage(); @@ -358,8 +362,8 @@ route[RELAY] { } onreply_route[RELAY] { - xlog("L_NOTICE", "On REPLY ROUTE from method: $rm, source: $si, reply status: $rs, contact uri: $ct.fields(uri)\n"); - xlog("L_NOTICE", "Engaging Media Proxy\n"); + xlog("L_NOTICE", "On REPLY ROUTE from method: $rm, source: $si, reply status: $rs, contact uri: $ct.fields(uri)"); + xlog("L_NOTICE", "Engaging Media Proxy"); rtpengine_manage(); @@ -371,7 +375,7 @@ onreply_route[RELAY] { # Note: This should only happen on reply from a client behind a NAT. if (nat_uac_test("diff-ip-src-contact,diff-port-src-contact")) { - xlog("L_NOTICE", "Fixing nated contact\n "); + xlog("L_NOTICE", "Fixing nated contact"); fix_nated_contact(); } @@ -384,7 +388,7 @@ failure_route[GW_FAILOVER] { # failure detection with redirect to next available trunk if (t_check_status("(408)|([56][0-9][0-9])")) { - xlog("Failed trunk $rd/$du detected \n"); + xlog("L_NOTICE", "$T_reply_code-lb-response-error-$avp(lb_dest)"); if ( lb_next() ) { t_on_failure("GW_FAILOVER"); @@ -392,7 +396,7 @@ failure_route[GW_FAILOVER] { exit; } - send_reply(500,"All GW are down"); + send_reply(500, "All GW are down"); } } diff --git a/components/gateway/public_gateway/opensips.cfg b/components/gateway/public_gateway/opensips.cfg index ed4a82420..f257b8339 100644 --- a/components/gateway/public_gateway/opensips.cfg +++ b/components/gateway/public_gateway/opensips.cfg @@ -281,7 +281,7 @@ failure_route[GW_FAILOVER] { # failure detection with redirect to next available trunk if (t_check_status("(408)|([56][0-9][0-9])")) { - xlog("L_CRIT", "$T_reply_code-lb-response-error-$avp(lb_dest)"); + xlog("L_NOTICE", "$T_reply_code-lb-response-error-$avp(lb_dest)"); if ( lb_next() ) { t_on_failure("GW_FAILOVER");