Skip to content

Commit

Permalink
A nameserver is not authoritative for its name, only its zone (#222)
Browse files Browse the repository at this point in the history
Fix confusion about authority
Fix out of bounds

Fixes part 1 of issue #221
  • Loading branch information
FR4NK-W authored Mar 26, 2019
1 parent ea31b8a commit 0f291e4
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions internal/pkg/rainsd/queryEngine.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ func answerQueriesAuthoritative(qs []*query.Name, sender net.Addr, token token.T
log.Info("Start processing query as authority", "queries", qs)
for _, q := range qs {
for i, auth := range s.config.Authorities {
if strings.HasSuffix(q.Name, auth.Zone) && q.Context == auth.Context {
// check this server is authoritative for the name and the query has the right context
if strings.HasSuffix(q.Name, auth.Zone) && q.Name != auth.Zone && q.Context == auth.Context {
break
}
if i == len(s.config.Authorities)-1 {
Expand Down Expand Up @@ -202,7 +203,7 @@ func glueRecordNames(qs []*query.Name, zoneAuths []ZoneContext) map[ZoneContext]
if strings.HasSuffix(q.Name, auth.Zone) {
name := strings.TrimSuffix(q.Name, auth.Zone)
names := strings.Split(name, ".")
if names[len(names)-1] == "" {
if len(names) > 1 && names[len(names)-1] == "" {
name = fmt.Sprintf("%s.%s", names[len(names)-2], auth.Zone)
} else { //root zone
name = names[len(names)-1] + auth.Zone
Expand Down

0 comments on commit 0f291e4

Please sign in to comment.