Skip to content

Commit

Permalink
Merge pull request #122 from Ahmadkashif/supportANY
Browse files Browse the repository at this point in the history
Adding ANY Query functionality
  • Loading branch information
Mzack9999 committed May 3, 2023
2 parents b0816c6 + 8e7cf6b commit 392438e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
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

0 comments on commit 392438e

Please sign in to comment.