Allow mnemonic algorithm numbers in DS (and DS-like) records
This commit is contained in:
parent
0c0b97f72b
commit
ea57a49d94
|
@ -604,3 +604,6 @@ var Alg_str = map[uint8]string{
|
|||
PRIVATEDNS: "PRIVATEDNS",
|
||||
PRIVATEOID: "PRIVATEOID",
|
||||
}
|
||||
|
||||
// Map of algorithm strings.
|
||||
var Str_alg = reverseInt8(Alg_str)
|
||||
|
|
8
msg.go
8
msg.go
|
@ -1048,6 +1048,14 @@ func unpackRR(msg []byte, off int) (rr RR, off1 int, ok bool) {
|
|||
}
|
||||
|
||||
// Reverse a map
|
||||
func reverseInt8(m map[uint8]string) map[string]uint8 {
|
||||
n := make(map[string]uint8)
|
||||
for u, s := range m {
|
||||
n[s] = u
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
func reverseInt16(m map[uint16]string) map[string]uint16 {
|
||||
n := make(map[string]uint16)
|
||||
for u, s := range m {
|
||||
|
|
12
zscan_rr.go
12
zscan_rr.go
|
@ -789,7 +789,11 @@ func setDS(h RR_Header, c chan lex, f string) (RR, *ParseError) {
|
|||
<-c // _BLANK
|
||||
l = <-c
|
||||
if i, e := strconv.Atoi(l.token); e != nil {
|
||||
if i, ok := Str_alg[strings.ToUpper(l.token)]; !ok {
|
||||
return nil, &ParseError{f, "bad DS Algorithm", l}
|
||||
} else {
|
||||
rr.Algorithm = i
|
||||
}
|
||||
} else {
|
||||
rr.Algorithm = uint8(i)
|
||||
}
|
||||
|
@ -830,7 +834,11 @@ func setDLV(h RR_Header, c chan lex, f string) (RR, *ParseError) {
|
|||
<-c // _BLANK
|
||||
l = <-c
|
||||
if i, e := strconv.Atoi(l.token); e != nil {
|
||||
if i, ok := Str_alg[strings.ToUpper(l.token)]; !ok {
|
||||
return nil, &ParseError{f, "bad DLV Algorithm", l}
|
||||
} else {
|
||||
rr.Algorithm = i
|
||||
}
|
||||
} else {
|
||||
rr.Algorithm = uint8(i)
|
||||
}
|
||||
|
@ -871,7 +879,11 @@ func setTA(h RR_Header, c chan lex, f string) (RR, *ParseError) {
|
|||
<-c // _BLANK
|
||||
l = <-c
|
||||
if i, e := strconv.Atoi(l.token); e != nil {
|
||||
if i, ok := Str_alg[strings.ToUpper(l.token)]; !ok {
|
||||
return nil, &ParseError{f, "bad TA Algorithm", l}
|
||||
} else {
|
||||
rr.Algorithm = i
|
||||
}
|
||||
} else {
|
||||
rr.Algorithm = uint8(i)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue