Skip to content

Commit

Permalink
Only warn user of --local-addr is provided explicitly by user (#489)
Browse files Browse the repository at this point in the history
* only warn if user explicitly provided a local addr, otherwise info log

* lint

* error out if user-explicitly supplied IPs won't work

---------

Co-authored-by: Zakir Durumeric <[email protected]>
  • Loading branch information
phillip-stephens and zakird authored Dec 22, 2024
1 parent e038db6 commit 410eb82
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/zdns/resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,13 @@ func (r *Resolver) getConnectionInfo(nameServer *NameServer) (*ConnectionInfo, e
}
}
if localAddr != nil {
log.Warnf("none of the user-supplied local addresses could connect to name server %s, using local address %s", nameServer.String(), localAddr.String())
if (len(r.userPreferredIPv4LocalAddrs) > 0 && localAddr.To4() != nil) || (len(r.userPreferredIPv6LocalAddrs) > 0 && util.IsIPv6(localAddr)) {
// the user provided a local addr. explicitly that won't work, error
log.Fatalf("none of the user-supplied local addresses (%v) could connect to name server %s", userIPs, nameServer.String())
} else {
// user didn't explicitly provide a local addr, this is just a default. Info level so as not to alarm the user
log.Infof("none of the default local addresses could connect to name server %s, using local address %s", nameServer.String(), localAddr.String())
}
}
}
if localAddr == nil {
Expand Down

0 comments on commit 410eb82

Please sign in to comment.