95% of the changes here introduce a new NameServer struct:
type NameServer struct {
IP net.IP // ip address, required
Port uint16 // udp/tcp port
DomainName string // used for SNI with TLS, required if you want to validate server certs
}
This lets us have a bit more type safety than we had before with passing an arbitrary string as a nameServer into functions.
Additionally, though, this adds the ability to specify nameservers by domain, ex: ./zdns A google.com --name-servers="one.one.one.one".
In this case, we'll query for the IPs (A and AAAA) and discard A if we're doing --6 or AAAA if --4, and store these as our resolver.NameServers.
Finally, if a user is passing nameservers as domains in as input on a per-line basis:
yahoo.com,one.one.one.one
google.com,8.8.8.8
We'll choose a random IP from one.one.one.one's records and use that to query.
Testing
Added a few unit tests and integration tests to test the new functionality.
Description
95% of the changes here introduce a new
NameServer
struct:This lets us have a bit more type safety than we had before with passing an arbitrary string as a
nameServer
into functions.Additionally, though, this adds the ability to specify nameservers by domain, ex:
./zdns A google.com --name-servers="one.one.one.one"
. In this case, we'll query for the IPs (A and AAAA) and discard A if we're doing--6
or AAAA if--4
, and store these as ourresolver.NameServers
.Finally, if a user is passing nameservers as domains in as input on a per-line basis:
We'll choose a random IP from
one.one.one.one
's records and use that to query.Testing
Added a few unit tests and integration tests to test the new functionality.