bare-dns
Domain name resolution for JavaScript
bare-dns — Domain name resolution for JavaScript. It is a native addon and requires Bare >=1.7.0.
Mirrors the Node.js dns module.
npm i bare-dnsUsage
const dns = require('bare-dns')
dns.lookup('github.com', (err, address, family) => {
console.log(address, family)
})API
dns
dns.IPFamily
type IPFamily = 4 | 6The IP address family: 4 for IPv4 or 6 for IPv6.
dns.lookup
dns.lookup(hostname: string, cb: (
err: Error | null,
address: string | null,
family: IPFamily | 0
) => void): voidResolve hostname into an IP address using the operating system's getaddrinfo facility, not the DNS protocol directly. With all: true, the callback receives every resolved address instead of just the first.
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
hostname | string | — | The host name to resolve. |
cb | ( err: Error | null, address: string | null, family: IPFamily | 0 ) => void | — | Called with (err, address, family), or (err, addresses) when all: true. |
dns.resolveTxt(hostname: string, cb: (err: Error | null, records: string[][]) => void): void
Source
Use the DNS protocol to resolve TXT records for hostname. The callback receives an array of records, each itself an array of the strings that make up that record.
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
hostname | string | — | The host name to query TXT records for. |
cb | (err: Error | null, records: string[][]) => void | — | Called with (err, records); each record is an array of the strings it is made of. |
DNSResolver
destroy(): void
Source
Cancel any pending queries on this resolver and release its underlying handle.
resolveTxt(hostname: string, cb: (err: Error | null, records: string[][]) => void): void
Source
Use the DNS protocol to resolve TXT records for hostname. The callback receives an array of records, each itself an array of the strings that make up that record.
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
hostname | string | — | The host name to query TXT records for. |
cb | (err: Error | null, records: string[][]) => void | — | Called with (err, records); each record is an array of the strings it is made of. |
Types
LookupOptions
interface LookupOptions {
family?: `IPv${IPFamily}` | IPFamily | 0
hints?: number
all?: boolean
}See also
- Bare modules — the full
bare-*catalog. - Bare runtime API — the runtime these modules extend.