Browse Source

Update dns API to use new CountLabel and SplitDomainName functions

Ask Bjørn Hansen 12 years ago
parent
commit
936f5e31e7
2 changed files with 10 additions and 10 deletions
  1. 2 2
      serve.go
  2. 8 8
      zone.go

+ 2 - 2
serve.go

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

+ 8 - 8
zone.go

@@ -52,13 +52,13 @@ type ZoneMetrics struct {
 }
 
 type Zone struct {
-	Origin    string
-	Labels    labels
-	LenLabels int
-	Options   ZoneOptions
-	Logging   *ZoneLogging
-	LastRead  time.Time
-	Metrics   ZoneMetrics
+	Origin     string
+	Labels     labels
+	LabelCount int
+	Options    ZoneOptions
+	Logging    *ZoneLogging
+	LastRead   time.Time
+	Metrics    ZoneMetrics
 }
 
 type qTypes []uint16
@@ -67,7 +67,7 @@ func NewZone(name string) *Zone {
 	zone := new(Zone)
 	zone.Labels = make(labels)
 	zone.Origin = name
-	zone.LenLabels = dns.LenLabels(zone.Origin)
+	zone.LabelCount = dns.CountLabel(zone.Origin)
 
 	// defaults
 	zone.Options.Ttl = 120