mirror of
https://github.com/getnamingo/registry.git
synced 2025-07-03 09:33:25 +02:00
Added handle formatting for objects
And fixed RDAP URLs
This commit is contained in:
parent
964cd8f370
commit
4d3ee365a1
6 changed files with 51 additions and 47 deletions
|
@ -69,7 +69,7 @@ foreach ($tlds as $tld) {
|
|||
foreach ($domains as $domain) {
|
||||
$xml->startElement('rdeDom:domain');
|
||||
$xml->writeElement('rdeDom:name', $domain['name']);
|
||||
$xml->writeElement('rdeDom:roid', $domain['id']);
|
||||
$xml->writeElement('rdeDom:roid', 'D' . $domain['id']);
|
||||
$xml->writeElement('rdeDom:uName', $domain['name']);
|
||||
$xml->writeElement('rdeDom:idnTableId', 'Latn');
|
||||
|
||||
|
@ -168,7 +168,7 @@ foreach ($tlds as $tld) {
|
|||
foreach ($hosts as $host) {
|
||||
$xml->startElement('rdeHost:host');
|
||||
$xml->writeElement('rdeHost:name', $host['name']);
|
||||
$xml->writeElement('rdeHost:roid', $host['id']);
|
||||
$xml->writeElement('rdeHost:roid', 'H' . $host['id']);
|
||||
|
||||
$xml->startElement('rdeHost:status');
|
||||
$xml->writeAttribute('s', 'ok');
|
||||
|
@ -190,7 +190,7 @@ foreach ($tlds as $tld) {
|
|||
foreach ($contacts as $contact) {
|
||||
$xml->startElement('rdeContact:contact');
|
||||
$xml->writeElement('rdeContact:id', $contact['identifier']);
|
||||
$xml->writeElement('rdeContact:roid', $contact['id']);
|
||||
$xml->writeElement('rdeContact:roid', 'C' . $contact['id']);
|
||||
$xml->startElement('rdeContact:status');
|
||||
$xml->writeAttribute('s', 'ok');
|
||||
$xml->text('ok');
|
||||
|
|
|
@ -64,7 +64,7 @@ function processContactInfo($conn, $db, $xml, $trans) {
|
|||
'resultCode' => 1000,
|
||||
'msg' => 'Command completed successfully',
|
||||
'id' => $contact['id'],
|
||||
'roid' => 'C_'.$contact['identifier'],
|
||||
'roid' => 'C' . $contact['identifier'],
|
||||
'status' => $statusArray,
|
||||
'postal' => $postalArray,
|
||||
'voice' => $contact['voice'],
|
||||
|
@ -148,7 +148,7 @@ function processHostInfo($conn, $db, $xml, $trans) {
|
|||
'resultCode' => 1000,
|
||||
'msg' => 'Command completed successfully',
|
||||
'name' => $host['name'],
|
||||
'roid' => 'H_'.$host['id'],
|
||||
'roid' => 'H' . $host['id'],
|
||||
'status' => $statusArray,
|
||||
'addr' => $addrArray,
|
||||
'clID' => getRegistrarClid($db, $host['clid']),
|
||||
|
@ -283,7 +283,7 @@ function processDomainInfo($conn, $db, $xml, $trans) {
|
|||
'resultCode' => 1000,
|
||||
'msg' => 'Command completed successfully',
|
||||
'name' => $domain['name'],
|
||||
'roid' => 'D_'.$domain['id'],
|
||||
'roid' => 'D' . $domain['id'],
|
||||
'status' => $statusArray,
|
||||
'registrant' => $domain['registrant'],
|
||||
'contact' => $transformedContacts,
|
||||
|
|
|
@ -6,5 +6,8 @@ return [
|
|||
'db_port' => 3306,
|
||||
'db_database' => 'your_database_name',
|
||||
'db_username' => 'your_username',
|
||||
'db_password' => 'your_password'
|
||||
'db_password' => 'your_password',
|
||||
'roid' => 'XX',
|
||||
'registry_url' => 'https://example.com/rdap-terms',
|
||||
'rdap_url' => 'https://rdap.example.com',
|
||||
];
|
|
@ -4,10 +4,10 @@ if (!extension_loaded('swoole')) {
|
|||
die('Swoole extension must be installed');
|
||||
}
|
||||
|
||||
function mapContactToVCard($contactDetails, $role) {
|
||||
function mapContactToVCard($contactDetails, $role, $c) {
|
||||
return [
|
||||
'objectClassName' => 'entity',
|
||||
'handle' => [$contactDetails['identifier']],
|
||||
'handle' => ['C' . $contactDetails['identifier'] . '-' . $c['roid']],
|
||||
'roles' => [$role],
|
||||
'remarks' => [
|
||||
[
|
||||
|
@ -96,26 +96,26 @@ $http->on('request', function ($request, $response) use ($c, $pdo) {
|
|||
// Handle domain query
|
||||
if (preg_match('#^/domain/([^/?]+)#', $requestPath, $matches)) {
|
||||
$domainName = $matches[1];
|
||||
handleDomainQuery($request, $response, $pdo, $domainName);
|
||||
handleDomainQuery($request, $response, $pdo, $domainName, $c);
|
||||
}
|
||||
// Handle entity (contacts) query
|
||||
elseif (preg_match('#^/entity/([^/?]+)#', $requestPath, $matches)) {
|
||||
$entityHandle = $matches[1];
|
||||
handleEntityQuery($request, $response, $pdo, $entityHandle);
|
||||
handleEntityQuery($request, $response, $pdo, $entityHandle, $c);
|
||||
}
|
||||
// Handle nameserver query
|
||||
elseif (preg_match('#^/nameserver/([^/?]+)#', $requestPath, $matches)) {
|
||||
$nameserverHandle = $matches[1];
|
||||
handleNameserverQuery($request, $response, $pdo, $nameserverHandle);
|
||||
handleNameserverQuery($request, $response, $pdo, $nameserverHandle, $c);
|
||||
}
|
||||
// Handle help query
|
||||
elseif ($requestPath === '/help') {
|
||||
handleHelpQuery($request, $response, $pdo);
|
||||
handleHelpQuery($request, $response, $pdo, $c);
|
||||
}
|
||||
// Handle search query (e.g., search for domains by pattern)
|
||||
elseif (preg_match('#^/domains\?name=([^/?]+)#', $requestPath, $matches)) {
|
||||
$searchPattern = $matches[1];
|
||||
handleSearchQuery($request, $response, $pdo, $searchPattern);
|
||||
handleSearchQuery($request, $response, $pdo, $searchPattern, $c);
|
||||
}
|
||||
else {
|
||||
$response->header('Content-Type', 'application/json');
|
||||
|
@ -130,7 +130,7 @@ $http->on('request', function ($request, $response) use ($c, $pdo) {
|
|||
// Start the server
|
||||
$http->start();
|
||||
|
||||
function handleDomainQuery($request, $response, $pdo, $domainName) {
|
||||
function handleDomainQuery($request, $response, $pdo, $domainName, $c) {
|
||||
// Extract and validate the domain name from the request
|
||||
$domain = trim($domainName);
|
||||
|
||||
|
@ -354,7 +354,7 @@ function handleDomainQuery($request, $response, $pdo, $domainName) {
|
|||
"handle" => $registrarDetails['iana_id'],
|
||||
"links" => [
|
||||
[
|
||||
"href" => "https://rdap.example.com/entity/" . $registrarDetails['iana_id'],
|
||||
"href" => $c['rdap_url'] . "/entity/" . $registrarDetails['iana_id'],
|
||||
"rel" => "self",
|
||||
"type" => "application/rdap+json"
|
||||
]
|
||||
|
@ -383,29 +383,29 @@ function handleDomainQuery($request, $response, $pdo, $domainName) {
|
|||
],
|
||||
],
|
||||
[
|
||||
mapContactToVCard($registrantDetails, 'registrant')
|
||||
mapContactToVCard($registrantDetails, 'registrant', $c)
|
||||
],
|
||||
array_map(function ($contact) {
|
||||
return mapContactToVCard($contact, 'admin');
|
||||
return mapContactToVCard($contact, 'admin', $c);
|
||||
}, $adminDetails),
|
||||
array_map(function ($contact) {
|
||||
return mapContactToVCard($contact, 'tech');
|
||||
return mapContactToVCard($contact, 'tech', $c);
|
||||
}, $techDetails),
|
||||
array_map(function ($contact) {
|
||||
return mapContactToVCard($contact, 'billing');
|
||||
return mapContactToVCard($contact, 'billing', $c);
|
||||
}, $billingDetails)
|
||||
),
|
||||
'events' => $events,
|
||||
'handle' => $domainDetails['id'] . '',
|
||||
'handle' => 'D' . $domainDetails['id'] . '-' . $c['roid'] . '',
|
||||
'ldhName' => $domain,
|
||||
'links' => [
|
||||
[
|
||||
'href' => 'https://rdap.example.com/domain/' . $domain,
|
||||
'href' => $c['rdap_url'] . '/domain/' . $domain,
|
||||
'rel' => 'self',
|
||||
'type' => 'application/rdap+json',
|
||||
],
|
||||
[
|
||||
'href' => 'https://rdap.registrar.com/domain/' . $domain,
|
||||
'href' => 'https://' . $registrarDetails['rdap_server'] . '/domain/' . $domain,
|
||||
'rel' => 'related',
|
||||
'type' => 'application/rdap+json',
|
||||
]
|
||||
|
@ -413,11 +413,11 @@ function handleDomainQuery($request, $response, $pdo, $domainName) {
|
|||
'nameservers' => array_map(function ($nameserverDetails) {
|
||||
return [
|
||||
'objectClassName' => 'nameserver',
|
||||
'handle' => $nameserverDetails['host_id'] . '',
|
||||
'handle' => 'H' . $nameserverDetails['host_id'] . '-' . $c['roid'] . '',
|
||||
'ldhName' => $nameserverDetails['name'],
|
||||
'links' => [
|
||||
[
|
||||
'href' => 'https://rdap.example.com/nameserver/' . $nameserverDetails['name'],
|
||||
'href' => $c['rdap_url'] . '/nameserver/' . $nameserverDetails['name'],
|
||||
'rel' => 'self',
|
||||
'type' => 'application/rdap+json',
|
||||
],
|
||||
|
@ -450,12 +450,12 @@ function handleDomainQuery($request, $response, $pdo, $domainName) {
|
|||
],
|
||||
"links" => [
|
||||
[
|
||||
"href" => "https://rdap.example.com/help",
|
||||
"href" => $c['rdap_url'] . "/help",
|
||||
"rel" => "self",
|
||||
"type" => "application/rdap+json"
|
||||
],
|
||||
[
|
||||
"href" => "https://example.com/rdap-terms",
|
||||
"href" => $c['registry_url'],
|
||||
"rel" => "alternate",
|
||||
"type" => "text/html"
|
||||
],
|
||||
|
@ -508,7 +508,7 @@ function handleDomainQuery($request, $response, $pdo, $domainName) {
|
|||
}
|
||||
}
|
||||
|
||||
function handleEntityQuery($request, $response, $pdo, $entityHandle) {
|
||||
function handleEntityQuery($request, $response, $pdo, $entityHandle, $c) {
|
||||
// Extract and validate the entity handle from the request
|
||||
$entity = trim($entityHandle);
|
||||
|
||||
|
@ -588,7 +588,7 @@ function handleEntityQuery($request, $response, $pdo, $entityHandle) {
|
|||
'events' => $events,
|
||||
'links' => [
|
||||
[
|
||||
'href' => 'https://rdap.example.com/entity/' . $registrarDetails['iana_id'],
|
||||
'href' => $c['rdap_url'] . '/entity/' . $registrarDetails['iana_id'],
|
||||
'rel' => 'self',
|
||||
'type' => 'application/rdap+json',
|
||||
]
|
||||
|
@ -630,12 +630,12 @@ function handleEntityQuery($request, $response, $pdo, $entityHandle) {
|
|||
],
|
||||
"links" => [
|
||||
[
|
||||
"href" => "https://rdap.example.com/help",
|
||||
"href" => $c['rdap_url'] . "/help",
|
||||
"rel" => "self",
|
||||
"type" => "application/rdap+json"
|
||||
],
|
||||
[
|
||||
"href" => "https://example.com/rdap-terms",
|
||||
"href" => $c['registry_url'],
|
||||
"rel" => "alternate",
|
||||
"type" => "text/html"
|
||||
],
|
||||
|
@ -688,7 +688,7 @@ function handleEntityQuery($request, $response, $pdo, $entityHandle) {
|
|||
}
|
||||
}
|
||||
|
||||
function handleNameserverQuery($request, $response, $pdo, $nameserverHandle) {
|
||||
function handleNameserverQuery($request, $response, $pdo, $nameserverHandle, $c) {
|
||||
// Extract and validate the nameserver handle from the request
|
||||
$ns = trim($nameserverHandle);
|
||||
|
||||
|
@ -835,7 +835,7 @@ function handleNameserverQuery($request, $response, $pdo, $nameserverHandle) {
|
|||
"handle" => $registrarDetails['iana_id'],
|
||||
"links" => [
|
||||
[
|
||||
"href" => "https://rdap.example.com/entity/" . $registrarDetails['iana_id'],
|
||||
"href" => $c['rdap_url'] . "/entity/" . $registrarDetails['iana_id'],
|
||||
"rel" => "self",
|
||||
"type" => "application/rdap+json"
|
||||
]
|
||||
|
@ -864,13 +864,13 @@ function handleNameserverQuery($request, $response, $pdo, $nameserverHandle) {
|
|||
],
|
||||
],
|
||||
),
|
||||
'handle' => $hostDetails['id'] . '',
|
||||
'handle' => 'H' . $hostDetails['id'] . '-' . $c['roid'] . '',
|
||||
'ipAddresses' => $ipAddresses,
|
||||
'events' => $events,
|
||||
'ldhName' => $hostDetails['name'],
|
||||
'links' => [
|
||||
[
|
||||
'href' => 'https://rdap.example.com/nameserver/' . $hostDetails['name'],
|
||||
'href' => $c['rdap_url'] . '/nameserver/' . $hostDetails['name'],
|
||||
'rel' => 'self',
|
||||
'type' => 'application/rdap+json',
|
||||
]
|
||||
|
@ -888,12 +888,12 @@ function handleNameserverQuery($request, $response, $pdo, $nameserverHandle) {
|
|||
],
|
||||
"links" => [
|
||||
[
|
||||
"href" => "https://rdap.example.com/help",
|
||||
"href" => $c['rdap_url'] . "/help",
|
||||
"rel" => "self",
|
||||
"type" => "application/rdap+json"
|
||||
],
|
||||
[
|
||||
"href" => "https://example.com/rdap-terms",
|
||||
"href" => $c['registry_url'],
|
||||
"rel" => "alternate",
|
||||
"type" => "text/html"
|
||||
],
|
||||
|
@ -946,7 +946,7 @@ function handleNameserverQuery($request, $response, $pdo, $nameserverHandle) {
|
|||
}
|
||||
}
|
||||
|
||||
function handleHelpQuery($request, $response, $pdo) {
|
||||
function handleHelpQuery($request, $response, $pdo, $c) {
|
||||
// Set the RDAP conformance levels
|
||||
$rdapConformance = [
|
||||
"rdap_level_0",
|
||||
|
@ -971,7 +971,7 @@ function handleHelpQuery($request, $response, $pdo) {
|
|||
],
|
||||
'links' => [
|
||||
[
|
||||
'href' => 'https://rdap.example.com/help',
|
||||
'href' => $c['rdap_url'] . '/help',
|
||||
'rel' => 'self',
|
||||
'type' => 'application/rdap+json',
|
||||
],
|
||||
|
@ -996,12 +996,12 @@ function handleHelpQuery($request, $response, $pdo) {
|
|||
],
|
||||
"links" => [
|
||||
[
|
||||
"href" => "https://rdap.example.com/help",
|
||||
"href" => $c['rdap_url'] . "/help",
|
||||
"rel" => "self",
|
||||
"type" => "application/rdap+json"
|
||||
],
|
||||
[
|
||||
"href" => "https://example.com/rdap-terms",
|
||||
"href" => $c['registry_url'],
|
||||
"rel" => "alternate",
|
||||
"type" => "text/html"
|
||||
],
|
||||
|
|
|
@ -7,5 +7,6 @@ return [
|
|||
'db_database' => 'your_database_name',
|
||||
'db_username' => 'your_username',
|
||||
'db_password' => 'your_password',
|
||||
'privacy' => false
|
||||
'privacy' => false,
|
||||
'roid' => 'XX',
|
||||
];
|
|
@ -358,7 +358,7 @@ $server->on('receive', function ($server, $fd, $reactorId, $data) use ($c, $pdo)
|
|||
$clidF = $stmt3->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
$res = "Domain Name: ".strtoupper($f['name'])
|
||||
."\nRegistry Domain ID: ".$f['id']
|
||||
."\nRegistry Domain ID: D".$f['id']."-".$c['roid']
|
||||
."\nRegistrar WHOIS Server: ".$clidF['whois_server']
|
||||
."\nRegistrar URL: ".$clidF['url']
|
||||
."\nUpdated Date: ".$f['update']
|
||||
|
@ -400,7 +400,7 @@ $server->on('receive', function ($server, $fd, $reactorId, $data) use ($c, $pdo)
|
|||
."\nRegistrant Fax: REDACTED FOR PRIVACY"
|
||||
."\nRegistrant Email: Kindly refer to the RDDS server associated with the identified registrar in this output to obtain contact details for the Registrant, Admin, or Tech associated with the queried domain name.";
|
||||
} else {
|
||||
$res .= "\nRegistry Registrant ID: ".$f2['identifier']
|
||||
$res .= "\nRegistry Registrant ID: C".$f2['identifier']."-".$c['roid']
|
||||
."\nRegistrant Name: ".$f2['name']
|
||||
."\nRegistrant Organization: ".$f2['org']
|
||||
."\nRegistrant Street: ".$f2['street1']
|
||||
|
@ -437,7 +437,7 @@ $server->on('receive', function ($server, $fd, $reactorId, $data) use ($c, $pdo)
|
|||
."\nAdmin Fax: REDACTED FOR PRIVACY"
|
||||
."\nAdmin Email: Kindly refer to the RDDS server associated with the identified registrar in this output to obtain contact details for the Registrant, Admin, or Tech associated with the queried domain name.";
|
||||
} else {
|
||||
$res .= "\nRegistry Admin ID: ".$f2['identifier']
|
||||
$res .= "\nRegistry Admin ID: C".$f2['identifier']."-".$c['roid']
|
||||
."\nAdmin Name: ".$f2['name']
|
||||
."\nAdmin Organization: ".$f2['org']
|
||||
."\nAdmin Street: ".$f2['street1']
|
||||
|
@ -474,7 +474,7 @@ $server->on('receive', function ($server, $fd, $reactorId, $data) use ($c, $pdo)
|
|||
."\nBilling Fax: REDACTED FOR PRIVACY"
|
||||
."\nBilling Email: Kindly refer to the RDDS server associated with the identified registrar in this output to obtain contact details for the Registrant, Admin, or Tech associated with the queried domain name.";
|
||||
} else {
|
||||
$res .= "\nRegistry Billing ID: ".$f2['identifier']
|
||||
$res .= "\nRegistry Billing ID: C".$f2['identifier']."-".$c['roid']
|
||||
."\nBilling Name: ".$f2['name']
|
||||
."\nBilling Organization: ".$f2['org']
|
||||
."\nBilling Street: ".$f2['street1']
|
||||
|
@ -511,7 +511,7 @@ $server->on('receive', function ($server, $fd, $reactorId, $data) use ($c, $pdo)
|
|||
."\nTech Fax: REDACTED FOR PRIVACY"
|
||||
."\nTech Email: Kindly refer to the RDDS server associated with the identified registrar in this output to obtain contact details for the Registrant, Admin, or Tech associated with the queried domain name.";
|
||||
} else {
|
||||
$res .= "\nRegistry Tech ID: ".$f2['identifier']
|
||||
$res .= "\nRegistry Tech ID: C".$f2['identifier']."-".$c['roid']
|
||||
."\nTech Name: ".$f2['name']
|
||||
."\nTech Organization: ".$f2['org']
|
||||
."\nTech Street: ".$f2['street1']
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue