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

feat(dns): allow custom dns server as cli flag #193

Merged
merged 2 commits into from
Oct 1, 2020
Merged

feat(dns): allow custom dns server as cli flag #193

merged 2 commits into from
Oct 1, 2020

Conversation

imsnif
Copy link
Owner

@imsnif imsnif commented Sep 30, 2020

Since there are some cases in which we don't properly detect the system dns servers to performs reverse dns lookup, I added a CLI option that would allow users to manually specify a dns server as a workaround.

Usage example:
sudo bandwhich --dns-server 1.1.1.1

Copy link
Collaborator

@TheLostLambda TheLostLambda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aside from a potentially stray comment, this looks excellent! A nice feature to have!

Some(dns_server_address) => {
let mut config = ResolverConfig::new();
let options = ResolverOpts::default();
// let socket = SocketAddr::V4(SocketAddrV4::new(Ipv4Addr::new(1, 1, 1, 1), 53));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this comment be removed? Is it something that still needs addressing?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hot damn, thanks for catching this :)

tls_dns_name: None,
};
config.add_name_server(nameserver_config);
TokioAsyncResolver::new(config, options, runtime).await?
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a shame we can't just change the nameserver of the configuration returned by from_system_conf, but I think this is the best we can do right now :)

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, for sure. I mostly want this feature as a workaround for issues where we fail to parse resolv.conf, so we'd be panicking by then.

@imsnif
Copy link
Owner Author

imsnif commented Oct 1, 2020

Thanks for the review @TheLostLambda !

@imsnif imsnif merged commit e813362 into main Oct 1, 2020
@cyqsimon cyqsimon deleted the dns-cli-arg branch August 25, 2023 09: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