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