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

Refactor DNS check #96

Closed
wants to merge 1 commit into from
Closed

Refactor DNS check #96

wants to merge 1 commit into from

Conversation

janeczku
Copy link
Contributor

@janeczku janeczku commented Feb 3, 2016

Fixes #95

  • Implements a (semi-)recursive iterative lookup mechanism to find all authoritative
    nameservers for the zone enclosing the domain.
    This is necessary because a direct query for NS records at a recursive DNS server (e.g. Google Public DNS) or at the zone's primary nameserver will often yield an incomplete list of authoritative nameservers or even those of a another zone (e.g.
    when the domain is a CNAME pointing to another zone).
  • All authoritative nameservers are then queried for the TXT record to make
    sure that it has been completely propagated.
  • The waitFor utility function now takes an interval parameter and returns
    the last seen error on timeout.

if len(in.Ns) > 0 {
for _, r := range in.Ns {
rr, ok := r.(*dns.NS)
if ok && recursionsCnt < preCheckDNSMaxRecursions {
Copy link
Member

Choose a reason for hiding this comment

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

Guess we should query all NS at some point, right? Instead of artificially limit the number to five.

@janeczku
Copy link
Contributor Author

janeczku commented Feb 4, 2016

@xenolf Right now we only check the first NS in the record. The MaxRecursion actually limits the recursion depth and protects us from an infinite loop due to misconfigured DNS zones.
I agree we should query all NS in the records!

@janeczku
Copy link
Contributor Author

janeczku commented Feb 4, 2016

We also better add a test case before merging this 😄

@xenolf
Copy link
Member

xenolf commented Feb 4, 2016

Are you going to add that to your PR or should I add it later? :)

Thanks for you hard work on this issue! 👏

@janeczku
Copy link
Contributor Author

janeczku commented Feb 4, 2016

I will update this with the check for all authoritative NS. If you could add a test when thats done? 😏

@xenolf
Copy link
Member

xenolf commented Feb 4, 2016

😆 Yeah I will. Them bloody tests 😜

@janeczku
Copy link
Contributor Author

janeczku commented Feb 5, 2016

@xenolf So the changes for querying all authoritative nameservers are in. This is a bit of a rewrite, so please review. Tested with CloudFlare DNS.

@janeczku
Copy link
Contributor Author

janeczku commented Feb 6, 2016

Added some unit tests FYI. :bowtie:

// waitFor polls the given function 'f', once per second, up to 'timeout' seconds.
func waitFor(timeout int, f func() (bool, error)) error {
// waitFor polls the given function 'f', once every 'interval' seconds, up to 'timeout' seconds.
func waitFor(timeout, interval int, f func() (bool, error)) error {
Copy link
Member

Choose a reason for hiding this comment

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

I'm just thinking out loud here... but maybe we should add a util.go for stuff like this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That was on my mind too! 😄 But maybe we can do the code re-organization later in a separate patch?

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, I agree... out of scope of this PR :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you have any other stuff on your mind that ought to move to the util.go?

Copy link
Member

Choose a reason for hiding this comment

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

Yes, limitReader for example. I'm also thinking about crypto.go as there are multiple functions in there which are mere utility functions.

@janeczku
Copy link
Contributor Author

janeczku commented Feb 7, 2016

@willglynn If you will, please test your scenario against the updated PR. Thanks!

* Implements a (semi-)recursive query mechanism to find all authoritative
nameservers for the zone enclosing the domain.
This is necessary because Google Public DNS
does sometimes not return any NS at all or those of a different zone (e.g.
when the domain is a CNAME pointing elsewhere).
* All authoritative nameservers are then queried for the TXT record to make
sure that it has been completely propagated.
* The waitFor utility function now takes an interval parameter and returns
the last seen error on timeout.
@willglynn
Copy link
Contributor

I should be able to check in on this tomorrow. Who knows; I might even be able to contribute tests 😄

@janeczku
Copy link
Contributor Author

janeczku commented Feb 8, 2016

Awesome 👌 😋

@willglynn
Copy link
Contributor

I don't have immediate feedback, but I have been collecting scenarios for testing.

(CNAMEs make for all sorts of fun.)

@janeczku janeczku mentioned this pull request Feb 9, 2016
@janeczku
Copy link
Contributor Author

janeczku commented Feb 9, 2016

The iterative DNS lookup used in this PR proved overkill, since the objective (getting a definite list of authoritative NS for a domain) can actually very well be accomplished by plain old and cheap recursive queries to a public DNS resolver. 😬 😅
Landing this PR would thus introduce unnecessary complexity.
Closed in favor of #116

@willglynn The API has not changed so any tests you might have prepared can be applied to the new PR.

@janeczku janeczku closed this Feb 9, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants