From 18f0b70cdfcf5bc20a0d74ea08f5605c132082e2 Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Wed, 11 Mar 2020 14:13:44 +0100 Subject: ddns.php: update aliases per ip-version separately --- ddns.php | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/ddns.php b/ddns.php index afa1bfc..7437a9f 100644 --- a/ddns.php +++ b/ddns.php @@ -203,24 +203,27 @@ $zone_file .= fread($pin, 1024); $zone_file = explode("\n", trim($zone_file)); pclose($pin); + $updateCommand .= + "zone ddns.eckner.net.\n"; foreach($aliasess as $aliases) { $aliases = explode(' ', trim($aliases)); $alias = array_shift($aliases); - $updateCommand .= - "zone ddns.eckner.net.\n" . - "prereq yxrrset " . $alias . ".ddns.eckner.net.\n" . - "update delete " . $alias . ".ddns.eckner.net.\n" . - "send\n"; - foreach($aliases as $representative) { - foreach($zone_file as $zone_file_entry) { - if (preg_match('/^'.$representative.' ([0-9]+) (AAAA|A) (\S+)$/', $zone_file_entry, $match)) { - $updateCommand .= - "update add " . $alias . ".ddns.eckner.net. " . $match[1] . " IN " . $match[2] . " " . $match[3] . "\n"; + foreach ($hasRrType as $rrType => $dummy) { + $updateCommand .= + "prereq yxrrset " . $alias . ".ddns.eckner.net. IN " . $rrType . "\n" . + "update delete " . $alias . ".ddns.eckner.net. IN " . $rrType . "\n" . + "send\n"; + foreach($aliases as $representative) { + foreach($zone_file as $zone_file_entry) { + if (preg_match('/^'.$representative.' ([0-9]+) (' . $rrType . ') (\S+)$/', $zone_file_entry, $match)) { + $updateCommand .= + "update add " . $alias . ".ddns.eckner.net. " . $match[1] . " IN " . $match[2] . " " . $match[3] . "\n"; + } } } + $updateCommand .= + "send\n"; } - $updateCommand .= - "send\n"; } } -- cgit v1.2.3-70-g09d2