Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass domains as NameServers and NameServer struct re-factor #435

Merged
merged 17 commits into from
Sep 5, 2024

Conversation

phillip-stephens
Copy link
Contributor

@phillip-stephens phillip-stephens commented Sep 4, 2024

Description

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.

@phillip-stephens phillip-stephens changed the title DRAFT - NameServer struct re-factor Pass domains as NameServers and NameServer struct re-factor Sep 5, 2024
@phillip-stephens phillip-stephens marked this pull request as ready for review September 5, 2024 14:29
@phillip-stephens phillip-stephens requested a review from a team as a code owner September 5, 2024 14:29
@zakird zakird merged commit e11da0b into main Sep 5, 2024
3 checks passed
@zakird zakird deleted the phillip/name-server-cli-refactor branch September 5, 2024 15:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants