Skip to content

Commit 29cbff6

Browse files
d7415TwiN
andauthored
feat(client): Add support for PTR DNS records (#886)
Co-authored-by: TwiN <[email protected]>
1 parent 2fe9913 commit 29cbff6

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

client/client.go

+4
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,10 @@ func QueryDNS(queryType, queryName, url string) (connected bool, dnsRcode string
321321
if ns, ok := rr.(*dns.NS); ok {
322322
body = []byte(ns.Ns)
323323
}
324+
case dns.TypePTR:
325+
if ptr, ok := rr.(*dns.PTR); ok {
326+
body = []byte(ptr.Ptr)
327+
}
324328
default:
325329
body = []byte("query type is not supported yet")
326330
}

client/client_test.go

+10
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,16 @@ func TestQueryDNS(t *testing.T) {
396396
expectedDNSCode: "NOERROR",
397397
expectedBody: "*.iana-servers.net.",
398398
},
399+
{
400+
name: "test Config with type PTR",
401+
inputDNS: dns.Config{
402+
QueryType: "PTR",
403+
QueryName: "8.8.8.8.in-addr.arpa.",
404+
},
405+
inputURL: "8.8.8.8",
406+
expectedDNSCode: "NOERROR",
407+
expectedBody: "dns.google.",
408+
},
399409
{
400410
name: "test Config with fake type and retrieve error",
401411
inputDNS: dns.Config{

0 commit comments

Comments
 (0)