mirror of
https://github.com/Control-D-Inc/ctrld.git
synced 2026-08-10 13:20:33 +02:00
Always use first record from DNS response
This commit is contained in:
@@ -205,15 +205,19 @@ func (uc *UpstreamConfig) SetupBootstrapIP() error {
|
|||||||
if len(r.Answer) == 0 {
|
if len(r.Answer) == 0 {
|
||||||
return errors.New("no answer from bootstrap DNS server")
|
return errors.New("no answer from bootstrap DNS server")
|
||||||
}
|
}
|
||||||
for _, a := range r.Answer {
|
|
||||||
switch ar := a.(type) {
|
bootstrapIP := func(record dns.RR) string {
|
||||||
|
switch ar := record.(type) {
|
||||||
case *dns.A:
|
case *dns.A:
|
||||||
uc.BootstrapIP = ar.A.String()
|
return ar.A.String()
|
||||||
//lint:ignore S1023 false alarm?
|
|
||||||
break
|
|
||||||
case *dns.AAAA:
|
case *dns.AAAA:
|
||||||
uc.BootstrapIP = ar.AAAA.String()
|
return ar.AAAA.String()
|
||||||
//lint:ignore S1023 false alarm?
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
for _, a := range r.Answer {
|
||||||
|
if ip := bootstrapIP(a); ip != "" {
|
||||||
|
uc.BootstrapIP = ip
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user