Skip to content

Commit

Permalink
Work around for Alpine (Musl) requiring a non-empty result for AAAA (…
Browse files Browse the repository at this point in the history
…ipv6).
  • Loading branch information
supertypo committed Jul 11, 2023
1 parent 1413fdb commit 9adc21f
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions dns.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package main

import (
"fmt"
"github.com/kaspanet/kaspad/app/appmessage"
"net"
"os"
"strings"
Expand Down Expand Up @@ -178,6 +179,10 @@ func (d *DNSServer) buildDNSResponse(addr *net.UDPAddr, authority dns.RR, dnsMsg
respMsg.Ns = append(respMsg.Ns, authority)
addrs := amgr.GoodAddresses(qtype, includeAllSubnetworks, subnetworkID)
log.Infof("%s: Sending %d addresses", addr, len(addrs))
if len(addrs) == 0 && qtype == dns.TypeAAAA {
// Musl (Alpine) requires non-empty result (work-around):
addrs = append(addrs, appmessage.NewNetAddressIPPort(net.ParseIP("100::"), uint16(0)))
}
for _, a := range addrs {
rr := fmt.Sprintf("%s 30 IN %s %s", dnsMsg.Question[0].Name, atype, a.IP.String())
newRR, err := dns.NewRR(rr)
Expand Down

0 comments on commit 9adc21f

Please sign in to comment.