fix: ndots options
parent
646829a72c
commit
94b9c6be15
8
TODO.md
8
TODO.md
|
@ -2,7 +2,7 @@
|
|||
|
||||
## Resolver
|
||||
- [x] Create a DNS Resolver struct
|
||||
- [x]] Add methods to initialise the config, set defaults
|
||||
- [x] Add methods to initialise the config, set defaults
|
||||
- [x] Add a resolve method
|
||||
- [x] Make it separate from Hub
|
||||
- [x] Parse output into separate fields
|
||||
|
@ -15,14 +15,12 @@
|
|||
- [x] Major records supported
|
||||
|
||||
## CLI Features
|
||||
- [ ] `digfile`
|
||||
- [ ] `ndots` support
|
||||
- [x] `ndots` support
|
||||
- [x] `search list` support
|
||||
- [x] JSON output
|
||||
- [x] Colorized output
|
||||
- [x] Table output
|
||||
- [x] Parsing options free-form
|
||||
- [x] Remove urfave/cli in favour of `flag`
|
||||
|
||||
## CLI Grunt
|
||||
- [x] Query args
|
||||
|
@ -35,6 +33,7 @@
|
|||
- [ ] Add different commands
|
||||
- [x] Add client transport options
|
||||
- [x] Fix an issue while loading free form args, where the same records are being added twice
|
||||
- [x] Remove urfave/cli in favour of `pflag + koanf`
|
||||
|
||||
## Tests
|
||||
|
||||
|
@ -53,3 +52,4 @@
|
|||
## v1.0
|
||||
|
||||
- [ ] Support obscure protocal tweaks in `dig`
|
||||
- [ ] `digfile`
|
||||
|
|
|
@ -42,7 +42,7 @@ func main() {
|
|||
|
||||
// Resolver Options
|
||||
f.Bool("search", false, "Use the search list provided in resolv.conf. It sets the `ndots` parameter as well unless overriden by `ndots` flag.")
|
||||
f.Int("ndots", 1, "Specify the ndots paramter")
|
||||
f.Int("ndots", 1, "Specify the ndots paramter. Default value is taken from resolv.conf and fallbacks to 1 if ndots statement is missing in resolv.conf")
|
||||
|
||||
// Output Options
|
||||
f.BoolP("json", "J", false, "Set the output format as JSON")
|
||||
|
@ -67,6 +67,7 @@ func main() {
|
|||
} else {
|
||||
hub.Logger.SetLevel(logrus.InfoLevel)
|
||||
}
|
||||
|
||||
// Run the app.
|
||||
hub.Logger.Debug("Starting doggo 🐶")
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/miekg/dns"
|
||||
|
@ -34,12 +35,11 @@ func (hub *Hub) prepareQuestions() error {
|
|||
domains []string
|
||||
ndots int
|
||||
)
|
||||
ndots = 1
|
||||
|
||||
ndots = hub.QueryFlags.Ndots
|
||||
// If `search` flag is specified then fetch the search list
|
||||
// from `resolv.conf` and set the
|
||||
if hub.QueryFlags.UseSearchList {
|
||||
list, n, err := fetchDomainList(name, false, hub.QueryFlags.Ndots)
|
||||
list, n, err := fetchDomainList(name, ndots)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -69,13 +69,15 @@ func (hub *Hub) prepareQuestions() error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func fetchDomainList(d string, isNdotsSet bool, ndots int) ([]string, int, error) {
|
||||
func fetchDomainList(d string, ndots int) ([]string, int, error) {
|
||||
fmt.Println(ndots)
|
||||
cfg, err := dns.ClientConfigFromFile(resolvers.DefaultResolvConfPath)
|
||||
if err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
// if user specified a custom ndots parameter, override it
|
||||
if isNdotsSet {
|
||||
// if it's the default value
|
||||
if cfg.Ndots == 1 {
|
||||
// override what the user gave. If the user didn't give any setting then it's 1 by default.
|
||||
cfg.Ndots = ndots
|
||||
}
|
||||
return cfg.NameList(d), cfg.Ndots, nil
|
||||
|
|
|
@ -20,6 +20,7 @@ func (hub *Hub) loadQueryArgs() error {
|
|||
hub.Logger.WithError(err).Error("Error parsing nameservers")
|
||||
hub.Logger.Exit(2)
|
||||
}
|
||||
|
||||
hub.loadFallbacks()
|
||||
return err
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue