class DomainManager implements DomainManagerInterface (View source)

Service class for managing domains/zones

Constants

private IPV4_REVERSE_TEMPLATE_TYPES

Decide whether a template record should be inserted into the target zone.

Historically IPv4 reverse zones (in-addr.arpa) were limited to NS/SOA because early templates auto-populated A records for webip/mailip. The allowlist now also covers PTR, LUA, CNAME and TXT so legitimate reverse-zone records (e.g. LUA-driven dynamic PTR generation, RFC 2317 classless delegations) are no longer silently dropped. IPv6 reverse zones (ip6.arpa) carry no restriction.

Methods

__construct(PDO $db, ConfigurationManager $config, SOARecordManagerInterface $soaRecordManager, DomainRepositoryInterface $domainRepository, DnsBackendProvider|null $backendProvider = null, LoggerInterface|null $logger = null, RecordChangeLogger|null $changeLogger = null, UserContextService|null $userContext = null)

Constructor

addDomain(object $db, string $domain, int|null $owner, string $type, string $slave_master, int|string $zone_template, array $groupIds = [], string|null $soaEditApi = null)

Add a domain to the database

deleteDomain(int $id)

Deletes a domain by a given id

bool
retrieveZone(int $id)

Request an immediate AXFR transfer of a secondary zone from its master.

changeZoneType(string $type, int $id)

Change Zone Type

changeZoneSlaveMaster(int $zone_id, string $ip_slave_master)

Change Slave Zone's Master IP Address

addOwnerToZone(int $zone_id, int $user_id)

Add a user as an owner of a zone. An existing owner is left as is and reported as success.

static int
getZoneTemplate(object $db, int $zone_id)

Get Zone Template ID for Zone ID

updateZoneRecords(string $db_type, int $dns_ttl, int $zone_id, int $zone_template_id)

Update All Zone Records for Zone ID with Zone Template

Details

__construct(PDO $db, ConfigurationManager $config, SOARecordManagerInterface $soaRecordManager, DomainRepositoryInterface $domainRepository, DnsBackendProvider|null $backendProvider = null, LoggerInterface|null $logger = null, RecordChangeLogger|null $changeLogger = null, UserContextService|null $userContext = null)

Constructor

Parameters

PDO $db

Database connection

ConfigurationManager $config

Configuration manager

SOARecordManagerInterface $soaRecordManager

SOA record manager

DomainRepositoryInterface $domainRepository

Domain repository

DnsBackendProvider|null $backendProvider

DNS backend provider (auto-created if null)

LoggerInterface|null $logger
RecordChangeLogger|null $changeLogger
UserContextService|null $userContext

ZoneWriteResult addDomain(object $db, string $domain, int|null $owner, string $type, string $slave_master, int|string $zone_template, array $groupIds = [], string|null $soaEditApi = null)

Add a domain to the database

Parameters

object $db

Database connection

string $domain

A domain name

int|null $owner

Owner ID for domain (null if only groups are assigned)

string $type

Type of domain ['NATIVE','MASTER','SLAVE']

string $slave_master

Master server hostname for domain

int|string $zone_template

ID of zone template ['none' or int]

array $groupIds

Group IDs for group ownership (assigned atomically within the same transaction)

string|null $soaEditApi

SOA-EDIT-API policy for the new zone; 'OFF' disables, null uses the dns.soa_edit_api config default

Return Value

ZoneWriteResult

ZoneWriteResult deleteDomain(int $id)

Deletes a domain by a given id

Parameters

int $id

Zone ID

Return Value

ZoneWriteResult

bool retrieveZone(int $id)

Request an immediate AXFR transfer of a secondary zone from its master.

Parameters

int $id

Zone ID

Return Value

bool

true on success

ZoneWriteResult changeZoneType(string $type, int $id)

Change Zone Type

Parameters

string $type

New Zone Type [NATIVE,MASTER,SLAVE]

int $id

Zone ID

Return Value

ZoneWriteResult

ZoneWriteResult changeZoneSlaveMaster(int $zone_id, string $ip_slave_master)

Change Slave Zone's Master IP Address

Parameters

int $zone_id

Zone ID

string $ip_slave_master

Master IP Address

Return Value

ZoneWriteResult

ZoneWriteResult addOwnerToZone(int $zone_id, int $user_id)

Add a user as an owner of a zone. An existing owner is left as is and reported as success.

Parameters

int $zone_id

Zone ID

int $user_id

User ID

Return Value

ZoneWriteResult

static int getZoneTemplate(object $db, int $zone_id)

Get Zone Template ID for Zone ID

Parameters

object $db

Database connection

int $zone_id

Zone ID

Return Value

int

Zone Template ID

ZoneWriteResult updateZoneRecords(string $db_type, int $dns_ttl, int $zone_id, int $zone_template_id)

Update All Zone Records for Zone ID with Zone Template

Parameters

string $db_type

Database type

int $dns_ttl

Default TTL

int $zone_id

Zone ID to update

int $zone_template_id

Zone Template ID to use for update

Return Value

ZoneWriteResult