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

Fixed large number of SERVFAILs #413

Merged
merged 2 commits into from
Aug 5, 2024
Merged
Show file tree
Hide file tree
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
24 changes: 0 additions & 24 deletions src/zdns/lookup.go
Original file line number Diff line number Diff line change
Expand Up @@ -404,30 +404,6 @@ func (r *Resolver) cachedRetryingLookup(ctx context.Context, q Question, nameSer
}
}

// Now, we check the authoritative:
name := strings.ToLower(q.Name)
layer = strings.ToLower(layer)
authName, err := nextAuthority(name, layer)
if err != nil {
var r SingleQueryResult
return r, isCached, StatusAuthFail, 0, err
}
if name != layer && authName != layer {
if authName == "" {
var r SingleQueryResult
return r, isCached, StatusAuthFail, 0, nil
}
var qAuth Question
qAuth.Name = authName
qAuth.Type = dns.TypeNS
qAuth.Class = dns.ClassINET

if cachedResult, ok = r.cache.GetCachedResult(qAuth, true, depth+2); ok {
isCached = true
return cachedResult, isCached, StatusNoError, 0, nil
}
}

// Alright, we're not sure what to do, go to the wire.
result, status, try, err := r.retryingLookup(ctx, q, nameServer, false)

Expand Down
32 changes: 0 additions & 32 deletions src/zdns/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
package zdns

import (
"errors"
"fmt"
"net"
"strings"
Expand Down Expand Up @@ -56,37 +55,6 @@ func nameIsBeneath(name, layer string) (bool, string) {
return false, ""
}

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

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

if !strings.HasSuffix(name, layer) {
return "", errors.New("server did not provide appropriate resolvers to continue recursion")
}

// 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, nil
}
// Find the next step in the layer
idx = strings.LastIndex(name[0:idx], ".")
next := name[idx+1:]
return next, nil
}

func checkGlue(server string, result SingleQueryResult) (SingleQueryResult, Status) {
for _, additional := range result.Additional {
ans, ok := additional.(Answer)
Expand Down
Loading