f7cloud_client/apps/mail/lib/Dns/Resolver.php
root 8b6a0139db f7cloud_client
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-17 22:59:26 +00:00

32 lines
682 B
PHP

<?php
declare(strict_types=1);
/**
* SPDX-FileCopyrightText: 2024 F7cloud GmbH and F7cloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCA\Mail\Dns;
use Pdp\Domain;
use Pdp\Rules;
use function dns_get_record;
class Resolver {
public function resolve(string $hostname, int $type): array|false {
return dns_get_record($hostname, $type);
}
public function isSuffix(string $hostname): bool {
$publicSuffixList = Rules::fromPath(__DIR__ . '/../../resources/public_suffix_list.dat');
$domain = Domain::fromIDNA2008($hostname);
$result = $publicSuffixList->resolve($domain);
return $result->secondLevelDomain()->toString() === '';
}
}