From 679cd9bdcbad024ad9af29a5662ca988b20a150b Mon Sep 17 00:00:00 2001 From: lazedo Date: Thu, 9 Apr 2020 00:10:17 +0000 Subject: [PATCH] simplify internal redirects (#125) * simplify internal redirects * missing comma * another missing comma --- kamailio/default.cfg | 31 ++++++++++--------------------- 1 file changed, 10 insertions(+), 21 deletions(-) diff --git a/kamailio/default.cfg b/kamailio/default.cfg index e5cb096..9cdfcc6 100644 --- a/kamailio/default.cfg +++ b/kamailio/default.cfg @@ -756,13 +756,9 @@ failure_route[INTERNAL_FAULT] # Handle redirects if (t_check_status("302")) { - $var(redirect) = @from.uri.user + "@" + @from.uri.host + "->" - + $T_rpl($(ct{tobody.user})) + "@" + $T_rpl($(ct{tobody.host})); if($T_rpl($hdr(X-Redirect-Server)) != $null) { - $sht(redirects=>$var(redirect)) = $T_rpl($hdr(X-Redirect-Server)); - xlog("L_INFO", "$ci|log|stored redirect mapping $var(redirect) to $T_rpl($hdr(X-Redirect-Server))\n"); + route(INTERNAL_REDIRECT); } - route(INTERNAL_REDIRECT); } else if (!t_check_status("407") && $avp(AVP_REDIRECT_KEY) != $null && $sht(redirects=>$avp(AVP_REDIRECT_KEY)) != $null @@ -809,24 +805,17 @@ failure_route[INTERNAL_FAULT] route[INTERNAL_REDIRECT] { - $var(ds_group) = 1; - $var(contact_uri) = $(ct{tobody.user}) + "@" + $(ct{tobody.host}); - $var(redirect) = @from.uri.user + "@" + @from.uri.host + "->" - + @ruri.user + "@" + @ruri.host; - if ($sht(redirects=>$var(redirect)) != $null) { - $var(prefered_route) = $sht(redirects=>$var(redirect)); - xlog("L_INFO", "$ci|log|found redirect for $var(redirect) : $var(prefered_route)\n"); - $du = $var(prefered_route); - $avp(AVP_REDIRECT_KEY) = $var(redirect); - t_on_branch("MANAGE_BRANCH"); - t_on_reply("INTERNAL_REPLY"); - t_on_failure("INTERNAL_FAULT"); - t_set_fr(0, 1000); - t_relay(); - exit(); - } + xlog("L_INFO", "$ci|log|redirect to $T_rpl($hdr(X-Redirect-Server))\n"); + $du = $T_rpl($hdr(X-Redirect-Server)); + t_on_branch("MANAGE_BRANCH"); + t_on_reply("INTERNAL_REPLY"); + t_on_failure("INTERNAL_FAULT"); + t_set_fr(0, 1000); + t_relay(); + exit(); } + onsend_route { if (isflagset(FLAG_ASSOCIATE_USER) && is_request()) { $var(user_source) = $(ct{tobody.user}) + "@" + $si + ":" + $sp;