class SOARecordManager implements SOARecordManagerInterface (View source)

Service class for managing SOA records

Constants

MAX_SERIAL

Zone serials are 32-bit unsigned values (RFC 1982).

Methods

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

Constructor

string
getSOARecord(int $zone_id)

Get SOA record content for Zone ID

static string|null
getSOASerial(string $soa_rec)

Get SOA Serial Number

static string
expandSerialPlaceholder(string $newContent, string $oldContent)

Replace a literal "[SERIAL]", "[UNIXTIME]" or "[COUNTER]" in the serial field of a submitted SOA record with a numeric value. The subsequent updateSOASerial() bump (see EditRecordController) then advances the value, preserving RFC 1982 monotonicity even if today's serial has already been incremented several times.

static string
getNextDate(string $curr_date)

Get Next Date

int|string
getNextSerial(int|string $curr_serial)

Get Next Serial

bool
updateSOARecord(int $domain_id, string $content)

Update SOA record

static string
setSOASerial(string $soa_rec, string $serial)

Set SOA serial in SOA content

string
getUpdatedSOARecord(string $soa_rec)

Return SOA record with incremented serial number

bool
updateSOASerial(int $domain_id)

Update SOA serial

Details

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

Constructor

Parameters

PDO $db

Database connection

ConfigurationManager $config

Configuration manager

DnsBackendProvider|null $backendProvider

Optional DNS backend provider

string getSOARecord(int $zone_id)

Get SOA record content for Zone ID

Parameters

int $zone_id

Zone ID

Return Value

string

SOA content

static string|null getSOASerial(string $soa_rec)

Get SOA Serial Number

Parameters

string $soa_rec

SOA record content

Return Value

string|null

SOA serial

static string expandSerialPlaceholder(string $newContent, string $oldContent)

Replace a literal "[SERIAL]", "[UNIXTIME]" or "[COUNTER]" in the serial field of a submitted SOA record with a numeric value. The subsequent updateSOASerial() bump (see EditRecordController) then advances the value, preserving RFC 1982 monotonicity even if today's serial has already been incremented several times.

The resolved value never drops below the existing serial - slaves only transfer when the serial increases, so a format switch cannot rewind it.

Parameters

string $newContent

SOA content as submitted by the user

string $oldContent

Current SOA content from the zone (may be empty)

Return Value

string

SOA content with the placeholder resolved to a numeric value

static string getNextDate(string $curr_date)

Get Next Date

Parameters

string $curr_date

Current date in YYYYMMDD format

Return Value

string

Date +1 day

int|string getNextSerial(int|string $curr_serial)

Get Next Serial

Zone transfer to zone slave(s) will occur only if the serial number of the SOA RR is arithmetically greater that the previous one (as defined by RFC-1982).

The serial should be updated, unless:

  • the serial is set to "0", see http://doc.powerdns.com/types.html#id482176

  • set a fresh serial ONLY if the existing serial is lower than the current date

  • update date in serial if it reaches limit of revisions for today or do you think that ritual suicide is better in such case?

"This works unless you will require to make more than 99 changes until the new date is reached - in which case perhaps ritual suicide is the best option." http://www.zytrax.com/books/dns/ch9/serial.html

Parameters

int|string $curr_serial

Current Serial No

Return Value

int|string

Next serial number

bool updateSOARecord(int $domain_id, string $content)

Update SOA record

Parameters

int $domain_id

Domain ID

string $content

SOA content to set

Return Value

bool

true if success

static string setSOASerial(string $soa_rec, string $serial)

Set SOA serial in SOA content

Parameters

string $soa_rec

SOA record content

string $serial

New serial number

Return Value

string

Updated SOA record

string getUpdatedSOARecord(string $soa_rec)

Return SOA record with incremented serial number

Parameters

string $soa_rec

Current SOA record

Return Value

string

Updated SOA record

bool updateSOASerial(int $domain_id)

Update SOA serial

Increments SOA serial to next possible number

Parameters

int $domain_id

Domain ID

Return Value

bool

true if success