Universal reverse DNS pointer names for IP addresses.
This module provides addressToArpa, which picks the IP version from the
shape of its argument and delegates to the version-specific function. The
name it builds is where a PTR record for the address lives: the four IPv4
octets reversed under in-addr.arpa (RFC 1035 §3.5), or all 32 IPv6
nibbles reversed under ip6.arpa (RFC 3596 §2.5).
For version-specific functions, see:
The names are relative
No trailing dot. 1.0.168.192.in-addr.arpa, not
1.0.168.192.in-addr.arpa. — the dot is DNS wire-format framing, and
every other stringifier in this package emits a bare canonical form
without it. Callers handing the name to a resolver that requires an
absolute name append "." themselves. See ADR 0009.
Addresses only
There is no prefix or zone form. The reverse zone name of a CIDR block is only well defined on a byte (IPv4) or nibble (IPv6) boundary, and the RFC 2317 classless-delegation name is a different construct again; if either is ever wanted it gets its own name. There is no inverse direction either — nothing in this package parses DNS names.
Look up the PTR record of an address
Look up the PTR record of an address
import { assertEquals } from "@std/assert"; import { addressToArpa } from "@hertzg/ip/arpa"; import { parseAddress } from "@hertzg/ip/address"; assertEquals(addressToArpa(parseAddress("8.8.8.8").address), "8.8.8.8.in-addr.arpa"); assertEquals( addressToArpa(parseAddress("2001:4860:4860::8888").address), "8.8.8.8.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.6.8.4.0.6.8.4.1.0.0.2.ip6.arpa", );
Builds the reverse DNS pointer name of an IP address of either version.
Usage
import * as mod from "arpa.ts";