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

Only warn user of --local-addr is provided explicitly by user #489

Merged
merged 7 commits into from
Dec 22, 2024

Conversation

phillip-stephens
Copy link
Contributor

@phillip-stephens phillip-stephens commented Dec 19, 2024

When there is a --name-server (either explicitly provided by user or implicit from /etc/resolv.conf) that cannot be reached by the --local-addr, we'll attempt to correct the local-addr to reach the nameserver.

In the fix in #481, I made this a warn msg to the user.

However, this means the user is getting a warn whenever the --local-addr is overridden, even if it's just a default being overridden.

We'll move to erroring out if the user supplies a --local-addr we can't use, and no warn otherwise

main

~/zdns on  main! ⌚ 13:11:30
$ go run . A example.com --iterative
WARN[0000] none of the user-supplied local addresses could connect to name server 170.247.170.2:53, using local address 192.168.1.173 
WARN[0000] none of the user-supplied local addresses could connect to name server [2001:500:2::c]:53, using local address 2600:1700:1d81:2250:91de:7de9:e0fc:9acf 
{"name":"example.com","results":{"A":{"data":{"answers":[{"answer":"93.184.215.14","class":"IN","name":"example.com","ttl":3600,"type":"A"}],"protocol":"udp","resolver":"199.43.135.53:53"},"duration":0.464350583,"status":"NOERROR","timestamp":"2024-12-19T13:11:41-05:00"}}}
00h:00m:01s; 1 names scanned; 1.00 names/sec; 100.0% success rate; NOERROR: 1
00h:00m:01s; Scan Complete; 1 names scanned; 0.68 names/sec; 100.0% success rate; NOERROR: 1

This PR - only warn if user directly supplied a local-addr and we override it.

No --local-addr

$ go run . A prstephens.com --verbosity=3
{"name":"prstephens.com","results":{"A":{"data":{"additionals":[{"flags":"","type":"EDNS0","udpsize":1232,"version":0}],"answers":[{"answer":"104.21.96.65","class":"IN","name":"prstephens.com","ttl":300,"type":"A"},{"answer":"172.67.173.251","class":"IN","name":"prstephens.com","ttl":300,"type":"A"}],"protocol":"udp","resolver":"1.1.1.1:53"},"duration":0.024726667,"status":"NOERROR","timestamp":"2024-12-19T15:55:59-05:00"}}}
00h:00m:00s; Scan Complete; 1 names scanned; 39.13 names/sec; 100.0% success rate; NOERROR: 1

Supplying a --local-addr that we must override

$ go run . A prstephens.com --verbosity=3 --local-addr=127.0.0.1
FATA[0000] none of the user-supplied local addresses ([127.0.0.1]) could connect to name server 1.1.1.1:53 
exit status 1

@phillip-stephens phillip-stephens marked this pull request as ready for review December 19, 2024 18:14
@phillip-stephens phillip-stephens requested a review from a team as a code owner December 19, 2024 18:15
@zakird zakird merged commit 410eb82 into main Dec 22, 2024
3 checks passed
@zakird zakird deleted the phillip/fix-warn branch December 22, 2024 01:31
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