mirror of
https://github.com/miekg/dns.git
synced 2025-10-18 21:31:01 +02:00
add ds/dnskey/rrsig and fix 1-line comments
This commit is contained in:
parent
725fb45591
commit
fa6e603134
44
types.rl
44
types.rl
@ -39,7 +39,6 @@
|
|||||||
z.Push(rr)
|
z.Push(rr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
action setCNAME {
|
action setCNAME {
|
||||||
rdf := fields(data[mark:p], 1)
|
rdf := fields(data[mark:p], 1)
|
||||||
rr := new(RR_CNAME)
|
rr := new(RR_CNAME)
|
||||||
@ -62,6 +61,47 @@
|
|||||||
rr.Expire = uint32(atoi(rdf[5]))
|
rr.Expire = uint32(atoi(rdf[5]))
|
||||||
rr.Minttl = uint32(atoi(rdf[6]))
|
rr.Minttl = uint32(atoi(rdf[6]))
|
||||||
z.Push(rr)
|
z.Push(rr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
action setDS {
|
||||||
|
rdf := fields(data[mark:p], 4)
|
||||||
|
rr := new(RR_DS)
|
||||||
|
rr.Hdr = *hdr
|
||||||
|
rr.Hdr.Rrtype = TypeDS
|
||||||
|
rr.KeyTag = uint16(atoi(rdf[0]))
|
||||||
|
rr.Algorithm = uint8(atoi(rdf[1]))
|
||||||
|
rr.DigestType = uint8(atoi(rdf[2]))
|
||||||
|
rr.Digest = rdf[3]
|
||||||
|
z.Push(rr)
|
||||||
|
}
|
||||||
|
|
||||||
|
action setDNSKEY {
|
||||||
|
rdf := fields(data[mark:p], 4)
|
||||||
|
rr := new(RR_DNSKEY)
|
||||||
|
rr.Hdr = *hdr
|
||||||
|
rr.Hdr.Rrtype = TypeDNSKEY
|
||||||
|
rr.Flags = uint16(atoi(rdf[0]))
|
||||||
|
rr.Protocol = uint8(atoi(rdf[1]))
|
||||||
|
rr.Algorithm = uint8(atoi(rdf[2]))
|
||||||
|
rr.PublicKey = rdf[3]
|
||||||
|
z.Push(rr)
|
||||||
|
}
|
||||||
|
|
||||||
|
action setRRSIG {
|
||||||
|
rdf := fields(data[mark:p], 9)
|
||||||
|
rr := new(RR_RRSIG)
|
||||||
|
rr.Hdr = *hdr
|
||||||
|
rr.Hdr.Rrtype = TypeRRSIG
|
||||||
|
rr.TypeCovered = uint16(atoi(rdf[0]))
|
||||||
|
rr.Algorithm = uint8(atoi(rdf[1]))
|
||||||
|
rr.Labels = uint8(atoi(rdf[2]))
|
||||||
|
rr.OrigTtl = uint32(atoi(rdf[3]))
|
||||||
|
rr.Expiration = uint32(atoi(rdf[4]))
|
||||||
|
rr.Inception = uint32(atoi(rdf[5]))
|
||||||
|
rr.KeyTag = uint16(atoi(rdf[6]))
|
||||||
|
rr.SignerName = rdf[7]
|
||||||
|
rr.Signature = rdf[9]
|
||||||
|
z.Push(rr)
|
||||||
|
}
|
||||||
|
|
||||||
}%%
|
}%%
|
||||||
|
56
zparse.rl
56
zparse.rl
@ -15,14 +15,19 @@ import (
|
|||||||
//const _IOBUF = 65365
|
//const _IOBUF = 65365
|
||||||
const _IOBUF = 3e7
|
const _IOBUF = 3e7
|
||||||
|
|
||||||
// Return the rdata fields as a slice. All starting whitespace deleted
|
// Return the rdata fields as a string slice.
|
||||||
|
// All starting whitespace is deleted.
|
||||||
func fields(s string, i int) (rdf []string) {
|
func fields(s string, i int) (rdf []string) {
|
||||||
rdf = strings.Fields(strings.TrimSpace(s))
|
rdf = strings.Fields(strings.TrimSpace(s))
|
||||||
for i, _ := range rdf {
|
for i, _ := range rdf {
|
||||||
rdf[i] = strings.TrimSpace(rdf[i])
|
rdf[i] = strings.TrimSpace(rdf[i])
|
||||||
}
|
}
|
||||||
// every rdf above i should be stiched together without
|
if len(rdf) > i {
|
||||||
// the spaces
|
// The last rdf contained embedded spaces, glue it back together.
|
||||||
|
for j := i; j < len(rdf); j++ {
|
||||||
|
rdf[i-1] += rdf[j]
|
||||||
|
}
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -34,44 +39,6 @@ func atoi(s string) uint {
|
|||||||
return i
|
return i
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
func rdata_ds(hdr RR_Header, tok *token) RR {
|
|
||||||
rr := new(RR_DS)
|
|
||||||
rr.Hdr = hdr;
|
|
||||||
rr.Hdr.Rrtype = TypeDS
|
|
||||||
rr.KeyTag = uint16(tok.N[0])
|
|
||||||
rr.Algorithm = uint8(tok.N[1])
|
|
||||||
rr.DigestType = uint8(tok.N[2])
|
|
||||||
rr.Digest = tok.T[0]
|
|
||||||
return rr
|
|
||||||
}
|
|
||||||
func rdata_dnskey(hdr RR_Header, tok *token) RR {
|
|
||||||
rr := new(RR_DNSKEY)
|
|
||||||
rr.Hdr = hdr;
|
|
||||||
rr.Hdr.Rrtype = TypeDNSKEY
|
|
||||||
rr.Flags = uint16(tok.N[0])
|
|
||||||
rr.Protocol = uint8(tok.N[1])
|
|
||||||
rr.Algorithm = uint8(tok.N[2])
|
|
||||||
rr.PublicKey = tok.T[0]
|
|
||||||
return rr
|
|
||||||
}
|
|
||||||
func rdata_rrsig(hdr RR_Header, tok *token) RR {
|
|
||||||
rr := new(RR_RRSIG)
|
|
||||||
rr.Hdr = hdr;
|
|
||||||
rr.Hdr.Rrtype = TypeRRSIG
|
|
||||||
rr.TypeCovered = uint16(tok.N[0])
|
|
||||||
rr.Algorithm = uint8(tok.N[1])
|
|
||||||
rr.Labels = uint8(tok.N[2])
|
|
||||||
rr.OrigTtl = uint32(tok.N[3])
|
|
||||||
rr.Expiration = uint32(tok.N[4])
|
|
||||||
rr.Inception = uint32(tok.N[5])
|
|
||||||
rr.KeyTag = uint16(tok.N[6])
|
|
||||||
rr.SignerName = tok.T[0]
|
|
||||||
rr.Signature = tok.T[1]
|
|
||||||
return rr
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
%%{
|
%%{
|
||||||
machine z;
|
machine z;
|
||||||
write data;
|
write data;
|
||||||
@ -120,7 +87,7 @@ func Zparse(q io.Reader) (z *Zone, err os.Error) {
|
|||||||
# | '(' $openBrace
|
# | '(' $openBrace
|
||||||
# | ')' $closeBrace
|
# | ')' $closeBrace
|
||||||
# | (comment? nl)+ when brace
|
# | (comment? nl)+ when brace
|
||||||
# )+ %mark;
|
# )+;
|
||||||
bl = [ \t]+;
|
bl = [ \t]+;
|
||||||
|
|
||||||
# rdata = [a-zA-Z0-9.]+ >mark;
|
# rdata = [a-zA-Z0-9.]+ >mark;
|
||||||
@ -140,11 +107,14 @@ func Zparse(q io.Reader) (z *Zone, err os.Error) {
|
|||||||
| ( 'CNAME'i rdata ) %setCNAME
|
| ( 'CNAME'i rdata ) %setCNAME
|
||||||
| ( 'NS'i rdata ) %setNS
|
| ( 'NS'i rdata ) %setNS
|
||||||
| ( 'MX'i rdata ) %setMX
|
| ( 'MX'i rdata ) %setMX
|
||||||
|
| ( 'DS'i rdata ) %setDS
|
||||||
|
| ( 'DNSKEY'i rdata ) %setDNSKEY
|
||||||
|
| ( 'RRSIG'i rdata ) %setRRSIG
|
||||||
);
|
);
|
||||||
|
|
||||||
rr = lhs rhs;
|
rr = lhs rhs;
|
||||||
# main := (rr? bl? ((comment? nl) when !brace))*;
|
# main := (rr? bl? ((comment? nl) when !brace))*;
|
||||||
main := (rr? nl)*;
|
main := ((rr?|comment?) nl)*;
|
||||||
|
|
||||||
write init;
|
write init;
|
||||||
write exec;
|
write exec;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user