Skip to content

Commit

Permalink
coredns: request must return both IPv6 and IPv4 for recordtype ANY
Browse files Browse the repository at this point in the history
Aardvark-dns must return both `IPv6` and `IPv4` if the DNS request has
record type `ANY` instead of `A` or `AAAA` record type.

Closes: #249

Signed-off-by: Aditya R <[email protected]>
  • Loading branch information
flouthoc committed Nov 10, 2022
1 parent 9331c87 commit 85ddddb
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/dns/coredns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -275,30 +275,33 @@ impl CoreDns {
}
};
if !resolved_ip_list.is_empty() {
if record_type == RecordType::A {
for record_addr in resolved_ip_list {
// Append matched IPv4 if request type is `A` or `ANY`.
if record_type == RecordType::A || record_type == RecordType::ANY {
for record_addr in &resolved_ip_list {
if let IpAddr::V4(ipv4) = record_addr {
req.add_answer(
Record::new()
.set_name(record_name.clone())
.set_ttl(86400)
.set_rr_type(RecordType::A)
.set_dns_class(DNSClass::IN)
.set_rdata(RData::A(ipv4))
.set_rdata(RData::A(*ipv4))
.clone(),
);
}
}
} else if record_type == RecordType::AAAA {
for record_addr in resolved_ip_list {
}
// Append matched IPv6 if request type is `AAAA` or `ANY`.
if record_type == RecordType::AAAA || record_type == RecordType::ANY {
for record_addr in &resolved_ip_list {
if let IpAddr::V6(ipv6) = record_addr {
req.add_answer(
Record::new()
.set_name(record_name.clone())
.set_ttl(86400)
.set_rr_type(RecordType::AAAA)
.set_dns_class(DNSClass::IN)
.set_rdata(RData::AAAA(ipv6))
.set_rdata(RData::AAAA(*ipv6))
.clone(),
);
}
Expand Down

0 comments on commit 85ddddb

Please sign in to comment.