Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds all new modules added in new tagged versions of miekg/dns #459

Merged
merged 10 commits into from
Dec 20, 2024
27 changes: 19 additions & 8 deletions src/cli/modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,15 @@ func init() {
RegisterLookupModule("A", &BasicLookupModule{DNSType: dns.TypeA, DNSClass: dns.ClassINET})
RegisterLookupModule("AAAA", &BasicLookupModule{DNSType: dns.TypeAAAA, DNSClass: dns.ClassINET})
RegisterLookupModule("AFSDB", &BasicLookupModule{DNSType: dns.TypeAFSDB, DNSClass: dns.ClassINET})
RegisterLookupModule("AMTRELAY", &BasicLookupModule{DNSType: dns.TypeAMTRELAY, DNSClass: dns.ClassINET})
RegisterLookupModule("ANY", &BasicLookupModule{DNSType: dns.TypeANY, DNSClass: dns.ClassINET})
RegisterLookupModule("APL", &BasicLookupModule{DNSType: dns.TypeAPL, DNSClass: dns.ClassINET})
RegisterLookupModule("ATMA", &BasicLookupModule{DNSType: dns.TypeATMA, DNSClass: dns.ClassINET})
RegisterLookupModule("AVC", &BasicLookupModule{DNSType: dns.TypeAVC, DNSClass: dns.ClassINET})
RegisterLookupModule("CAA", &BasicLookupModule{DNSType: dns.TypeCAA, DNSClass: dns.ClassINET})
RegisterLookupModule("CERT", &BasicLookupModule{DNSType: dns.TypeCERT, DNSClass: dns.ClassINET})
RegisterLookupModule("CDS", &BasicLookupModule{DNSType: dns.TypeCDS, DNSClass: dns.ClassINET})
RegisterLookupModule("CDNSKEY", &BasicLookupModule{DNSType: dns.TypeCDNSKEY, DNSClass: dns.ClassINET})
RegisterLookupModule("CDS", &BasicLookupModule{DNSType: dns.TypeCDS, DNSClass: dns.ClassINET})
RegisterLookupModule("CERT", &BasicLookupModule{DNSType: dns.TypeCERT, DNSClass: dns.ClassINET})
RegisterLookupModule("CNAME", &BasicLookupModule{DNSType: dns.TypeCNAME, DNSClass: dns.ClassINET})
RegisterLookupModule("CSYNC", &BasicLookupModule{DNSType: dns.TypeCSYNC, DNSClass: dns.ClassINET})
RegisterLookupModule("DHCID", &BasicLookupModule{DNSType: dns.TypeDHCID, DNSClass: dns.ClassINET})
Expand All @@ -65,41 +68,48 @@ func init() {
RegisterLookupModule("HINFO", &BasicLookupModule{DNSType: dns.TypeHINFO, DNSClass: dns.ClassINET})
RegisterLookupModule("HIP", &BasicLookupModule{DNSType: dns.TypeHIP, DNSClass: dns.ClassINET})
RegisterLookupModule("HTTPS", &BasicLookupModule{DNSType: dns.TypeHTTPS, DNSClass: dns.ClassINET})
RegisterLookupModule("IPSECKEY", &BasicLookupModule{DNSType: dns.TypeIPSECKEY, DNSClass: dns.ClassINET})
RegisterLookupModule("ISDN", &BasicLookupModule{DNSType: dns.TypeISDN, DNSClass: dns.ClassINET})
RegisterLookupModule("KEY", &BasicLookupModule{DNSType: dns.TypeKEY, DNSClass: dns.ClassINET})
RegisterLookupModule("KX", &BasicLookupModule{DNSType: dns.TypeKX, DNSClass: dns.ClassINET})
RegisterLookupModule("L32", &BasicLookupModule{DNSType: dns.TypeL32, DNSClass: dns.ClassINET})
RegisterLookupModule("L64", &BasicLookupModule{DNSType: dns.TypeL64, DNSClass: dns.ClassINET})
RegisterLookupModule("LOC", &BasicLookupModule{DNSType: dns.TypeLOC, DNSClass: dns.ClassINET})
RegisterLookupModule("LP", &BasicLookupModule{DNSType: dns.TypeLP, DNSClass: dns.ClassINET})
RegisterLookupModule("MB", &BasicLookupModule{DNSType: dns.TypeMB, DNSClass: dns.ClassINET})
RegisterLookupModule("MD", &BasicLookupModule{DNSType: dns.TypeMD, DNSClass: dns.ClassINET})
RegisterLookupModule("MF", &BasicLookupModule{DNSType: dns.TypeMF, DNSClass: dns.ClassINET})
RegisterLookupModule("MB", &BasicLookupModule{DNSType: dns.TypeMB, DNSClass: dns.ClassINET})
RegisterLookupModule("MG", &BasicLookupModule{DNSType: dns.TypeMG, DNSClass: dns.ClassINET})
RegisterLookupModule("MINFO", &BasicLookupModule{DNSType: dns.TypeMINFO, DNSClass: dns.ClassINET})
RegisterLookupModule("MR", &BasicLookupModule{DNSType: dns.TypeMR, DNSClass: dns.ClassINET})
RegisterLookupModule("MX", &BasicLookupModule{DNSType: dns.TypeMX, DNSClass: dns.ClassINET})
RegisterLookupModule("NAPTR", &BasicLookupModule{DNSType: dns.TypeNAPTR, DNSClass: dns.ClassINET})
RegisterLookupModule("NIMLOC", &BasicLookupModule{DNSType: dns.TypeNIMLOC, DNSClass: dns.ClassINET})
RegisterLookupModule("NID", &BasicLookupModule{DNSType: dns.TypeNID, DNSClass: dns.ClassINET})
RegisterLookupModule("NIMLOC", &BasicLookupModule{DNSType: dns.TypeNIMLOC, DNSClass: dns.ClassINET})
RegisterLookupModule("NINFO", &BasicLookupModule{DNSType: dns.TypeNINFO, DNSClass: dns.ClassINET})
RegisterLookupModule("NSAPPTR", &BasicLookupModule{DNSType: dns.TypeNSAPPTR, DNSClass: dns.ClassINET})
RegisterLookupModule("NONE", &BasicLookupModule{DNSType: dns.TypeNone, DNSClass: dns.ClassINET})
RegisterLookupModule("NS", &BasicLookupModule{DNSType: dns.TypeNS, DNSClass: dns.ClassINET})
RegisterLookupModule("NXT", &BasicLookupModule{DNSType: dns.TypeNXT, DNSClass: dns.ClassINET})
RegisterLookupModule("NSAPPTR", &BasicLookupModule{DNSType: dns.TypeNSAPPTR, DNSClass: dns.ClassINET})
RegisterLookupModule("NSEC", &BasicLookupModule{DNSType: dns.TypeNSEC, DNSClass: dns.ClassINET})
RegisterLookupModule("NSEC3", &BasicLookupModule{DNSType: dns.TypeNSEC3, DNSClass: dns.ClassINET})
RegisterLookupModule("NSEC3PARAM", &BasicLookupModule{DNSType: dns.TypeNSEC3PARAM, DNSClass: dns.ClassINET})
RegisterLookupModule("NULL", &BasicLookupModule{DNSType: dns.TypeNULL, DNSClass: dns.ClassINET})
RegisterLookupModule("NXNAME", &BasicLookupModule{DNSType: dns.TypeNXNAME, DNSClass: dns.ClassINET})
RegisterLookupModule("NXT", &BasicLookupModule{DNSType: dns.TypeNXT, DNSClass: dns.ClassINET})
RegisterLookupModule("OPENPGPKEY", &BasicLookupModule{DNSType: dns.TypeOPENPGPKEY, DNSClass: dns.ClassINET})
RegisterLookupModule("OPT", &BasicLookupModule{DNSType: dns.TypeOPT, DNSClass: dns.ClassINET})
RegisterLookupModule("PTR", &BasicLookupModule{DNSType: dns.TypePTR, DNSClass: dns.ClassINET})
RegisterLookupModule("PX", &BasicLookupModule{DNSType: dns.TypePX, DNSClass: dns.ClassINET})
RegisterLookupModule("RKEY", &BasicLookupModule{DNSType: dns.TypeRKEY, DNSClass: dns.ClassINET})
RegisterLookupModule("RP", &BasicLookupModule{DNSType: dns.TypeRP, DNSClass: dns.ClassINET})
RegisterLookupModule("RRSIG", &BasicLookupModule{DNSType: dns.TypeRRSIG, DNSClass: dns.ClassINET})
RegisterLookupModule("RT", &BasicLookupModule{DNSType: dns.TypeRT, DNSClass: dns.ClassINET})
RegisterLookupModule("SIG", &BasicLookupModule{DNSType: dns.TypeSIG, DNSClass: dns.ClassINET})
RegisterLookupModule("SMIMEA", &BasicLookupModule{DNSType: dns.TypeSMIMEA, DNSClass: dns.ClassINET})
RegisterLookupModule("SSHFP", &BasicLookupModule{DNSType: dns.TypeSSHFP, DNSClass: dns.ClassINET})
RegisterLookupModule("SOA", &BasicLookupModule{DNSType: dns.TypeSOA, DNSClass: dns.ClassINET})
RegisterLookupModule("SPF", &BasicLookupModule{DNSType: dns.TypeSPF, DNSClass: dns.ClassINET})
RegisterLookupModule("SRV", &BasicLookupModule{DNSType: dns.TypeSRV, DNSClass: dns.ClassINET})
RegisterLookupModule("SSHFP", &BasicLookupModule{DNSType: dns.TypeSSHFP, DNSClass: dns.ClassINET})
RegisterLookupModule("SVCB", &BasicLookupModule{DNSType: dns.TypeSVCB, DNSClass: dns.ClassINET})
RegisterLookupModule("TALINK", &BasicLookupModule{DNSType: dns.TypeTALINK, DNSClass: dns.ClassINET})
RegisterLookupModule("TKEY", &BasicLookupModule{DNSType: dns.TypeTKEY, DNSClass: dns.ClassINET})
Expand All @@ -109,7 +119,8 @@ func init() {
RegisterLookupModule("UINFO", &BasicLookupModule{DNSType: dns.TypeUINFO, DNSClass: dns.ClassINET})
RegisterLookupModule("UNSPEC", &BasicLookupModule{DNSType: dns.TypeUNSPEC, DNSClass: dns.ClassINET})
RegisterLookupModule("URI", &BasicLookupModule{DNSType: dns.TypeURI, DNSClass: dns.ClassINET})
RegisterLookupModule("ANY", &BasicLookupModule{DNSType: dns.TypeANY, DNSClass: dns.ClassINET})
RegisterLookupModule("X25", &BasicLookupModule{DNSType: dns.TypeX25, DNSClass: dns.ClassINET})
RegisterLookupModule("ZONEMD", &BasicLookupModule{DNSType: dns.TypeZONEMD, DNSClass: dns.ClassINET})
RegisterLookupModule("MULTIPLE", &BasicLookupModule{
DNSType: dns.TypeANY,
DNSClass: dns.ClassINET,
Expand Down
107 changes: 107 additions & 0 deletions src/zdns/answers.go
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,54 @@ type URIAnswer struct {
Target string `json:"target" groups:"short,normal,long,trace"`
}

type AMTRELAYAnswer struct {
Answer `json:"answer"`
Precedence uint8 `json:"precedence,omitempty" groups:"short,normal,long,trace"`
GatewayType uint8 `json:"gateway_type,omitempty" groups:"short,normal,long,trace"`
GatewayAddr net.IP `json:"gateway_addr,omitempty" groups:"short,normal,long,trace"`
GatewayHost string `json:"gateway_host,omitempty" groups:"short,normal,long,trace"`
}

type APLAnswer struct {
Answer
Prefixes []APLPrefix `json:"prefixes" groups:"short,normal,long,trace"`
}

type APLPrefix struct {
Negation bool `json:"negation" groups:"short,normal,long,trace"`
Network net.IPNet `json:"network" groups:"short,normal,long,trace"`
}

type IPSECKEYAnswer struct {
Answer
Precedence uint8 `json:"precedence" groups:"short,normal,long,trace"`
GatewayType uint8 `json:"gateway_type" groups:"short,normal,long,trace"`
Algorithm uint8 `json:"algorithm" groups:"short,normal,long,trace"`
GatewayAddr net.IP `json:"gateway_addr" groups:"short,normal,long,trace"`
GatewayHost string `json:"gateway_host" groups:"short,normal,long,trace"`
PublicKey string `json:"public_key" groups:"short,normal,long,trace"`
}

type NXTAnswer struct {
NSECAnswer
}

type RKEYAnswer struct {
Answer
Flags uint16 `json:"flags" groups:"short,normal,long,trace"`
Protocol uint8 `json:"protocol" groups:"short,normal,long,trace"`
Algorithm uint8 `json:"algorithm" groups:"short,normal,long,trace"`
PublicKey string `json:"public_key" groups:"short,normal,long,trace"`
}

type ZONEMDAnswer struct {
Answer
Serial uint32 `json:"serial" groups:"short,normal,long,trace"`
Scheme uint8 `json:"scheme" groups:"short,normal,long,trace"`
Hash uint8 `json:"hash" groups:"short,normal,long,trace"`
Digest string `json:"digest" groups:"short,normal,long,trace"`
}

// copy-paste from zmap/dns/types.go >>>>>
//
// Copyright (c) 2009 The Go Authors.
Expand Down Expand Up @@ -922,6 +970,65 @@ func ParseAnswer(ans dns.RR) interface{} {
return makeSVCBAnswer(cAns)
case *dns.OPT:
return makeEDNSAnswer(cAns)
case *dns.AMTRELAY:
return AMTRELAYAnswer{
Answer: makeBaseAnswer(&cAns.Hdr, ""),
Precedence: cAns.Precedence,
GatewayType: cAns.GatewayType,
GatewayAddr: cAns.GatewayAddr,
GatewayHost: cAns.GatewayHost,
}
case *dns.ANY:
return makeBaseAnswer(&cAns.Hdr, "")
case *dns.APL:
ret := APLAnswer{
Answer: makeBaseAnswer(&cAns.Hdr, ""),
Prefixes: make([]APLPrefix, 0, len(cAns.Prefixes)),
}
// convert to our types since we'll get json marshall hints
for _, p := range cAns.Prefixes {
ret.Prefixes = append(ret.Prefixes, APLPrefix{
Negation: p.Negation,
Network: p.Network,
})
}
return ret
case *dns.IPSECKEY:
return IPSECKEYAnswer{
Answer: makeBaseAnswer(&cAns.Hdr, ""),
Precedence: cAns.Precedence,
GatewayType: cAns.GatewayType,
Algorithm: cAns.Algorithm,
GatewayAddr: cAns.GatewayAddr,
GatewayHost: cAns.GatewayHost,
PublicKey: cAns.PublicKey,
}
case *dns.NXNAME:
return makeBaseAnswer(&cAns.Hdr, "")
case *dns.NXT:
return NXTAnswer{
NSECAnswer{
Answer: makeBaseAnswer(&cAns.Hdr, ""),
NextDomain: strings.TrimSuffix(cAns.NextDomain, "."),
TypeBitMap: makeBitString(cAns.TypeBitMap)},
}
case *dns.RKEY:
return RKEYAnswer{
Answer: makeBaseAnswer(&cAns.Hdr, ""),
Flags: cAns.Flags,
Protocol: cAns.Protocol,
Algorithm: cAns.Algorithm,
PublicKey: cAns.PublicKey,
}
case *dns.ZONEMD:
return ZONEMDAnswer{
Answer: makeBaseAnswer(&cAns.Hdr, ""),
Serial: cAns.Serial,
Scheme: cAns.Scheme,
Hash: cAns.Hash,
Digest: cAns.Digest,
}

default:
return struct {
Type string `json:"type"`
Expand Down
Loading