mirror of
https://github.com/getnamingo/registry.git
synced 2025-07-25 11:58:19 +02:00
RDAP update
This commit is contained in:
parent
2b6164a0f1
commit
6df25ee4f7
3 changed files with 73 additions and 2 deletions
|
@ -33,6 +33,12 @@
|
||||||
# run escrow.php every day
|
# run escrow.php every day
|
||||||
5 0 * * * root /usr/bin/php8.2 /opt/registry/automation/escrow.php
|
5 0 * * * root /usr/bin/php8.2 /opt/registry/automation/escrow.php
|
||||||
|
|
||||||
|
# run rdap-urls.php every day
|
||||||
|
50 1 * * * root /usr/bin/php8.2 /opt/registry/automation/rdap-urls.php
|
||||||
|
|
||||||
|
# run file_cache.php every day
|
||||||
|
0 2 * * * root /usr/bin/php8.2 /var/www/cp/bin/file_cache.php
|
||||||
|
|
||||||
# run reporting.php every 1st day
|
# run reporting.php every 1st day
|
||||||
1 0 1 * * root /usr/bin/php8.2 /opt/registry/automation/reporting.php
|
1 0 1 * * root /usr/bin/php8.2 /opt/registry/automation/reporting.php
|
||||||
|
|
||||||
|
|
65
automation/rdap-urls.php
Normal file
65
automation/rdap-urls.php
Normal file
|
@ -0,0 +1,65 @@
|
||||||
|
<?php
|
||||||
|
$c = require_once 'config.php';
|
||||||
|
require_once 'helpers.php';
|
||||||
|
|
||||||
|
// Connect to the database
|
||||||
|
$dsn = "{$c['db_type']}:host={$c['db_host']};dbname={$c['db_database']};port={$c['db_port']}";
|
||||||
|
$logFilePath = '/var/log/namingo/rdap-urls.log';
|
||||||
|
$log = setupLogger($logFilePath, 'RDAP_URLS');
|
||||||
|
$log->info('job started.');
|
||||||
|
|
||||||
|
try {
|
||||||
|
$dbh = new PDO($dsn, $c['db_username'], $c['db_password']);
|
||||||
|
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||||
|
} catch (PDOException $e) {
|
||||||
|
$log->error('DB Connection failed: ' . $e->getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
// URL to the IANA file
|
||||||
|
$csv_url = 'https://www.iana.org/assignments/registrar-ids/registrar-ids-1.csv';
|
||||||
|
|
||||||
|
// Download IANA file
|
||||||
|
$ch = curl_init();
|
||||||
|
curl_setopt($ch, CURLOPT_URL, $csv_url);
|
||||||
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||||
|
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
|
||||||
|
$userAgent = 'Namingo Registry/0.5 (+https://namingo.org)';
|
||||||
|
curl_setopt($ch, CURLOPT_USERAGENT, $userAgent);
|
||||||
|
$csv_data = curl_exec($ch);
|
||||||
|
if (curl_errno($ch)) {
|
||||||
|
$error_msg = curl_error($ch);
|
||||||
|
}
|
||||||
|
curl_close($ch);
|
||||||
|
|
||||||
|
if ($csv_data === false) {
|
||||||
|
$log->error("Error downloading CSV file: " . $error_msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Parse CSV data
|
||||||
|
$rows = array_map("str_getcsv", explode("\n", $csv_data));
|
||||||
|
$header = array_shift($rows); // Remove header
|
||||||
|
|
||||||
|
foreach ($rows as $row) {
|
||||||
|
if (count($row) < 4 || empty($row[3])) {
|
||||||
|
// Skip rows with missing RDAP Base URL
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Prepare SQL statement
|
||||||
|
$stmt = $dbh->prepare("UPDATE registrar SET rdap_server = :rdap_server WHERE iana_id = :iana_id");
|
||||||
|
|
||||||
|
// Bind parameters
|
||||||
|
$stmt->bindParam(':rdap_server', $row[3], PDO::PARAM_STR);
|
||||||
|
$stmt->bindParam(':iana_id', $row[0], PDO::PARAM_INT);
|
||||||
|
|
||||||
|
// Execute and check for errors
|
||||||
|
try {
|
||||||
|
$stmt->execute();
|
||||||
|
} catch (\PDOException $e) {
|
||||||
|
$log->error("Error updating ID {$row[0]}: " . $e->getMessage());
|
||||||
|
} catch (Throwable $e) {
|
||||||
|
$log->error('Error: ' . $e->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$log->info('job finished successfully.');
|
|
@ -539,7 +539,7 @@ function handleDomainQuery($request, $response, $pdo, $domainName, $c, $log) {
|
||||||
'type' => 'application/rdap+json',
|
'type' => 'application/rdap+json',
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'href' => 'https://' . $registrarDetails['rdap_server'] . '/domain/' . $domain,
|
'href' => $registrarDetails['rdap_server'] . 'domain/' . $domain,
|
||||||
'rel' => 'related',
|
'rel' => 'related',
|
||||||
'type' => 'application/rdap+json',
|
'type' => 'application/rdap+json',
|
||||||
]
|
]
|
||||||
|
@ -1771,7 +1771,7 @@ function handleDomainSearchQuery($request, $response, $pdo, $searchPattern, $c,
|
||||||
'type' => 'application/rdap+json',
|
'type' => 'application/rdap+json',
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'href' => 'https://' . $registrarDetails['rdap_server'] . '/domain/' . $domain,
|
'href' => $registrarDetails['rdap_server'] . 'domain/' . $domain,
|
||||||
'rel' => 'related',
|
'rel' => 'related',
|
||||||
'type' => 'application/rdap+json',
|
'type' => 'application/rdap+json',
|
||||||
]
|
]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue