parent
bec7a7f75b
commit
a8769e1df5
|
@ -42,7 +42,7 @@ func main() {
|
|||
// Resolver Options
|
||||
f.Int("timeout", 5, "Sets the timeout for a query to T seconds. The default timeout is 5 seconds.")
|
||||
f.Bool("search", true, "Use the search list provided in resolv.conf. It sets the `ndots` parameter as well unless overridden by `ndots` flag.")
|
||||
f.Int("ndots", 0, "Specify the ndots parameter. Default value is taken from resolv.conf and fallbacks to 1 if ndots statement is missing in resolv.conf")
|
||||
f.Int("ndots", -1, "Specify the ndots parameter. Default value is taken from resolv.conf and fallbacks to 1 if ndots statement is missing in resolv.conf")
|
||||
f.BoolP("ipv4", "4", false, "Use IPv4 only")
|
||||
f.BoolP("ipv6", "6", false, "Use IPv6 only")
|
||||
|
||||
|
|
|
@ -35,6 +35,8 @@ func (hub *Hub) loadNameservers() error {
|
|||
}
|
||||
}
|
||||
|
||||
// Set `ndots` to the user specified value.
|
||||
hub.ResolverOpts.Ndots = hub.QueryFlags.Ndots
|
||||
// fallback to system nameserver
|
||||
// in case no nameserver is specified by user.
|
||||
if len(hub.Nameservers) == 0 {
|
||||
|
@ -42,8 +44,9 @@ func (hub *Hub) loadNameservers() error {
|
|||
if err != nil {
|
||||
return fmt.Errorf("error fetching system default nameserver")
|
||||
}
|
||||
// override if user hasn't specified any value.
|
||||
if hub.QueryFlags.Ndots == 0 {
|
||||
// `-1` indicates the flag is not set.
|
||||
// use from config if user hasn't specified any value.
|
||||
if hub.ResolverOpts.Ndots == -1 {
|
||||
hub.ResolverOpts.Ndots = ndots
|
||||
}
|
||||
if len(search) > 0 && hub.QueryFlags.UseSearchList {
|
||||
|
@ -51,6 +54,11 @@ func (hub *Hub) loadNameservers() error {
|
|||
}
|
||||
hub.Nameservers = append(hub.Nameservers, ns...)
|
||||
}
|
||||
// if the user hasn't given any override of `ndots` AND has
|
||||
// given a custom nameserver. Set `ndots` to 1 as the fallback value
|
||||
if hub.ResolverOpts.Ndots == -1 {
|
||||
hub.ResolverOpts.Ndots = 1
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue