Skip to content

Commit

Permalink
Fix parsing of targeting option
Browse files Browse the repository at this point in the history
(previously the code was otherwise there, but it was impossible to enable)
  • Loading branch information
abh committed Oct 3, 2013
1 parent 0c23ff7 commit e2ae6c1
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 17 deletions.
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 1 addition & 0 deletions dns/test.example.com.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"stathat": true,
"stathat_api": "abc-test"
},
"targeting": "country continent @ regiongroup region",
"contact": "support.bitnames.com",
"data" : {
"": {
Expand Down
2 changes: 1 addition & 1 deletion geodns.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
31 changes: 15 additions & 16 deletions zones.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions zones_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit e2ae6c1

Please sign in to comment.