feat(dns): Support SRV query type (#1005)

This commit is contained in:
TwiN 2025-02-17 10:22:44 -05:00 committed by GitHub
parent a1f7bd7b73
commit 46b24b849f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -15,6 +15,7 @@ import (
"time" "time"
"github.com/TwiN/gocache/v2" "github.com/TwiN/gocache/v2"
"github.com/TwiN/logr"
"github.com/TwiN/whois" "github.com/TwiN/whois"
"github.com/ishidawataru/sctp" "github.com/ishidawataru/sctp"
"github.com/miekg/dns" "github.com/miekg/dns"
@ -326,6 +327,7 @@ func QueryDNS(queryType, queryName, url string) (connected bool, dnsRcode string
m.SetQuestion(queryName, queryTypeAsUint16) m.SetQuestion(queryName, queryTypeAsUint16)
r, _, err := c.Exchange(m, url) r, _, err := c.Exchange(m, url)
if err != nil { if err != nil {
logr.Infof("[client.QueryDNS] Error exchanging DNS message: %v", err)
return false, "", nil, err return false, "", nil, err
} }
connected = true connected = true
@ -356,6 +358,10 @@ func QueryDNS(queryType, queryName, url string) (connected bool, dnsRcode string
if ptr, ok := rr.(*dns.PTR); ok { if ptr, ok := rr.(*dns.PTR); ok {
body = []byte(ptr.Ptr) 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: default:
body = []byte("query type is not supported yet") body = []byte("query type is not supported yet")
} }