From 30019538c403369b0478d8afbe34f77ea8aa8471 Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Wed, 14 Mar 2018 17:11:08 -0700 Subject: [PATCH] discovery: update DNS bootstrapper to adhere to new query schema MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- discovery/bootstrapper.go | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/discovery/bootstrapper.go b/discovery/bootstrapper.go index 58eb1fad..507c7fb5 100644 --- a/discovery/bootstrapper.go +++ b/discovery/bootstrapper.go @@ -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 }