class DnsHelper (View source)

Constants

private IPV4_REVERSE_ZONE_PATTERN

private IPV6_REVERSE_ZONE_PATTERN

Methods

static bool
isReverseZone(string $zoneName)

Tell whether a network can be derived from a reverse zone name.

static bool
isReverseZoneName(string $name)

Tell whether a name belongs to the reverse-DNS namespace.

static bool
isWithinZone(string $name, string $zoneName)

Tell whether a record name falls within a zone: the zone apex itself or any name under it. Comparison is case-insensitive and anchored on a label boundary, so "testexample.com" is not treated as inside "example.com".

static bool
isZoneApex(string $recordName, string $zoneName)

Check whether a record name is the zone apex.

static string|null
resolveReverseZoneName(string $input)

Resolve user input on a reverse-zone form to a reverse zone name.

static string
getRegisteredDomain(string $domain)

No description

static string
getSubDomainName(string $domain)

No description

static string
stripZoneSuffix(string $recordName, string $zoneName)

Strip zone name from record name for display purposes

static string
restoreZoneSuffix(string $hostname, string $zoneName)

Restore full record name from hostname and zone name

Details

static bool isReverseZone(string $zoneName)

Tell whether a network can be derived from a reverse zone name.

This is the strict test: the name must be a structured in-addr.arpa or ip6.arpa name. It gates network derivation on the add-zone form via resolveReverseZoneName(). For plain "is this a reverse zone at all" classification use isReverseZoneName().

Parameters

string $zoneName

Return Value

bool

static bool isReverseZoneName(string $name)

Tell whether a name belongs to the reverse-DNS namespace.

This is the broad classification test: any name under in-addr.arpa or ip6.arpa counts, including RFC 2317 classless names (e.g. "0-25.2.0.192.in-addr.arpa") that the strict isReverseZone() rejects because they carry no parsable network. Use this for listing, filtering and "is this a reverse zone at all" decisions; use isReverseZone() only when a network must be derived from the name.

Parameters

string $name

Return Value

bool

static bool isWithinZone(string $name, string $zoneName)

Tell whether a record name falls within a zone: the zone apex itself or any name under it. Comparison is case-insensitive and anchored on a label boundary, so "testexample.com" is not treated as inside "example.com".

Names are compared as given (no trailing-dot normalization); callers that accept FQDN-dotted input must normalize it before matching.

Parameters

string $name

Record name or hostname to test

string $zoneName

Zone name

Return Value

bool

True if $name is the zone apex or a subdomain of the zone

static bool isZoneApex(string $recordName, string $zoneName)

Check whether a record name is the zone apex.

Comparison is case-insensitive and ignores a trailing dot on either side.

Parameters

string $recordName

Record name (FQDN)

string $zoneName

Zone name

Return Value

bool

True if the record name equals the zone apex

static string|null resolveReverseZoneName(string $input)

Resolve user input on a reverse-zone form to a reverse zone name.

Passes an already-valid reverse zone name through unchanged and converts a network (e.g. 192.168.1.0/24, 2001:db8::/48) to its reverse zone name. Returns null when the input is neither, so the caller can reject it instead of silently creating a forward zone.

Pass-through is gated on isReverseZone() (not a looser .arpa suffix) because form input must be a canonical numeric reverse name or a parsable network. RFC 2317 range-style names carry no network to derive and are rejected here; the user enters the parent zone instead.

Parameters

string $input

Return Value

string|null

static string getRegisteredDomain(string $domain)

No description

Parameters

string $domain

Return Value

string

Exceptions

CannotProcessHost

static string getSubDomainName(string $domain)

No description

Parameters

string $domain

Return Value

string

static string stripZoneSuffix(string $recordName, string $zoneName)

Strip zone name from record name for display purposes

Parameters

string $recordName

The full record name (FQDN)

string $zoneName

The zone name to strip

Return Value

string

The hostname part without zone suffix, or '@' for zone apex

static string restoreZoneSuffix(string $hostname, string $zoneName)

Restore full record name from hostname and zone name

Parameters

string $hostname

The hostname part (or '@' for zone apex)

string $zoneName

The zone name

Return Value

string

The full record name (FQDN)