TODO: This is a dkim hack

This commit is contained in:
2025-09-25 09:40:40 +02:00
parent 3630f82817
commit 7566def0d1

View File

@@ -22,7 +22,6 @@
* @author Froxlor team <team@froxlor.org> * @author Froxlor team <team@froxlor.org>
* @license https://files.froxlor.org/misc/COPYING.txt GPLv2 * @license https://files.froxlor.org/misc/COPYING.txt GPLv2
*/ */
namespace Froxlor\Dns; namespace Froxlor\Dns;
use Froxlor\Database\Database; use Froxlor\Database\Database;
@@ -523,7 +522,7 @@ class Dns
* @param array $domain * @param array $domain
* @return array * @return array
*/ */
private static function generateDkimEntries(array $domain): array /** private static function generateDkimEntries(array $domain): array
{ {
$zone_dkim = []; $zone_dkim = [];
@@ -569,7 +568,20 @@ class Dns
} }
return $zone_dkim; 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 * @param string $txt_content
@@ -577,35 +589,35 @@ class Dns
* @return string * @return string
*/ */
public static function encloseTXTContent(string $txt_content, bool $isMultiLine = false): string public static function encloseTXTContent(string $txt_content, bool $isMultiLine = false): string
{ {
// check that TXT content is enclosed in " " // check that TXT content is enclosed in " "
if (!$isMultiLine && Settings::Get('system.dns_server') != 'PowerDNS') { if (! $isMultiLine && Settings::Get('system.dns_server') != 'PowerDNS') {
if (substr($txt_content, 0, 1) != '"') { if (substr($txt_content, 0, 1) != '"') {
$txt_content = '"' . $txt_content; $txt_content = '"' . $txt_content;
} }
if (substr($txt_content, -1) != '"') { if (substr($txt_content, - 1) != '"') {
$txt_content .= '"'; $txt_content .= '"';
} }
} }
if (Settings::Get('system.dns_server') == 'PowerDNS') { if (Settings::Get('system.dns_server') == 'PowerDNS') {
// no quotation for PowerDNS // no quotation for PowerDNS
if (substr($txt_content, 0, 1) == '"') { if (substr($txt_content, 0, 1) == '"') {
$txt_content = substr($txt_content, 1); $txt_content = substr($txt_content, 1);
} }
if (substr($txt_content, -1) == '"') { if (substr($txt_content, - 1) == '"') {
$txt_content = substr($txt_content, 0, -1); $txt_content = substr($txt_content, 0, - 1);
} }
} }
return $txt_content; return $txt_content;
} }
/** /**
* @param string $email * @param string $email
* @return string * @return string
*/ */
private static function escapeSoaAdminMail(string $email): string private static function escapeSoaAdminMail(string $email): string
{ {
$mail_parts = explode("@", $email); $mail_parts = explode("@", $email);
return str_replace(".", "\.", $mail_parts[0]) . "." . $mail_parts[1] . "."; return str_replace(".", "\.", $mail_parts[0]) . "." . $mail_parts[1] . ".";
} }
} }