<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40" dir="ltr"><head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
span.EmailStyle19
        {mso-style-type:personal-reply;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style>
</head>
<body lang="EN-US" style="text-align:left; direction:ltr;"><div>Hi Ben,</div><div><br></div><div>Thank you. I can see the 401 and 403 responses in the failure route with <span style="font-family: Calibri, sans-serif;">$T_reply_code</span></div><div><span style="font-family: Calibri, sans-serif;"><br></span></div><div><span style="font-family: Calibri, sans-serif;">I really appreciate you taking the time to respond, it's helped me out.</span></div><div><span style="font-family: Calibri, sans-serif;"><br></span></div><div><span style="font-family: Calibri, sans-serif;">Cheers,</span></div><div><span style="font-family: Calibri, sans-serif;">John</span></div><div><br></div><div>On Wed, 2020-09-16 at 13:57 +0000, Ben Newlin wrote:</div><blockquote type="cite" style="margin:0 0 0 .8ex; border-left:2px #729fcf solid;padding-left:1ex">
<div class="WordSection1">
<p class="MsoNormal">John,<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">The status of the response is exposed in several places, depending on your configuration. It can be accessed vis $rs [1], but since failure_route is processing the request you will need to specify the reply context [2], so $(<reply>rs).
 But if you are using the TM module then you can just use $T_reply_code [3].<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">The initial challenge for auth (401/407) will trigger the failure route, so every request will end up in failure route at least once if they are all challenged. But if authentication is successful and 2xx is returned it will not trigger
 the failure route a second time. The only place to see the 2xx status code is in a reply route.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">[1] <a href="https://www.opensips.org/Documentation/Script-CoreVar-3-1#toc77">
https://www.opensips.org/Documentation/Script-CoreVar-3-1#toc77</a><o:p></o:p></p>
<p class="MsoNormal">[2] <a href="https://www.opensips.org/Documentation/Script-CoreVar-3-1">
https://www.opensips.org/Documentation/Script-CoreVar-3-1</a><o:p></o:p></p>
<p class="MsoNormal">[3] <a href="https://opensips.org/docs/modules/3.1.x/tm.html#pv_T_reply_code">
https://opensips.org/docs/modules/3.1.x/tm.html#pv_T_reply_code</a><o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><span style="color:black">Ben Newlin </span><o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal" style="margin-bottom:12.0pt"><b><span style="font-size:12.0pt;color:black">From:
</span></b><span style="font-size:12.0pt;color:black">Users <users-bounces@lists.opensips.org><br>
<b>Date: </b>Wednesday, September 16, 2020 at 9:30 AM<br>
<b>To: </b>OpenSIPS users mailling list <users@lists.opensips.org><br>
<b>Subject: </b>Re: [OpenSIPS-Users] Midregistrar handle failed registrations<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt">I have tried using t_on_failure + failure_route but every registration<br>
ends up in the failure_route branch regardless of whether the<br>
authentication was successful or not.<br>
<br>
Does anyone know how I can capture the response returned from the main<br>
registrar please to know in script whether the register was<br>
authenticated or not?<br>
<br>
On Wed, 2020-09-16 at 17:15 +1000, John Matich - Siptalk wrote:<br>
> How do I capture the response of a failed registration that has been<br>
> passed through to the main registrar and failed to authenticate?<br>
> <br>
> My code is:<br>
> <br>
> if (is_method("REGISTER")) {<br>
>        mid_registrar_save("location");<br>
>        switch ($retcode) {<br>
>        case 1:<br>
>                xlog("L_INFO", "forwarding REGISTER to main<br>
> registrar...\n");<br>
>                $ru = "sip:10.0.0.3:5070";<br>
>                if (!t_relay()) {<br>
>                        send_reply("500", "Server Internal Error 1");<br>
>                }<br>
> <br>
>                break;<br>
>        case 2:<br>
>                xlog("L_INFO", "REGISTER has been absorbed!\n");<br>
>                break;<br>
>        default:<br>
>                xlog("L_ERR", "mid-registrar error!\n");<br>
>                send_reply("500", "Server Internal Error 2");<br>
>        }<br>
> <br>
>        exit;<br>
> }<br>
> <br>
> But there isn't anywhere that I can find to read a failed<br>
> authentication.<br>
> <br>
> <br>
> _______________________________________________<br>
> Users mailing list<br>
> Users@lists.opensips.org<br>
> <a href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users">
https://protect-us.mimecast.com/s/63yIC9rL2vSJZoY2foxKku?domain=lists.opensips.org</a><br>
<br>
<br>
_______________________________________________<br>
Users mailing list<br>
Users@lists.opensips.org<br>
<a href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a><o:p></o:p></p>
</div>
</div>


</blockquote></body></html>