interface DnsBackendProvider (View source)

Interface for DNS data backend operations.

Abstracts the underlying DNS data store (direct SQL or PowerDNS REST API). Poweradmin-internal tables (zones, users, permissions, templates) are always accessed via SQL regardless of the backend - this interface only covers operations on PowerDNS data tables (domains, records, supermasters, etc.).

Methods

int|false
createZone(string $domain, string $type, string $slaveMaster = '')

Create a new zone in the DNS backend.

bool
deleteZone(int $domainId, string $zoneName)

Delete a zone and all its associated DNS data (records, metadata, cryptokeys).

bool
updateZoneType(int $domainId, string $type)

Change zone type (NATIVE, MASTER, SLAVE, PRODUCER, CONSUMER).

bool
updateZoneMaster(int $domainId, string $masterIp)

Update slave zone's master IP address.

bool
retrieveZone(int $domainId)

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

bool
updateZoneAccount(int $domainId, string $account)

Update zone account field.

array
getCatalogMembers(string $catalogName)

Zones carrying the given catalog.

array
getZonesByKind(string $kind)

Zones of one kind, with the catalog each currently belongs to.

string
getZoneCatalog(int $domainId)

Catalog the zone belongs to, lowercase and without a trailing dot, or '' when it is not a member.

bool
updateZoneCatalog(int $domainId, string $catalogName)

Join $catalogName, or leave the current catalog when it is ''.

bool
addRecord(int $domainId, string $name, string $type, string $content, int $ttl, int $prio)

Add a DNS record.

int|string|null
addRecordGetId(int $domainId, string $name, string $type, string $content, int $ttl, int $prio)

Add a DNS record and return its ID.

int|string|null
createRecordAtomic(int $domainId, string $name, string $type, string $content, int $ttl, int $prio, int $disabled = 0)

Create a DNS record atomically with optional disabled flag.

bool
editRecord(int|string $recordId, string $name, string $type, string $content, int $ttl, int $prio, int $disabled, array|null $comment = null)

Edit an existing DNS record.

bool
deleteRecord(int|string $recordId)

Delete a DNS record by ID.

bool
deleteRecordsByDomainId(int $domainId)

Delete all records for a given domain.

bool
updateSOASerial(int $domainId)

Update the SOA serial for a zone.

bool
addSupermaster(string $masterIp, string $nsName, string $account)

Add a supermaster (autoprimary).

bool
deleteSupermaster(string $masterIp, string $nsName)

Delete a supermaster (autoprimary).

array
getSupermasters()

Get all supermasters.

bool
updateSupermaster(string $oldMasterIp, string $oldNsName, string $newMasterIp, string $newNsName, string $account)

Update a supermaster.

bool
zoneExists(string $zoneName)

Check if a zone exists by name.

array|null
getZoneById(int $domainId)

Get zone info by ID.

string|null
getZoneNameById(int $domainId)

Get zone name by domain ID.

int|null
getZoneIdByName(string $zoneName)

Get zone ID by name.

string
getZoneTypeById(int $domainId)

Get zone type by domain ID.

string|null
getZoneMasterById(int $domainId)

Get zone master by domain ID.

array|null
getRecordById(int|string $recordId)

Get a single record by ID.

int
getZoneIdFromRecordId(int|string $recordId)

Get zone ID from a record ID.

array
getZoneStats(bool $withDnssec = true)

Get bulk zone stats (DNSSEC state, SOA serials) keyed by zone name.

int
countZoneRecords(int $domainId)

Count non-ENT records in a zone.

array|null
getZoneSoaHealth(string $zoneName, string $kind)

Report SOA-record presence and disabled state for a zone, used by zone-list UIs to render "Disabled" / "No SOA" badges. SLAVE zones legitimately have no SOA (records arrive via AXFR), so callers may pass the zone kind to skip unnecessary lookups; implementations must return is_missing_soa=false for SLAVE.

bool
recordExists(int $domainId, string $name, string $type, string $content)

Check if a record with given attributes exists.

array
getRecordsByZoneId(int $domainId, string|null $type = null)

Get records by zone ID, optionally filtered by type.

array
getRecordsByName(int $domainId, string $name, string|null $type = null)

Get the records at one name in a zone, optionally filtered by type.

string
getSOARecord(int $domainId)

Get SOA record content for a zone.

int
getBestMatchingReverseZoneId(string $reverseName)

Find the best matching reverse zone ID for a PTR record name.

array
getZones(bool $withDnssec = true)

Get all zones from the DNS backend.

array|null
getZoneByName(string $zoneName)

Get a single zone by name with its type, master, and DNSSEC status.

array
getZoneRecords(int $domainId, string $zoneName)

Get all records for a zone from the DNS backend.

array
searchDnsData(string $query, string $objectType = 'all', int $max = 100)

Search for zones and records matching a query.

bool
isApiBackend()

Check if this is the API backend.

bool
hasSoaEditApi(int $domainId)

Check whether the zone has soa_edit_api configured in PowerDNS.

bool
setZoneSerialPolicy(int $domainId, string $zoneName, array $properties)

Set the zone's SOA serial policy metadata.

Details

int|false createZone(string $domain, string $type, string $slaveMaster = '')

Create a new zone in the DNS backend.

Parameters

string $domain

Zone name (without trailing dot)

string $type

Zone type: NATIVE, MASTER, SLAVE, PRODUCER, or CONSUMER

string $slaveMaster

Master IP for kinds that replicate from a primary (SLAVE, CONSUMER)

Return Value

int|false

The new domain ID, or false on failure

bool deleteZone(int $domainId, string $zoneName)

Delete a zone and all its associated DNS data (records, metadata, cryptokeys).

Does NOT delete Poweradmin-internal data (zones table, records_zone_templ, etc.)

  • those are handled by the caller.

Parameters

int $domainId

Domain ID

string $zoneName

Zone name (needed for API calls)

Return Value

bool

bool updateZoneType(int $domainId, string $type)

Change zone type (NATIVE, MASTER, SLAVE, PRODUCER, CONSUMER).

Masters are cleared unless the new kind replicates from a primary.

Parameters

int $domainId

Domain ID

string $type

New zone type

Return Value

bool

bool updateZoneMaster(int $domainId, string $masterIp)

Update slave zone's master IP address.

Parameters

int $domainId

Domain ID

string $masterIp

Master IP address

Return Value

bool

bool retrieveZone(int $domainId)

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

Only the API backend can trigger this. The SQL backend returns false, since PowerDNS pulls secondaries on its own refresh schedule there.

Parameters

int $domainId

Domain ID

Return Value

bool

bool updateZoneAccount(int $domainId, string $account)

Update zone account field.

Parameters

int $domainId

Domain ID

string $account

Account value

Return Value

bool

array getCatalogMembers(string $catalogName)

Zones carrying the given catalog.

PowerDNS only publishes a member whose kind is MASTER or PRODUCER and which has an enabled apex SOA, so the kind is returned for callers to flag the rest.

Parameters

string $catalogName

Producer zone name, lowercase and without a trailing dot

Return Value

array

array getZonesByKind(string $kind)

Zones of one kind, with the catalog each currently belongs to.

Parameters

string $kind

A ZoneType constant

Return Value

array

string getZoneCatalog(int $domainId)

Catalog the zone belongs to, lowercase and without a trailing dot, or '' when it is not a member.

Parameters

int $domainId

Domain ID

Return Value

string

bool updateZoneCatalog(int $domainId, string $catalogName)

Join $catalogName, or leave the current catalog when it is ''.

Parameters

int $domainId

Domain ID

string $catalogName

Producer zone name in canonical form, or '' to clear

Return Value

bool

bool addRecord(int $domainId, string $name, string $type, string $content, int $ttl, int $prio)

Add a DNS record.

Parameters

int $domainId

Domain ID

string $name

Record name

string $type

Record type (A, AAAA, CNAME, MX, etc.)

string $content

Record content

int $ttl Time-to-live
int $prio Priority

Return Value

bool

int|string|null addRecordGetId(int $domainId, string $name, string $type, string $content, int $ttl, int $prio)

Add a DNS record and return its ID.

Parameters

int $domainId

Domain ID

string $name

Record name

string $type

Record type

string $content

Record content

int $ttl Time-to-live
int $prio Priority

Return Value

int|string|null

The new record ID (int for SQL mode, encoded string for API mode), or null on failure

int|string|null createRecordAtomic(int $domainId, string $name, string $type, string $content, int $ttl, int $prio, int $disabled = 0)

Create a DNS record atomically with optional disabled flag.

In SQL mode, wraps the INSERT in a transaction with deadlock retry. In API mode, delegates to addRecordGetId + optional editRecord.

Parameters

int $domainId

Domain ID

string $name

Record name

string $type

Record type

string $content

Record content

int $ttl Time-to-live
int $prio Priority
int $disabled

Disabled flag (0 = enabled, 1 = disabled)

Return Value

int|string|null

The new record ID, or null on failure

bool editRecord(int|string $recordId, string $name, string $type, string $content, int $ttl, int $prio, int $disabled, array|null $comment = null)

Edit an existing DNS record.

Parameters

int|string $recordId

Record ID (int for SQL mode, encoded string for API mode)

string $name

New record name

string $type

New record type

string $content

New record content

int $ttl

New TTL

int $prio

New priority

int $disabled

Whether record is disabled (0 or 1)

array|null $comment

RRset comment ['content' => string, 'account' => string]; null leaves comments untouched, empty content clears them. SQL mode ignores it.

Return Value

bool

bool deleteRecord(int|string $recordId)

Delete a DNS record by ID.

Parameters

int|string $recordId

Record ID (int for SQL mode, encoded string for API mode)

Return Value

bool

bool deleteRecordsByDomainId(int $domainId)

Delete all records for a given domain.

Parameters

int $domainId

Domain ID

Return Value

bool

bool updateSOASerial(int $domainId)

Update the SOA serial for a zone.

In API mode this is a no-op since PowerDNS handles serial increments automatically via soa_edit_api.

Parameters

int $domainId

Domain ID

Return Value

bool

bool addSupermaster(string $masterIp, string $nsName, string $account)

Add a supermaster (autoprimary).

Parameters

string $masterIp

Supermaster IP address

string $nsName

Nameserver hostname

string $account

Account name

Return Value

bool

bool deleteSupermaster(string $masterIp, string $nsName)

Delete a supermaster (autoprimary).

Parameters

string $masterIp

Supermaster IP address

string $nsName

Nameserver hostname

Return Value

bool

array getSupermasters()

Get all supermasters.

Return Value

array

Array of supermaster records

bool updateSupermaster(string $oldMasterIp, string $oldNsName, string $newMasterIp, string $newNsName, string $account)

Update a supermaster.

Parameters

string $oldMasterIp

Original IP

string $oldNsName

Original nameserver

string $newMasterIp

New IP

string $newNsName

New nameserver

string $account

Account name

Return Value

bool

bool zoneExists(string $zoneName)

Check if a zone exists by name.

Parameters

string $zoneName

Zone name

Return Value

bool

array|null getZoneById(int $domainId)

Get zone info by ID.

Parameters

int $domainId

Domain ID

Return Value

array|null

[id, name, type, master, dnssec] or null

string|null getZoneNameById(int $domainId)

Get zone name by domain ID.

Parameters

int $domainId

Domain ID

Return Value

string|null

Zone name or null

int|null getZoneIdByName(string $zoneName)

Get zone ID by name.

Parameters

string $zoneName

Zone name

Return Value

int|null

Domain ID or null

string getZoneTypeById(int $domainId)

Get zone type by domain ID.

Parameters

int $domainId

Domain ID

Return Value

string

Zone type (NATIVE, MASTER, SLAVE)

string|null getZoneMasterById(int $domainId)

Get zone master by domain ID.

Parameters

int $domainId

Domain ID

Return Value

string|null

Master IP or null

array|null getRecordById(int|string $recordId)

Get a single record by ID.

Parameters

int|string $recordId

Record ID (int for SQL mode, encoded string for API mode)

Return Value

array|null

Record data or null

int getZoneIdFromRecordId(int|string $recordId)

Get zone ID from a record ID.

Parameters

int|string $recordId

Record ID (int for SQL mode, encoded string for API mode)

Return Value

int

Zone ID (0 if not found)

array getZoneStats(bool $withDnssec = true)

Get bulk zone stats (DNSSEC state, SOA serials) keyed by zone name.

SQL backends may return an empty array when this data is not needed; API backends fetch it in a single call to avoid N+1 lookups in zone lists. Record counts are not included - the PowerDNS zone list carries none.

Parameters

bool $withDnssec

Set false when neither the DNSSEC flag nor edited_serial is needed

Return Value

array

int countZoneRecords(int $domainId)

Count non-ENT records in a zone.

Parameters

int $domainId

Domain ID

Return Value

int

Record count

array|null getZoneSoaHealth(string $zoneName, string $kind)

Report SOA-record presence and disabled state for a zone, used by zone-list UIs to render "Disabled" / "No SOA" badges. SLAVE zones legitimately have no SOA (records arrive via AXFR), so callers may pass the zone kind to skip unnecessary lookups; implementations must return is_missing_soa=false for SLAVE.

Returns null on transient backend failure so callers can preserve any previously-cached state instead of overwriting it with an inferred default.

Parameters

string $zoneName

Zone name (without trailing dot)

string $kind

Zone kind ('MASTER', 'NATIVE', 'SLAVE', 'PRODUCER', 'CONSUMER')

Return Value

array|null

bool recordExists(int $domainId, string $name, string $type, string $content)

Check if a record with given attributes exists.

Parameters

int $domainId

Domain ID

string $name

Record name

string $type

Record type

string $content

Record content

Return Value

bool

array getRecordsByZoneId(int $domainId, string|null $type = null)

Get records by zone ID, optionally filtered by type.

Parameters

int $domainId

Domain ID

string|null $type

Optional record type filter

Return Value

array

Array of record data

array getRecordsByName(int $domainId, string $name, string|null $type = null)

Get the records at one name in a zone, optionally filtered by type.

Names match case-insensitively, per RFC 4343.

Parameters

int $domainId

Domain ID

string $name

Record name, with or without a trailing dot

string|null $type

Optional record type filter

Return Value

array

Array of record data

string getSOARecord(int $domainId)

Get SOA record content for a zone.

Parameters

int $domainId

Domain ID

Return Value

string

SOA content or empty string

int getBestMatchingReverseZoneId(string $reverseName)

Find the best matching reverse zone ID for a PTR record name.

Parameters

string $reverseName

Reverse name (e.g. 1.168.192.in-addr.arpa)

Return Value

int

Zone ID or -1 if not found

array getZones(bool $withDnssec = true)

Get all zones from the DNS backend.

Returns raw zone data without Poweradmin metadata (ownership, comments). Each zone array contains: name, type, dnssec (bool), master (string).

Parameters

bool $withDnssec

Set false to skip DNSSEC state; API backends then avoid a per-zone lookup and report dnssec as false

Return Value

array

Array of zone data arrays

array|null getZoneByName(string $zoneName)

Get a single zone by name with its type, master, and DNSSEC status.

Parameters

string $zoneName

Zone name (without trailing dot)

Return Value

array|null

Zone data array or null if not found

array getZoneRecords(int $domainId, string $zoneName)

Get all records for a zone from the DNS backend.

Returns a flat array of record data. In SQL mode, records include numeric IDs. In API mode, IDs are resolved from the database. ENT records (null/empty type) are excluded.

Parameters

int $domainId

Domain ID

string $zoneName

Zone name (needed for API calls)

Return Value

array

Array of record data arrays

array searchDnsData(string $query, string $objectType = 'all', int $max = 100)

Search for zones and records matching a query.

Returns separate arrays for zone matches and record matches. Results contain only DNS data - callers must enrich with Poweradmin metadata (ownership, permissions).

Parameters

string $query

Search query (supports wildcards)

string $objectType

Filter: 'all', 'zone', 'record'

int $max

Maximum results

Return Value

array

bool isApiBackend()

Check if this is the API backend.

Callers can use this to adjust behavior (e.g., skip manual SOA serial updates, show notices about search limitations).

Return Value

bool

bool hasSoaEditApi(int $domainId)

Check whether the zone has soa_edit_api configured in PowerDNS.

Returns false for SQL backends (not applicable).

Parameters

int $domainId

Return Value

bool

bool setZoneSerialPolicy(int $domainId, string $zoneName, array $properties)

Set the zone's SOA serial policy metadata.

Keys are the zone-object property names from MetadataDefinitions::SERIAL_POLICY_PROPERTY_KINDS. An empty string clears the policy. API backend updates the zone object; SQL backend replaces the matching domainmetadata rows.

Parameters

int $domainId
string $zoneName
array $properties

Return Value

bool