mirror of
https://github.com/Control-D-Inc/ctrld.git
synced 2026-08-10 13:20:33 +02:00
Workaround issue with weird DNS server when bootstraping
We see in practice on fresh new VM test, there's a DNS server that return the answer with record not for the query domain. To workaround this, filter out the answers not for the query domain.
This commit is contained in:
+8
-1
@@ -140,11 +140,18 @@ func lookupIP(domain string, timeout int, withBootstrapDNS bool) (ips []string)
|
|||||||
if timeout > 0 && timeout < timeoutMs {
|
if timeout > 0 && timeout < timeoutMs {
|
||||||
timeoutMs = timeoutMs
|
timeoutMs = timeoutMs
|
||||||
}
|
}
|
||||||
|
questionDomain := dns.Fqdn(domain)
|
||||||
ipFromRecord := func(record dns.RR) string {
|
ipFromRecord := func(record dns.RR) string {
|
||||||
switch ar := record.(type) {
|
switch ar := record.(type) {
|
||||||
case *dns.A:
|
case *dns.A:
|
||||||
|
if ar.Hdr.Name != questionDomain {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
return ar.A.String()
|
return ar.A.String()
|
||||||
case *dns.AAAA:
|
case *dns.AAAA:
|
||||||
|
if ar.Hdr.Name != questionDomain {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
return ar.AAAA.String()
|
return ar.AAAA.String()
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
@@ -154,7 +161,7 @@ func lookupIP(domain string, timeout int, withBootstrapDNS bool) (ips []string)
|
|||||||
ctx, cancel := context.WithTimeout(context.Background(), time.Duration(timeoutMs)*time.Millisecond)
|
ctx, cancel := context.WithTimeout(context.Background(), time.Duration(timeoutMs)*time.Millisecond)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
m := new(dns.Msg)
|
m := new(dns.Msg)
|
||||||
m.SetQuestion(domain+".", dnsType)
|
m.SetQuestion(questionDomain, dnsType)
|
||||||
m.RecursionDesired = true
|
m.RecursionDesired = true
|
||||||
|
|
||||||
r, err := resolver.Resolve(ctx, m)
|
r, err := resolver.Resolve(ctx, m)
|
||||||
|
|||||||
Reference in New Issue
Block a user