diff --git a/defaults.go b/defaults.go index c34890ee..14e18b0b 100644 --- a/defaults.go +++ b/defaults.go @@ -273,8 +273,11 @@ func (t Type) String() string { // String returns the string representation for the class c. func (c Class) String() string { - if c1, ok := ClassToString[uint16(c)]; ok { - return c1 + if s, ok := ClassToString[uint16(c)]; ok { + // Only emit mnemonics when they are unambiguous, specically ANY is in both. + if _, ok := StringToType[s]; !ok { + return s + } } return "CLASS" + strconv.Itoa(int(c)) } diff --git a/parse_test.go b/parse_test.go index db877147..efdaf59a 100644 --- a/parse_test.go +++ b/parse_test.go @@ -433,6 +433,7 @@ func TestParseClass(t *testing.T) { // ClassANY can not occur in zone files // "t.example.com. ANY A 127.0.0.1": "t.example.com. 3600 ANY A 127.0.0.1", "t.example.com. NONE A 127.0.0.1": "t.example.com. 3600 NONE A 127.0.0.1", + "t.example.com. CLASS255 A 127.0.0.1": "t.example.com. 3600 CLASS255 A 127.0.0.1", } for i, o := range tests { rr, err := NewRR(i) diff --git a/scan.go b/scan.go index 77542caa..f9cd4740 100644 --- a/scan.go +++ b/scan.go @@ -577,6 +577,7 @@ func zlexer(s *scan, c chan lex) { return } l.value = zRrtpe + rrtype = true l.torc = t } } @@ -600,7 +601,7 @@ func zlexer(s *scan, c chan lex) { c <- l } stri = 0 - // I reverse space stuff here + if !space && !commt { l.value = zBlank l.token = " " diff --git a/update_test.go b/update_test.go index 6813baa1..5dba413a 100644 --- a/update_test.go +++ b/update_test.go @@ -119,15 +119,15 @@ func TestPreReqAndRemovals(t *testing.T) { ;example.org. IN SOA ;; ANSWER SECTION: -name_used. 0 ANY ANY +name_used. 0 CLASS255 ANY name_not_used. 0 NONE ANY -rrset_used1. 0 ANY A +rrset_used1. 0 CLASS255 A rrset_used2. 3600 IN A 127.0.0.1 rrset_not_used. 0 NONE A ;; AUTHORITY SECTION: -remove1. 0 ANY ANY -remove2. 0 ANY A +remove1. 0 CLASS255 ANY +remove2. 0 CLASS255 A remove3. 0 NONE A 127.0.0.1 insert. 3600 IN A 127.0.0.1 `