mirror of
https://github.com/getnamingo/registry.git
synced 2025-07-06 02:53:19 +02:00
ICANN RST Fixes
This commit is contained in:
parent
b598925bc5
commit
193cac6d0e
3 changed files with 53 additions and 36 deletions
|
@ -180,20 +180,20 @@ try {
|
||||||
$domains = $stmt->fetchAll();
|
$domains = $stmt->fetchAll();
|
||||||
|
|
||||||
foreach ($domains as $domain) {
|
foreach ($domains as $domain) {
|
||||||
$xml->startElement('rdeDom:domain');
|
$xml->startElement('rdeDomain:domain');
|
||||||
$xml->writeElement('rdeDom:name', $domain['name']);
|
$xml->writeElement('rdeDomain:name', $domain['name']);
|
||||||
$xml->writeElement('rdeDom:roid', 'D' . $domain['id'] . '-' . $c['roid']);
|
$xml->writeElement('rdeDomain:roid', 'D' . $domain['id'] . '-' . $c['roid']);
|
||||||
$xml->writeElement('rdeDom:uName', $domain['name']);
|
$xml->writeElement('rdeDomain:uName', $domain['name']);
|
||||||
$xml->writeElement('rdeDom:idnTableId', 'Latn');
|
$xml->writeElement('rdeDomain:idnTableId', 'Latn');
|
||||||
|
|
||||||
// Fetch domain status
|
// Fetch domain status
|
||||||
$stmt = $dbh->prepare("SELECT * FROM domain_status WHERE domain_id = :domain_id;");
|
$stmt = $dbh->prepare("SELECT * FROM domain_status WHERE domain_id = :domain_id;");
|
||||||
$stmt->bindParam(':domain_id', $domain['id']);
|
$stmt->bindParam(':domain_id', $domain['id']);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
$status = $stmt->fetch();
|
$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
|
// Fetch domain contacts
|
||||||
$stmt = $dbh->prepare("SELECT * FROM domain_contact_map WHERE domain_id = :domain_id;");
|
$stmt = $dbh->prepare("SELECT * FROM domain_contact_map WHERE domain_id = :domain_id;");
|
||||||
|
@ -201,10 +201,10 @@ try {
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
$domain_contacts = $stmt->fetchAll();
|
$domain_contacts = $stmt->fetchAll();
|
||||||
foreach ($domain_contacts as $contact) {
|
foreach ($domain_contacts as $contact) {
|
||||||
$xml->startElement('rdeDom:contact');
|
$xml->startElement('rdeDomain:contact');
|
||||||
$xml->writeAttribute('type', $contact['type']);
|
$xml->writeAttribute('type', $contact['type']);
|
||||||
$xml->text($contact['contact_id']);
|
$xml->text($contact['contact_id']);
|
||||||
$xml->endElement(); // Closing rdeDom:contact
|
$xml->endElement(); // Closing rdeDomain:contact
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fetch domain hosts and incorporate into XML
|
// Fetch domain hosts and incorporate into XML
|
||||||
|
@ -212,20 +212,20 @@ try {
|
||||||
$stmt->bindParam(':domain_id', $domain['id']);
|
$stmt->bindParam(':domain_id', $domain['id']);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
$domain_hosts = $stmt->fetchAll();
|
$domain_hosts = $stmt->fetchAll();
|
||||||
$xml->startElement('rdeDom:ns');
|
$xml->startElement('rdeDomain:ns');
|
||||||
foreach ($domain_hosts as $host) {
|
foreach ($domain_hosts as $host) {
|
||||||
$xml->writeElement('domain:hostObj', $host['name']);
|
$xml->writeElement('domain:hostObj', $host['name']);
|
||||||
}
|
}
|
||||||
$xml->endElement(); // Closing rdeDom:ns
|
$xml->endElement(); // Closing rdeDomain:ns
|
||||||
|
|
||||||
$xml->writeElement('rdeDom:clID', $domain['clid']);
|
$xml->writeElement('rdeDomain:clID', $domain['clid']);
|
||||||
$xml->writeElement('rdeDom:crRr', $domain['crid']);
|
$xml->writeElement('rdeDomain:crRr', $domain['crid']);
|
||||||
$crDate = DateTime::createFromFormat('Y-m-d H:i:s.v', $domain['crdate']);
|
$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']);
|
$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
|
// Fetch and incorporate host details
|
||||||
|
@ -438,7 +438,7 @@ try {
|
||||||
$deposit = $xml->outputMemory();
|
$deposit = $xml->outputMemory();
|
||||||
|
|
||||||
// Define the base name without the extension
|
// 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
|
// XML, tar, and gzip filenames
|
||||||
$xmlFileName = $baseFileName . ".xml";
|
$xmlFileName = $baseFileName . ".xml";
|
||||||
|
@ -725,20 +725,20 @@ try {
|
||||||
$domains = $stmt->fetchAll();
|
$domains = $stmt->fetchAll();
|
||||||
|
|
||||||
foreach ($domains as $domain) {
|
foreach ($domains as $domain) {
|
||||||
$xml->startElement('rdeDom:domain');
|
$xml->startElement('rdeDomain:domain');
|
||||||
$xml->writeElement('rdeDom:name', $domain['name']);
|
$xml->writeElement('rdeDomain:name', $domain['name']);
|
||||||
$xml->writeElement('rdeDom:roid', 'D' . $domain['id'] . '-' . $c['roid']);
|
$xml->writeElement('rdeDomain:roid', 'D' . $domain['id'] . '-' . $c['roid']);
|
||||||
$xml->writeElement('rdeDom:uName', $domain['name']);
|
$xml->writeElement('rdeDomain:uName', $domain['name']);
|
||||||
$xml->writeElement('rdeDom:idnTableId', 'Latn');
|
$xml->writeElement('rdeDomain:idnTableId', 'Latn');
|
||||||
|
|
||||||
// Fetch domain status
|
// Fetch domain status
|
||||||
$stmt = $dbh->prepare("SELECT * FROM domain_status WHERE domain_id = :domain_id;");
|
$stmt = $dbh->prepare("SELECT * FROM domain_status WHERE domain_id = :domain_id;");
|
||||||
$stmt->bindParam(':domain_id', $domain['id']);
|
$stmt->bindParam(':domain_id', $domain['id']);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
$status = $stmt->fetch();
|
$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
|
// Fetch domain contacts
|
||||||
$stmt = $dbh->prepare("SELECT * FROM domain_contact_map WHERE domain_id = :domain_id;");
|
$stmt = $dbh->prepare("SELECT * FROM domain_contact_map WHERE domain_id = :domain_id;");
|
||||||
|
@ -746,10 +746,10 @@ try {
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
$domain_contacts = $stmt->fetchAll();
|
$domain_contacts = $stmt->fetchAll();
|
||||||
foreach ($domain_contacts as $contact) {
|
foreach ($domain_contacts as $contact) {
|
||||||
$xml->startElement('rdeDom:contact');
|
$xml->startElement('rdeDomain:contact');
|
||||||
$xml->writeAttribute('type', $contact['type']);
|
$xml->writeAttribute('type', $contact['type']);
|
||||||
$xml->text($contact['contact_id']);
|
$xml->text($contact['contact_id']);
|
||||||
$xml->endElement(); // Closing rdeDom:contact
|
$xml->endElement(); // Closing rdeDomain:contact
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fetch domain hosts and incorporate into XML
|
// Fetch domain hosts and incorporate into XML
|
||||||
|
@ -757,20 +757,20 @@ try {
|
||||||
$stmt->bindParam(':domain_id', $domain['id']);
|
$stmt->bindParam(':domain_id', $domain['id']);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
$domain_hosts = $stmt->fetchAll();
|
$domain_hosts = $stmt->fetchAll();
|
||||||
$xml->startElement('rdeDom:ns');
|
$xml->startElement('rdeDomain:ns');
|
||||||
foreach ($domain_hosts as $host) {
|
foreach ($domain_hosts as $host) {
|
||||||
$xml->writeElement('domain:hostObj', $host['name']);
|
$xml->writeElement('domain:hostObj', $host['name']);
|
||||||
}
|
}
|
||||||
$xml->endElement(); // Closing rdeDom:ns
|
$xml->endElement(); // Closing rdeDomain:ns
|
||||||
|
|
||||||
$xml->writeElement('rdeDom:clID', $domain['clid']);
|
$xml->writeElement('rdeDomain:clID', $domain['clid']);
|
||||||
$xml->writeElement('rdeDom:crRr', $domain['crid']);
|
$xml->writeElement('rdeDomain:crRr', $domain['crid']);
|
||||||
$crDate = DateTime::createFromFormat('Y-m-d H:i:s.v', $domain['crdate']);
|
$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']);
|
$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
|
// Fetch and incorporate registrar details
|
||||||
|
|
|
@ -1033,3 +1033,11 @@ function validateHostName(string $hostName): bool
|
||||||
$asciiHostName
|
$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);
|
||||||
|
}
|
|
@ -91,10 +91,19 @@ $server->handle(function (Connection $conn) use ($table, $pool, $c, $log, $permi
|
||||||
|
|
||||||
// Check if the IP is in the permitted list
|
// Check if the IP is in the permitted list
|
||||||
if (!$permittedIPsTable->exist($clientIP)) {
|
if (!$permittedIPsTable->exist($clientIP)) {
|
||||||
|
$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.');
|
$log->warning('Access denied. The IP address ' . $clientIP . ' is not authorized for this service.');
|
||||||
$conn->close();
|
$conn->close();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (($c['rately'] == true) && ($rateLimiter->isRateLimited('epp', $clientIP, $c['limit'], $c['period']))) {
|
if (($c['rately'] == true) && ($rateLimiter->isRateLimited('epp', $clientIP, $c['limit'], $c['period']))) {
|
||||||
$log->error('rate limit exceeded for ' . $clientIP);
|
$log->error('rate limit exceeded for ' . $clientIP);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue