<p>This pull request is definitely not finished and probably not even the right direction so I did not want to spend a lot of time on it, but wanted to continue the discussion from previous PR <a href="https://github.com/OpenSIPS/opensips/pull/474" class="issue-link" title="resolve inet6 records for hosts and prefer them if dns_try_ipv6 is set">#474</a>. This exposes do_srv_lookup from resolve.c poorly because of issue <a href="https://github.com/OpenSIPS/opensips/issues/482" class="issue-link" title="sip_resolvehost srv logic">#482</a>.</p>
<p>This PR is attempting to solve 2 issues per the discussion:<br>
1) Build destination uri from a preferred protocol list that will fall-through until it finds a result.<br>
2) Be able to identify the address family of the host based destination within the script for offering IP6 or IP4 SDP.</p>
<p>The first argument to the method will be populated with the phostport;protocol string as a result from the queries.</p>
<p>The second argument is a semi-colon separated list of protocols to try. As the protocols are tried, they are removed from the list so that the remaining can be retried from a failure_route. If not SRV records are found, it tries to simply resolve the A or AAAA record for the host.</p>
<p>Here is an rudimentary example of how I've been testing it:</p>
<pre><code>branch_route[rtpengine] {
$avp(plist) = "tls;tcp;udp";
if (uri_resolve("$avp(du)", "$avp(plist)")) {
$du = $avp(du); # set the $du to our result
t_on_failure("1");
if ($du =~ "^sip:[0-9]{1,3}\..*$") {
$dlg_val(uas_ipv)="IP4";
} else {
$dlg_val(uas_ipv)="IP6";
}
}
...
}
failure_route[1] {
if (!t_check_status("(5..)|(6..)|(403)")) {
xlog("L_NOTICE","$var(request_log) $rs not acceptable failure\n");
exit;
}
if ($avp(plist)) {
# The first protocol failed, go to the next one.
if (uri_resolve("$avp(du)", "$avp(plist)")) {
t_on_failure("1");
$du = $avp(du);
}
} else {
exit;
}
}
</code></pre>
<hr>
<h4>You can view, comment on, or merge this pull request online at:</h4>
<p> <a href='https://github.com/OpenSIPS/opensips/pull/483'>https://github.com/OpenSIPS/opensips/pull/483</a></p>
<h4>Commit Summary</h4>
<ul>
<li>(discussion only) uri_resolve method added that builds dest uri with support for SRV protocol record fall-through</li>
</ul>
<h4>File Changes</h4>
<ul>
<li>
<strong>A</strong>
<a href="https://github.com/OpenSIPS/opensips/pull/483/files#diff-0">modules/uri/methods.c</a>
(144)
</li>
<li>
<strong>A</strong>
<a href="https://github.com/OpenSIPS/opensips/pull/483/files#diff-1">modules/uri/methods.h</a>
(26)
</li>
<li>
<strong>M</strong>
<a href="https://github.com/OpenSIPS/opensips/pull/483/files#diff-2">modules/uri/uri_mod.c</a>
(36)
</li>
<li>
<strong>M</strong>
<a href="https://github.com/OpenSIPS/opensips/pull/483/files#diff-3">resolve.c</a>
(2)
</li>
<li>
<strong>M</strong>
<a href="https://github.com/OpenSIPS/opensips/pull/483/files#diff-4">resolve.h</a>
(3)
</li>
</ul>
<h4>Patch Links:</h4>
<ul>
<li><a href='https://github.com/OpenSIPS/opensips/pull/483.patch'>https://github.com/OpenSIPS/opensips/pull/483.patch</a></li>
<li><a href='https://github.com/OpenSIPS/opensips/pull/483.diff'>https://github.com/OpenSIPS/opensips/pull/483.diff</a></li>
</ul>
<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br>Reply to this email directly or <a href="https://github.com/OpenSIPS/opensips/pull/483">view it on GitHub</a>.<img alt="" height="1" src="https://github.com/notifications/beacon/AFOciYnxQ_yo-kuemsf_71eZQTF3SxaGks5oD-aDgaJpZM4ELAUw.gif" width="1" /></p>
<div itemscope itemtype="http://schema.org/EmailMessage">
<div itemprop="action" itemscope itemtype="http://schema.org/ViewAction">
<link itemprop="url" href="https://github.com/OpenSIPS/opensips/pull/483"></link>
<meta itemprop="name" content="View Pull Request"></meta>
</div>
<meta itemprop="description" content="View this Pull Request on GitHub"></meta>
</div>