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

Adding ANY Query functionality #122

Merged
merged 3 commits into from
May 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func main() {

log.Println(ips)

// Query Types: dns.TypeA, dns.TypeNS, dns.TypeCNAME, dns.TypeSOA, dns.TypePTR, dns.TypeMX
// Query Types: dns.TypeA, dns.TypeNS, dns.TypeCNAME, dns.TypeSOA, dns.TypePTR, dns.TypeMX, dns.TypeANY
// dns.TypeTXT, dns.TypeAAAA, dns.TypeSRV (from github.com/miekg/dns)
dnsResponses, err := dnsClient.Query(hostname, dns.TypeA)
if err != nil {
Expand Down
9 changes: 8 additions & 1 deletion client.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,11 @@ func (c *Client) PTR(host string) (*DNSData, error) {
return c.QueryMultiple(host, []uint16{dns.TypePTR})
}

// ANY helper function
func (c *Client) ANY(host string) (*DNSData, error) {
return c.QueryMultiple(host, []uint16{dns.TypeANY})
}

// NS helper function
func (c *Client) NS(host string) (*DNSData, error) {
return c.QueryMultiple(host, []uint16{dns.TypeNS})
Expand Down Expand Up @@ -524,6 +529,7 @@ type DNSData struct {
CNAME []string `json:"cname,omitempty"`
MX []string `json:"mx,omitempty"`
PTR []string `json:"ptr,omitempty"`
ANY []string `json:"any,omitempty"`
SOA []string `json:"soa,omitempty"`
NS []string `json:"ns,omitempty"`
TXT []string `json:"txt,omitempty"`
Expand Down Expand Up @@ -608,7 +614,7 @@ func (d *DNSData) ParseFromEnvelopeChan(envChan chan *dns.Envelope) error {
}

func (d *DNSData) contains() bool {
return len(d.A) > 0 || len(d.AAAA) > 0 || len(d.CNAME) > 0 || len(d.MX) > 0 || len(d.NS) > 0 || len(d.PTR) > 0 || len(d.TXT) > 0 || len(d.SRV) > 0 || len(d.SOA) > 0 || len(d.CAA) > 0
return len(d.A) > 0 || len(d.AAAA) > 0 || len(d.CNAME) > 0 || len(d.MX) > 0 || len(d.NS) > 0 || len(d.PTR) > 0 || len(d.ANY) > 0 || len(d.TXT) > 0 || len(d.SRV) > 0 || len(d.SOA) > 0 || len(d.CAA) > 0
}

// JSON returns the object as json string
Expand All @@ -628,6 +634,7 @@ func (d *DNSData) dedupe() {
d.CNAME = sliceutil.Dedupe(d.CNAME)
d.MX = sliceutil.Dedupe(d.MX)
d.PTR = sliceutil.Dedupe(d.PTR)
d.ANY = sliceutil.Dedupe(d.ANY)
d.SOA = sliceutil.Dedupe(d.SOA)
d.NS = sliceutil.Dedupe(d.NS)
d.TXT = sliceutil.Dedupe(d.TXT)
Expand Down
1 change: 1 addition & 0 deletions doh/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ const (
NS QuestionType = "NS"
SOA QuestionType = "SOA"
PTR QuestionType = "PTR"
ANY QuestionType = "ANY"
CNAME QuestionType = "CNAME"
)

Expand Down