Selaa lähdekoodia

Make 'aaaa', 'a' and 'ip' all work as options for a/aaaa configurations

Ask Bjørn Hansen 7 vuotta sitten
vanhempi
commit
7e74631cc8
2 muutettua tiedostoa jossa 7 lisäystä ja 5 poistoa
  1. 2 2
      dns/test.example.com.json
  2. 5 3
      zones/reader.go

+ 2 - 2
dns/test.example.com.json

@@ -220,10 +220,10 @@
           "aaaa": "2a07:2180:0:1::400"
         },
         {
-          "aaaa": "2607:f238:3::1:45"
+          "ip": "2607:f238:3::1:45"
         },
         {
-          "aaaa": "2403:300:a0c:f000::1"
+          "ip": "2403:300:a0c:f000::1"
         }
       ],
       "max_hosts": "1",

+ 5 - 3
zones/reader.go

@@ -271,7 +271,9 @@ func setupZoneData(data map[string]interface{}, zone *Zone) {
 					case map[string]interface{}:
 						r := rec.(map[string]interface{})
 
-						ip = r["ip"].(string)
+						if _, ok := r["ip"]; ok {
+							ip = r["ip"].(string)
+						}
 
 						if len(ip) == 0 || dnsType == dns.TypePTR {
 							switch dnsType {
@@ -303,13 +305,13 @@ func setupZoneData(data map[string]interface{}, zone *Zone) {
 							record.RR = &dns.A{Hdr: h, A: x}
 							break
 						}
-						panic(fmt.Errorf("Bad A record %s for %s", ip, dk))
+						panic(fmt.Errorf("Bad A record %q for %q", ip, dk))
 					case dns.TypeAAAA:
 						if x := net.ParseIP(ip); x != nil {
 							record.RR = &dns.AAAA{Hdr: h, AAAA: x}
 							break
 						}
-						panic(fmt.Errorf("Bad AAAA record %s for %s", ip, dk))
+						panic(fmt.Errorf("Bad AAAA record %q for %q", ip, dk))
 					}
 
 				case dns.TypeMX: