ICANN RST Fixes

This commit is contained in:
Pinga 2025-04-28 14:20:34 +03:00
parent b598925bc5
commit 193cac6d0e
3 changed files with 53 additions and 36 deletions

View file

@ -180,20 +180,20 @@ try {
$domains = $stmt->fetchAll();
foreach ($domains as $domain) {
$xml->startElement('rdeDom:domain');
$xml->writeElement('rdeDom:name', $domain['name']);
$xml->writeElement('rdeDom:roid', 'D' . $domain['id'] . '-' . $c['roid']);
$xml->writeElement('rdeDom:uName', $domain['name']);
$xml->writeElement('rdeDom:idnTableId', 'Latn');
$xml->startElement('rdeDomain:domain');
$xml->writeElement('rdeDomain:name', $domain['name']);
$xml->writeElement('rdeDomain:roid', 'D' . $domain['id'] . '-' . $c['roid']);
$xml->writeElement('rdeDomain:uName', $domain['name']);
$xml->writeElement('rdeDomain:idnTableId', 'Latn');
// Fetch domain status
$stmt = $dbh->prepare("SELECT * FROM domain_status WHERE domain_id = :domain_id;");
$stmt->bindParam(':domain_id', $domain['id']);
$stmt->execute();
$status = $stmt->fetch();
$xml->writeElement('rdeDom:status', $status['status'] ?? 'okk');
$xml->writeElement('rdeDomain:status', $status['status'] ?? 'okk');
$xml->writeElement('rdeDom:registrant', $domain['registrant']);
$xml->writeElement('rdeDomain:registrant', $domain['registrant']);
// Fetch domain contacts
$stmt = $dbh->prepare("SELECT * FROM domain_contact_map WHERE domain_id = :domain_id;");
@ -201,10 +201,10 @@ try {
$stmt->execute();
$domain_contacts = $stmt->fetchAll();
foreach ($domain_contacts as $contact) {
$xml->startElement('rdeDom:contact');
$xml->startElement('rdeDomain:contact');
$xml->writeAttribute('type', $contact['type']);
$xml->text($contact['contact_id']);
$xml->endElement(); // Closing rdeDom:contact
$xml->endElement(); // Closing rdeDomain:contact
}
// Fetch domain hosts and incorporate into XML
@ -212,20 +212,20 @@ try {
$stmt->bindParam(':domain_id', $domain['id']);
$stmt->execute();
$domain_hosts = $stmt->fetchAll();
$xml->startElement('rdeDom:ns');
$xml->startElement('rdeDomain:ns');
foreach ($domain_hosts as $host) {
$xml->writeElement('domain:hostObj', $host['name']);
}
$xml->endElement(); // Closing rdeDom:ns
$xml->endElement(); // Closing rdeDomain:ns
$xml->writeElement('rdeDom:clID', $domain['clid']);
$xml->writeElement('rdeDom:crRr', $domain['crid']);
$xml->writeElement('rdeDomain:clID', $domain['clid']);
$xml->writeElement('rdeDomain:crRr', $domain['crid']);
$crDate = DateTime::createFromFormat('Y-m-d H:i:s.v', $domain['crdate']);
$xml->writeElement('rdeDom:crDate', $crDate->format("Y-m-d\\TH:i:s.v\\Z"));
$xml->writeElement('rdeDomain:crDate', $crDate->format("Y-m-d\\TH:i:s.v\\Z"));
$exDate = DateTime::createFromFormat('Y-m-d H:i:s.v', $domain['exdate']);
$xml->writeElement('rdeDom:exDate', $exDate->format("Y-m-d\\TH:i:s.v\\Z"));
$xml->writeElement('rdeDomain:exDate', $exDate->format("Y-m-d\\TH:i:s.v\\Z"));
$xml->endElement(); // Closing rdeDom:domain
$xml->endElement(); // Closing rdeDomain:domain
}
// Fetch and incorporate host details
@ -438,7 +438,7 @@ try {
$deposit = $xml->outputMemory();
// Define the base name without the extension
$baseFileName = "{$tldname}_".date('Ymd')."_full_S1_R{$finalDepositId}";
$baseFileName = "{$tldname}_" . date('Y-m-d') . "_full_S1_R{$finalDepositId}";
// XML, tar, and gzip filenames
$xmlFileName = $baseFileName . ".xml";
@ -725,20 +725,20 @@ try {
$domains = $stmt->fetchAll();
foreach ($domains as $domain) {
$xml->startElement('rdeDom:domain');
$xml->writeElement('rdeDom:name', $domain['name']);
$xml->writeElement('rdeDom:roid', 'D' . $domain['id'] . '-' . $c['roid']);
$xml->writeElement('rdeDom:uName', $domain['name']);
$xml->writeElement('rdeDom:idnTableId', 'Latn');
$xml->startElement('rdeDomain:domain');
$xml->writeElement('rdeDomain:name', $domain['name']);
$xml->writeElement('rdeDomain:roid', 'D' . $domain['id'] . '-' . $c['roid']);
$xml->writeElement('rdeDomain:uName', $domain['name']);
$xml->writeElement('rdeDomain:idnTableId', 'Latn');
// Fetch domain status
$stmt = $dbh->prepare("SELECT * FROM domain_status WHERE domain_id = :domain_id;");
$stmt->bindParam(':domain_id', $domain['id']);
$stmt->execute();
$status = $stmt->fetch();
$xml->writeElement('rdeDom:status', $status['status'] ?? 'okk');
$xml->writeElement('rdeDomain:status', $status['status'] ?? 'okk');
$xml->writeElement('rdeDom:registrant', $domain['registrant']);
$xml->writeElement('rdeDomain:registrant', $domain['registrant']);
// Fetch domain contacts
$stmt = $dbh->prepare("SELECT * FROM domain_contact_map WHERE domain_id = :domain_id;");
@ -746,10 +746,10 @@ try {
$stmt->execute();
$domain_contacts = $stmt->fetchAll();
foreach ($domain_contacts as $contact) {
$xml->startElement('rdeDom:contact');
$xml->startElement('rdeDomain:contact');
$xml->writeAttribute('type', $contact['type']);
$xml->text($contact['contact_id']);
$xml->endElement(); // Closing rdeDom:contact
$xml->endElement(); // Closing rdeDomain:contact
}
// Fetch domain hosts and incorporate into XML
@ -757,20 +757,20 @@ try {
$stmt->bindParam(':domain_id', $domain['id']);
$stmt->execute();
$domain_hosts = $stmt->fetchAll();
$xml->startElement('rdeDom:ns');
$xml->startElement('rdeDomain:ns');
foreach ($domain_hosts as $host) {
$xml->writeElement('domain:hostObj', $host['name']);
}
$xml->endElement(); // Closing rdeDom:ns
$xml->endElement(); // Closing rdeDomain:ns
$xml->writeElement('rdeDom:clID', $domain['clid']);
$xml->writeElement('rdeDom:crRr', $domain['crid']);
$xml->writeElement('rdeDomain:clID', $domain['clid']);
$xml->writeElement('rdeDomain:crRr', $domain['crid']);
$crDate = DateTime::createFromFormat('Y-m-d H:i:s.v', $domain['crdate']);
$xml->writeElement('rdeDom:crDate', $crDate->format("Y-m-d\\TH:i:s.v\\Z"));
$xml->writeElement('rdeDomain:crDate', $crDate->format("Y-m-d\\TH:i:s.v\\Z"));
$exDate = DateTime::createFromFormat('Y-m-d H:i:s.v', $domain['exdate']);
$xml->writeElement('rdeDom:exDate', $exDate->format("Y-m-d\\TH:i:s.v\\Z"));
$xml->writeElement('rdeDomain:exDate', $exDate->format("Y-m-d\\TH:i:s.v\\Z"));
$xml->endElement(); // Closing rdeDom:domain
$xml->endElement(); // Closing rdeDomain:domain
}
// Fetch and incorporate registrar details

View file

@ -1032,4 +1032,12 @@ function validateHostName(string $hostName): bool
'/^([a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/',
$asciiHostName
);
}
function ipMatches($ip, $cidr) {
list($subnet, $mask) = explode('/', $cidr);
$ipLong = ip2long($ip);
$subnetLong = ip2long($subnet);
$maskLong = -1 << (32 - (int)$mask);
return ($ipLong & $maskLong) === ($subnetLong & $maskLong);
}

View file

@ -91,9 +91,18 @@ $server->handle(function (Connection $conn) use ($table, $pool, $c, $log, $permi
// Check if the IP is in the permitted list
if (!$permittedIPsTable->exist($clientIP)) {
$log->warning('Access denied. The IP address ' . $clientIP . ' is not authorized for this service.');
$conn->close();
return;
$allowed = false;
foreach ($permittedIPsTable as $row) {
if (strpos($row['addr'], '/') !== false && ipMatches($clientIP, $row['addr'])) {
$allowed = true;
break;
}
}
if (!$allowed) {
$log->warning('Access denied. The IP address ' . $clientIP . ' is not authorized for this service.');
$conn->close();
return;
}
}
if (($c['rately'] == true) && ($rateLimiter->isRateLimited('epp', $clientIP, $c['limit'], $c['period']))) {