From 0208812013ab30347137f2230bf3c0d0e83cb9c2 Mon Sep 17 00:00:00 2001 From: Michael Kaufmann Date: Sun, 27 Jun 2021 08:41:16 +0200 Subject: [PATCH] prefer custom zone entries over automatically created ones when system.dns_createmailentry is enabled, fixes #944 Signed-off-by: Michael Kaufmann --- lib/Froxlor/Dns/Dns.php | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/lib/Froxlor/Dns/Dns.php b/lib/Froxlor/Dns/Dns.php index fa95586e..f333c3d1 100644 --- a/lib/Froxlor/Dns/Dns.php +++ b/lib/Froxlor/Dns/Dns.php @@ -53,7 +53,7 @@ class Dns $domain = $domain_id; } - if ($domain['isbinddomain'] != '1') { + if (!isset($domain['isbinddomain']) || $domain['isbinddomain'] != '1') { return; } @@ -190,12 +190,26 @@ class Dns '@', 'www', '*' - ] as $crceord) { - if ($entry['type'] == 'CNAME' && $entry['record'] == '@' && (array_key_exists(md5($crceord), $required_entries['A']) || array_key_exists(md5($crceord), $required_entries['AAAA']))) { - unset($required_entries['A'][md5($crceord)]); - unset($required_entries['AAAA'][md5($crceord)]); + ] as $crecord) { + if ($entry['type'] == 'CNAME' && $entry['record'] == '@' && (array_key_exists(md5($crecord), $required_entries['A']) || array_key_exists(md5($crecord), $required_entries['AAAA']))) { + unset($required_entries['A'][md5($crecord)]); + unset($required_entries['AAAA'][md5($crecord)]); } } + // also allow overriding of auto-generated values (imap,pop3,mail,smtp) if enabled in the settings + if (Settings::Get('system.dns_createmailentry')) { + foreach (array( + 'imap', + 'pop3', + 'mail', + 'smtp' + ) as $crecord) { + if ($entry['type'] == 'CNAME' && $entry['record'] == $crecord && (array_key_exists(md5($crecord), $required_entries['A']) || array_key_exists(md5($crecord), $required_entries['AAAA']))) { + unset($required_entries['A'][md5($crecord)]); + unset($required_entries['AAAA'][md5($crecord)]); + } + } + } $zonerecords[] = new DnsEntry($entry['record'], $entry['type'], $entry['content'], $entry['prio'], $entry['ttl']); }