Skip to content

Commit

Permalink
feat(dns): Support SRV query type (#1005)
Browse files Browse the repository at this point in the history
  • Loading branch information
TwiN authored Feb 17, 2025
1 parent a1f7bd7 commit 46b24b8
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"time"

"github.com/TwiN/gocache/v2"
"github.com/TwiN/logr"
"github.com/TwiN/whois"
"github.com/ishidawataru/sctp"
"github.com/miekg/dns"
Expand Down Expand Up @@ -326,6 +327,7 @@ func QueryDNS(queryType, queryName, url string) (connected bool, dnsRcode string
m.SetQuestion(queryName, queryTypeAsUint16)
r, _, err := c.Exchange(m, url)
if err != nil {
logr.Infof("[client.QueryDNS] Error exchanging DNS message: %v", err)
return false, "", nil, err
}
connected = true
Expand Down Expand Up @@ -356,6 +358,10 @@ func QueryDNS(queryType, queryName, url string) (connected bool, dnsRcode string
if ptr, ok := rr.(*dns.PTR); ok {
body = []byte(ptr.Ptr)
}
case dns.TypeSRV:
if srv, ok := rr.(*dns.SRV); ok {
body = []byte(fmt.Sprintf("%s:%d", srv.Target, srv.Port))
}
default:
body = []byte("query type is not supported yet")
}
Expand Down

0 comments on commit 46b24b8

Please sign in to comment.