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

Fix Iteration #117

Merged
merged 2 commits into from
Aug 31, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 25 additions & 7 deletions modules/miekg/miekg.go
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,7 @@ func (s *Lookup) cachedRetryingLookup(dnsType uint16, dnsClass uint16, name stri
s.VerboseLog(depth+2, "Cache auth check for ", authName)
cachedResult, ok = s.Factory.Factory.GetCachedResult(authName, dns.TypeNS, dnsType, depth+2, s.Factory.ThreadID)
if ok {
isCached = true
return cachedResult, isCached, zdns.STATUS_NOERROR, nil
}
}
Expand Down Expand Up @@ -602,17 +603,34 @@ func nameIsBeneath(name string, layer string) (bool, string) {
}

func nextAuthority(name string, layer string) string {
// We are our own authority for PTRs
// (This is dealt with elsewhere)
if strings.HasSuffix(layer, "in-addr.arpa") {
return name
}

idx := strings.LastIndex(name, ".")
if idx < 0 || (idx+1) >= len(name) {
return ""
return name
}
if layer != "." {
idx = strings.LastIndex(name[0:idx], ".")
if idx < 0 || (idx+1) >= len(name) {
return name
}
if layer == "." {
return name[idx+1:]
}

if !strings.HasSuffix(name, layer) {
panic("Layers by definition are suffixes of names")
}

// Limit the search space to the prefix of the string that isnt layer
idx = strings.LastIndex(name, layer) - 1
if idx < 0 || (idx+1) >= len(name) {
// Out of bounds. We are our own authority
return name
}
return name[idx+1:]
// Find the next step in the layer
idx = strings.LastIndex(name[0:idx], ".")
next := name[idx+1:]
return next
}

func (s *Lookup) checkGlue(server string, depth int, result Result) (Result, zdns.Status) {
Expand Down