mirror of
https://github.com/Control-D-Inc/ctrld.git
synced 2026-02-03 22:18:39 +00:00
Always use first record from DNS response
This commit is contained in:
committed by
Cuong Manh Le
parent
b0114dfaeb
commit
12512a60da
18
config.go
18
config.go
@@ -205,15 +205,19 @@ func (uc *UpstreamConfig) SetupBootstrapIP() error {
|
||||
if len(r.Answer) == 0 {
|
||||
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:
|
||||
uc.BootstrapIP = ar.A.String()
|
||||
//lint:ignore S1023 false alarm?
|
||||
break
|
||||
return ar.A.String()
|
||||
case *dns.AAAA:
|
||||
uc.BootstrapIP = ar.AAAA.String()
|
||||
//lint:ignore S1023 false alarm?
|
||||
return ar.AAAA.String()
|
||||
}
|
||||
return ""
|
||||
}
|
||||
for _, a := range r.Answer {
|
||||
if ip := bootstrapIP(a); ip != "" {
|
||||
uc.BootstrapIP = ip
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user