Skip to content

Commit

Permalink
More work on DnsStaticLookupClient.
Browse files Browse the repository at this point in the history
  • Loading branch information
alanedwardes committed Aug 4, 2023
1 parent 74da761 commit 7bf9019
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Ae.Dns.Client/Lookup/DnsStaticLookupClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,15 @@ public async Task<DnsMessage> Query(DnsMessage query, CancellationToken token =

if (query.Header.QueryType == DnsQueryType.A || query.Header.QueryType == DnsQueryType.AAAA)
{
var addressFamily = query.Header.QueryType == DnsQueryType.A ? AddressFamily.InterNetwork : AddressFamily.InterNetworkV6;

foreach (var source in _sources)
{
if (source.TryForwardLookup(query.Header.Host, out IList<IPAddress> addresses))
{
return ReturnAddresses(query, addresses, source);
// This might return zero addresses, but that's OK. We must not return an error.
// For reasoning behind this, see https://www.rfc-editor.org/rfc/rfc4074#section-3
return ReturnAddresses(query, addresses.Where(x => x.AddressFamily == addressFamily), source);
}
}
}
Expand Down

0 comments on commit 7bf9019

Please sign in to comment.