Browse Source

Fix off-by-one error that made only two-level domains work

Ask Bjørn Hansen 13 years ago
parent
commit
546871ca19
2 changed files with 2 additions and 2 deletions
  1. 1 1
      config.go
  2. 1 1
      serve.go

+ 1 - 1
config.go

@@ -77,8 +77,8 @@ func readZoneFile(zoneName, fileName string) (*Zone, error) {
 
 
 	Zone := new(Zone)
 	Zone := new(Zone)
 	Zone.Labels = make(labels)
 	Zone.Labels = make(labels)
-	Zone.LenLabels = dns.LenLabels(Zone.Origin)
 	Zone.Origin = zoneName
 	Zone.Origin = zoneName
+	Zone.LenLabels = dns.LenLabels(Zone.Origin)
 
 
 	if err == nil {
 	if err == nil {
 		var objmap map[string]interface{}
 		var objmap map[string]interface{}

+ 1 - 1
serve.go

@@ -8,7 +8,7 @@ import (
 
 
 func getQuestionName(z *Zone, req *dns.Msg) string {
 func getQuestionName(z *Zone, req *dns.Msg) string {
 	lx := dns.SplitLabels(req.Question[0].Name)
 	lx := dns.SplitLabels(req.Question[0].Name)
-	ql := lx[0 : len(lx)-z.LenLabels-1]
+	ql := lx[0 : len(lx)-z.LenLabels]
 	return strings.Join(ql, ".")
 	return strings.Join(ql, ".")
 }
 }