From 7566def0d1b9466f5a397c885d4bf75249620f1a Mon Sep 17 00:00:00 2001 From: Udo Waechter Date: Thu, 25 Sep 2025 09:40:40 +0200 Subject: [PATCH] TODO: This is a dkim hack --- lib/Froxlor/Dns/Dns.php | 68 ++++++++++++++++++++++++----------------- 1 file changed, 40 insertions(+), 28 deletions(-) diff --git a/lib/Froxlor/Dns/Dns.php b/lib/Froxlor/Dns/Dns.php index dc7a134b..7578ce94 100644 --- a/lib/Froxlor/Dns/Dns.php +++ b/lib/Froxlor/Dns/Dns.php @@ -22,7 +22,6 @@ * @author Froxlor team * @license https://files.froxlor.org/misc/COPYING.txt GPLv2 */ - namespace Froxlor\Dns; use Froxlor\Database\Database; @@ -523,7 +522,7 @@ class Dns * @param array $domain * @return array */ - private static function generateDkimEntries(array $domain): array + /** private static function generateDkimEntries(array $domain): array { $zone_dkim = []; @@ -569,7 +568,20 @@ class Dns } return $zone_dkim; - } + } */ + private static function generateDkimEntries(array $domain): array + { + $zone_dkim = []; + if (Settings::Get('dkim.use_dkim') == '1' && $domain['dkim'] == '1' && $domain['dkim_pubkey'] != '') { + // start + $dkim_txt = '("v=DKIM1;k=rsa;p=MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAosq0CmLqEzJJxIHkQwG1Xwk6CSyHHWSDXL9BHCKzY9lJXH7a23PogVlLvUBYaAg" + "BtFOpsKuUCBl+/g6rOqgVXKg0OpYdpgTxZyz1i4NcubGFLifQGnF8ZKpIEDqIzmLI6SbH+9DKwYA319sXAR6feZI4g5bWqF07t/kzA5LN+2V5QnDQ3th++GPRl5rmW" + "F6uoidIRD85UZVEX4s3J1hce0k6tRb2aEozCJaSXHUwyarmbbX/5rky467QQ+45Uy0q9CNaMMu1IX5eybhLRxYXK1k0TfIRJv4FH1UFLlq2QoGC7d+KvLrUabhzQ5w" + "bdZkWuVgLFZ7CL2NegfzO6YeEcQIDAQAB")'; + $zone_dkim[] = $dkim_txt; + } + return $zone_dkim; +} /** * @param string $txt_content @@ -577,35 +589,35 @@ class Dns * @return string */ public static function encloseTXTContent(string $txt_content, bool $isMultiLine = false): string - { - // check that TXT content is enclosed in " " - if (!$isMultiLine && Settings::Get('system.dns_server') != 'PowerDNS') { - if (substr($txt_content, 0, 1) != '"') { - $txt_content = '"' . $txt_content; - } - if (substr($txt_content, -1) != '"') { - $txt_content .= '"'; - } - } - if (Settings::Get('system.dns_server') == 'PowerDNS') { - // no quotation for PowerDNS - if (substr($txt_content, 0, 1) == '"') { - $txt_content = substr($txt_content, 1); - } - if (substr($txt_content, -1) == '"') { - $txt_content = substr($txt_content, 0, -1); - } - } - return $txt_content; - } + { + // check that TXT content is enclosed in " " + if (! $isMultiLine && Settings::Get('system.dns_server') != 'PowerDNS') { + if (substr($txt_content, 0, 1) != '"') { + $txt_content = '"' . $txt_content; + } + if (substr($txt_content, - 1) != '"') { + $txt_content .= '"'; + } + } + if (Settings::Get('system.dns_server') == 'PowerDNS') { + // no quotation for PowerDNS + if (substr($txt_content, 0, 1) == '"') { + $txt_content = substr($txt_content, 1); + } + if (substr($txt_content, - 1) == '"') { + $txt_content = substr($txt_content, 0, - 1); + } + } + return $txt_content; + } /** * @param string $email * @return string */ private static function escapeSoaAdminMail(string $email): string - { - $mail_parts = explode("@", $email); - return str_replace(".", "\.", $mail_parts[0]) . "." . $mail_parts[1] . "."; - } + { + $mail_parts = explode("@", $email); + return str_replace(".", "\.", $mail_parts[0]) . "." . $mail_parts[1] . "."; + } }