discovery: update DNS bootstrapper to adhere to new query schema

In this commit, we update the DNS bootstrapper to match the new query
semantics expected by the new DNS server. We no longer hard code the
target DNS host, and instead, we’ll re-use the same target endpoint as
we only need the soaShim in order to establish a direct TCP connection
for the queries.
This commit is contained in:
Olaoluwa Osuntokun 2018-03-14 17:11:08 -07:00
parent 6793f3653e
commit 30019538c4
No known key found for this signature in database
GPG Key ID: 964EA263DD637C21

@ -278,8 +278,9 @@ func NewDNSSeedBootstrapper(seeds [][2]string, lookupHost func(string) ([]string
// address of the authoritative DNS server. Once we have this IP address, we'll
// connect manually over TCP to request the SRV record. This is necessary as
// the records we return are currently too large for a class of resolvers,
// causing them to be filtered out.
func fallBackSRVLookup(soaShim string) ([]*net.SRV, error) {
// causing them to be filtered out. The targetEndPoint is the original end
// point that was meant to be hit.
func fallBackSRVLookup(soaShim string, targetEndPoint string) ([]*net.SRV, error) {
log.Tracef("Attempting to query fallback DNS seed")
// First, we'll lookup the IP address of the server that will act as
@ -297,7 +298,7 @@ func fallBackSRVLookup(soaShim string) ([]*net.SRV, error) {
return nil, err
}
dnsHost := "_nodes._tcp.nodes.lightning.directory."
dnsHost := fmt.Sprintf("_nodes._tcp.%v", targetEndPoint)
dnsConn := &dns.Conn{Conn: conn}
defer dnsConn.Close()
@ -369,8 +370,10 @@ search:
// If we get an error when trying to query via
// the primary seed, we'll fallback to the
// secondary seed before concluding failure.
secondarySeed := dnsSeedTuple[1]
addrs, err = fallBackSRVLookup(secondarySeed)
soaShim := dnsSeedTuple[1]
addrs, err = fallBackSRVLookup(
soaShim, primarySeed,
)
if err != nil {
return nil, err
}