Browse Source

Fix parsing of targeting option

(previously the code was otherwise there, but it was impossible to enable)
Ask Bjørn Hansen 12 years ago
parent
commit
e2ae6c12d8
5 changed files with 21 additions and 17 deletions
  1. 3 0
      CHANGES.md
  2. 1 0
      dns/test.example.com.json
  3. 1 1
      geodns.go
  4. 15 16
      zones.go
  5. 1 0
      zones_test.go

+ 3 - 0
CHANGES.md

@@ -1,5 +1,8 @@
 # GeoDNS Changelog
 
+## 2.4.4
+
+* Fix parsing of 'targeting' option
 * Add server id and ip to _country responses for easier debugging.
 
 ## 2.4.3

+ 1 - 0
dns/test.example.com.json

@@ -5,6 +5,7 @@
     "stathat": true,
     "stathat_api": "abc-test"
   },
+  "targeting": "country continent @ regiongroup region",
   "contact": "support.bitnames.com",
   "data" : {
     "":  {

+ 1 - 1
geodns.go

@@ -31,7 +31,7 @@ import (
 )
 
 // VERSION is the current version of GeoDNS
-var VERSION string = "2.4.3"
+var VERSION string = "2.4.4"
 var buildTime string
 var gitVersion string
 

+ 15 - 16
zones.go

@@ -158,23 +158,22 @@ func readZoneFile(zoneName, fileName string) (zone *Zone, zerr error) {
 		//log.Printf("k: %s v: %#v, T: %T\n", k, v, v)
 
 		switch k {
-		case "ttl", "serial", "max_hosts", "contact":
-			switch option := k; option {
-			case "ttl":
-				zone.Options.Ttl = valueToInt(v)
-			case "serial":
-				zone.Options.Serial = valueToInt(v)
-			case "contact":
-				zone.Options.Contact = v.(string)
-			case "max_hosts":
-				zone.Options.MaxHosts = valueToInt(v)
-			case "targeting":
-				zone.Options.Targeting, err = parseTargets(v.(string))
-				if err != nil {
-					log.Printf("Could not parse targeting '%s': %s", v, err)
-					return nil, err
-				}
+
+		case "ttl":
+			zone.Options.Ttl = valueToInt(v)
+		case "serial":
+			zone.Options.Serial = valueToInt(v)
+		case "contact":
+			zone.Options.Contact = v.(string)
+		case "max_hosts":
+			zone.Options.MaxHosts = valueToInt(v)
+		case "targeting":
+			zone.Options.Targeting, err = parseTargets(v.(string))
+			if err != nil {
+				log.Printf("Could not parse targeting '%s': %s", v, err)
+				return nil, err
 			}
+
 		case "logging":
 			{
 				logging := new(ZoneLogging)

+ 1 - 0
zones_test.go

@@ -41,6 +41,7 @@ func (s *ConfigSuite) TestReadConfigs(c *C) {
 
 	c.Check(tz.Options.MaxHosts, Equals, 2)
 	c.Check(tz.Options.Contact, Equals, "support.bitnames.com")
+	c.Check(tz.Options.Targeting.String(), Equals, "@ continent country regiongroup region")
 
 	// Got logging option
 	c.Check(tz.Logging.StatHat, Equals, true)