Merge pull request #102 from alstrasolutions/main

Fix WHOIS and RDAP to correctly extract the TLD for multi-segment TLDs
This commit is contained in:
Pinga 2024-07-23 23:37:54 +03:00 committed by GitHub
commit 1294c9faec
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 14 additions and 2 deletions

View file

@ -227,7 +227,13 @@ function handleDomainQuery($request, $response, $pdo, $domainName, $c, $log) {
// Extract TLD from the domain
$parts = explode('.', $domain);
$tld = "." . end($parts);
// Handle multi-segment TLDs (e.g., co.uk, ngo.us, etc.)
if (count($parts) > 2) {
$tld = "." . $parts[count($parts) - 2] . "." . $parts[count($parts) - 1];
} else {
$tld = "." . end($parts);
}
// Check if the TLD exists in the domain_tld table
$stmtTLD = $pdo->prepare("SELECT COUNT(*) FROM domain_tld WHERE tld = :tld");

View file

@ -111,7 +111,13 @@ $server->on('receive', function ($server, $fd, $reactorId, $data) use ($c, $pool
// Extract TLD from the domain and prepend a dot
$parts = explode('.', $domain);
$tld = "." . end($parts);
// Handle multi-segment TLDs (e.g., co.uk, ngo.us, etc.)
if (count($parts) > 2) {
$tld = "." . $parts[count($parts) - 2] . "." . $parts[count($parts) - 1];
} else {
$tld = "." . end($parts);
}
// Check if the TLD exists in the domain_tld table
$stmtTLD = $pdo->prepare("SELECT COUNT(*) FROM domain_tld WHERE tld = :tld");