@layered/dns-records
Version:
Discover publicly available DNS Records for a domain
18 lines (13 loc) • 649 B
text/typescript
import { type DnsRecord, getAllDnsRecordsStream, parseDnsRecord } from '../src/index.ts'
// get the DNS Records stream. Notice await is not needed
const dnsRecordsStream = getAllDnsRecordsStream('shopify.com')
// decoder to convert the Uint8Array to a string
const decoder = new TextDecoder()
for await (const record of dnsRecordsStream) {
// record is a Uint8Array, so we need to convert it to a string
const dnsRecordLine = decoder.decode(record)
console.log('DNS line', dnsRecordLine)
// parse the DNS record line to a DnsRecord object
const dnsRecord: DnsRecord = parseDnsRecord(dnsRecordLine)
//console.log('DNS object', dnsRecord)
}