ClassANY: don't convert CLASS255 to ANY (#618)
* ClassANY: don't convert CLASS255 to ANY Class "ANY" is wireformat only. In zonefile you can use CLASS255, but when String-ing we convert this into "ANY" which is wrong. I.e. this means we can't read back our own update. Bit of a kludge to work around this, as I'm not sure we can just remove ANY from the ClassToString map.
This commit is contained in:
parent
ac8cd7878c
commit
dcdbddd810
|
@ -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))
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
3
scan.go
3
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 = " "
|
||||
|
|
|
@ -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
|
||||
`
|
||||
|
|
Loading…
Reference in New Issue