diff --git a/automation/config.php.dist b/automation/config.php.dist index c502ffc..40233ab 100644 --- a/automation/config.php.dist +++ b/automation/config.php.dist @@ -45,6 +45,7 @@ return [ // ... more name servers as needed ... ], 'dns_soa' => 'hostmaster.example.com', + 'dns_serial' => 1, // change to 2 for YYYYMMDDXX format, and 3 for Cloudflare-like serial 'zone_mode' => 'default', // nice is also available // URS Configuration diff --git a/automation/helpers.php b/automation/helpers.php index 71db1ab..051e093 100644 --- a/automation/helpers.php +++ b/automation/helpers.php @@ -284,3 +284,26 @@ function processUrlAbuseData($fileContent) { function checkUrlAbuse($domain, Map $urlAbuseData) { return $urlAbuseData->get($domain, false); } + +function generateSerial($soa_type = null) { + // Default to Type 1 if $soa_type is not set, null, or invalid + $soa_type = $soa_type ?? 1; + + switch ($soa_type) { + case 2: // Date-based, updates every 15 minutes + $hour = (int) date('H'); + $segment = (int)(date('i') / 15); // 0 through 3 + $offset = $hour * 4 + $segment; // Converts hour + quarter into a unique number + return date('Ymd') . str_pad($offset, 2, '0', STR_PAD_LEFT); + + case 3: // Cloudflare-like serial + $referenceTimestamp = strtotime("2020-11-01 00:00:00"); // Reference point + $timeDifference = time() - $referenceTimestamp; // Difference in seconds + $serial = $timeDifference + 2350000000; // Offset to ensure longer serials + return $serial; + + case 1: // Fixed-length, second-based serial (default) + default: + return time(); + } +} \ No newline at end of file diff --git a/automation/write-zone.php b/automation/write-zone.php index 770872b..3e9bcbd 100644 --- a/automation/write-zone.php +++ b/automation/write-zone.php @@ -38,7 +38,7 @@ Coroutine::create(function () use ($pool, $log, $c) { $pdo = $pool->get(); $sth = $pdo->prepare('SELECT id, tld FROM domain_tld'); $sth->execute(); - $timestamp = time(); + $serial = generateSerial($c['dns_serial'] ?? 1); $tlds = []; @@ -54,7 +54,7 @@ Coroutine::create(function () use ($pool, $log, $c) { $soa->setRdata(Factory::Soa( $c['ns']['ns1'] . '.', $c['dns_soa'] . '.', - $timestamp, + $serial, 900, 1800, 3600000,