Skip to content

Commit

Permalink
Allow A/AAAA records without a weight
Browse files Browse the repository at this point in the history
  • Loading branch information
abh committed Dec 20, 2012
1 parent 2ba7029 commit 381d230
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
17 changes: 10 additions & 7 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,14 +235,17 @@ func setupZoneData(data map[string]interface{}, Zone *Zone) {
rec := records[rType][i].([]interface{})
ip := rec[0].(string)
var err error
switch rec[1].(type) {
case string:
record.Weight, err = strconv.Atoi(rec[1].(string))
if err != nil {
panic("Error converting weight to integer")

if len(rec) > 1 {
switch rec[1].(type) {
case string:
record.Weight, err = strconv.Atoi(rec[1].(string))
if err != nil {
panic("Error converting weight to integer")
}
case float64:
record.Weight = int(rec[1].(float64))
}
case float64:
record.Weight = int(rec[1].(float64))
}
switch dnsType {
case dns.TypeA:
Expand Down
2 changes: 1 addition & 1 deletion dns/test.example.com.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"max_hosts": "1"
},
"bar": {
"a": [ [ "192.168.1.2", 10 ] ],
"a": [ [ "192.168.1.2" ] ],
"ttl": "601"
},
"bar.no": { "a": [] },
Expand Down

0 comments on commit 381d230

Please sign in to comment.