chore: Fix UDP Port parsing
parent
13cf2caaee
commit
a57814688c
2
TODO.md
2
TODO.md
|
@ -20,6 +20,8 @@
|
|||
- [x] Neatly package them to load args in different functions
|
||||
- [x] Upper case is not mandatory for query type/classes
|
||||
- [ ] Output
|
||||
- [ ] Add client transport options
|
||||
|
||||
## Tests
|
||||
|
||||
## Documentation
|
||||
|
|
|
@ -32,7 +32,7 @@ func (hub *Hub) loadQueryArgs(c *cli.Context) error {
|
|||
func (hub *Hub) parseFreeArgs(c *cli.Context) error {
|
||||
for _, arg := range c.Args().Slice() {
|
||||
if strings.HasPrefix(arg, "@") {
|
||||
hub.QueryFlags.Nameservers.Set(arg)
|
||||
hub.QueryFlags.Nameservers.Set(strings.Trim(arg, "@"))
|
||||
} else if _, ok := dns.StringToType[strings.ToUpper(arg)]; ok {
|
||||
hub.QueryFlags.QTypes.Set(arg)
|
||||
} else if _, ok := dns.StringToClass[strings.ToUpper(arg)]; ok {
|
||||
|
|
|
@ -19,9 +19,17 @@ const DefaultResolvConfPath = "/etc/resolv.conf"
|
|||
// NewResolver accepts a list of nameservers and configures a DNS resolver.
|
||||
func NewResolver(servers []string) *Resolver {
|
||||
client := &dns.Client{}
|
||||
var nameservers []string
|
||||
for _, srv := range servers {
|
||||
if i := net.ParseIP(srv); i != nil {
|
||||
nameservers = append(nameservers, net.JoinHostPort(srv, "53"))
|
||||
} else {
|
||||
nameservers = append(nameservers, dns.Fqdn(srv)+":"+"53")
|
||||
}
|
||||
}
|
||||
return &Resolver{
|
||||
client: client,
|
||||
servers: servers,
|
||||
servers: nameservers,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue