Skip to content

Commit

Permalink
Properly filter family by Query Type
Browse files Browse the repository at this point in the history
Only emit A records for IPv4 and AAAA records for IPv6 Queries
  • Loading branch information
Sean-Der committed Mar 20, 2024
1 parent b515cab commit 28bb42c
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -865,19 +865,16 @@ func (c *Conn) readLoop(name string, pktConn ipPacketConn, inboundBufferSize int
var selectedIP net.IP
for _, ip := range ifc.ips {
ipCopy := ip
ipIsV6 := ipCopy.To4() == nil

// match up respective IP types based on question
if queryWantsV4 {
if ipv4 := ipCopy.To4(); ipv4 == nil {
continue
}
} else { // queryWantsV6
if ipv6 := ipCopy.To16(); ipv6 == nil {
continue
} else if !isSupportedIPv6(ipv6, c.multicastPktConnV4 == nil) {
c.log.Debugf("interface %d address not a supported IPv6 address %s", ifIndex, ipCopy)
continue
}
// Query must match family (A for IPv4 and AAAA IPv6)
if queryWantsV4 == ipIsV6 {
continue
}

if ipIsV6 && !isSupportedIPv6(ipCopy, c.multicastPktConnV4 == nil) {
c.log.Debugf("interface %d address not a supported IPv6 address %s", ifIndex, ipCopy)
continue
}

selectedIP = ipCopy
Expand Down

0 comments on commit 28bb42c

Please sign in to comment.