class CNAMERecordValidator implements DnsRecordValidatorInterface (View source)

Validator for CNAME DNS records

Validates CNAME records according to:

  • RFC 1034: Domain Names - Concepts and Facilities
  • RFC 1035: Domain Names - Implementation and Specification
  • RFC 2181: Clarifications to the DNS Specification (Section 10.1)

CNAME records (Canonical Name) create an alias from one domain name to another. According to RFC 1034 and RFC 2181, CNAME record names must be unique, cannot coexist with other record types, and MX/NS records cannot point to a CNAME.

Methods

__construct(ConfigurationManager $config, PDO $db, DnsBackendProvider|null $backendProvider = null)

Constructor

validate(string $content, string $name, mixed $prio, int|string|null $ttl, int $defaultTTL, mixed ...$args)

Validate CNAME record

validateSyntax(string $content, string $name, mixed $prio, int|string|null $ttl, int $defaultTTL)

Validate the parts of a CNAME record that do not depend on the zone it lives in.

validateCnameExistence(string $name, int|string $rid)

Check if CNAME already exists

Details

__construct(ConfigurationManager $config, PDO $db, DnsBackendProvider|null $backendProvider = null)

Constructor

Parameters

ConfigurationManager $config
PDO $db
DnsBackendProvider|null $backendProvider

Optional DNS backend provider

ValidationResult validate(string $content, string $name, mixed $prio, int|string|null $ttl, int $defaultTTL, mixed ...$args)

Validate CNAME record

Parameters

string $content

The content part of the record

string $name

The name part of the record

mixed $prio

The priority value (if applicable)

int|string|null $ttl

The TTL value

int $defaultTTL

The default TTL to use if not specified

mixed ...$args

Additional validator-specific parameters

Return Value

ValidationResult

ValidationResult containing validated data or error messages

ValidationResult validateSyntax(string $content, string $name, mixed $prio, int|string|null $ttl, int $defaultTTL)

Validate the parts of a CNAME record that do not depend on the zone it lives in.

Callers holding a record with no zone context - zone template records, for instance - use this to check the record itself without the existence lookups that only make sense against a real zone.

Parameters

string $content

Target hostname

string $name

CNAME hostname

mixed $prio

Priority (not used for CNAME records)

int|string|null $ttl

TTL value

int $defaultTTL

Default TTL value

Return Value

ValidationResult

ValidationResult containing validated data or error messages

ValidationResult validateCnameExistence(string $name, int|string $rid)

Check if CNAME already exists

Parameters

string $name CNAME
int|string $rid

Record ID (-1 for new records, string in API backend mode)

Return Value

ValidationResult

ValidationResult containing success or error message