mirror of
https://github.com/getnamingo/registry.git
synced 2025-06-26 14:14:41 +02:00
Updated epp domain info; added rgp and secdns extensions
This commit is contained in:
parent
4ec93e053e
commit
1c2c147601
2 changed files with 128 additions and 13 deletions
|
@ -708,13 +708,13 @@ class EppWriter {
|
|||
}
|
||||
$writer->endElement(); // End of 'domain:ns'
|
||||
}
|
||||
if (isset($resp['return_host'])) {
|
||||
if (isset($resp['return_host'])) {
|
||||
if ($resp['return_host']) {
|
||||
foreach ($resp['host'] as $h) {
|
||||
$writer->writeElement('domain:host', $h);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$writer->writeElement('domain:clID', $resp['clID']);
|
||||
if (isset($resp['crID'])) {
|
||||
$writer->writeElement('domain:crID', $resp['crID']);
|
||||
|
@ -747,11 +747,12 @@ class EppWriter {
|
|||
$writer->endElement(); // End of 'domain:infData'
|
||||
$writer->endElement(); // End of 'resData'
|
||||
|
||||
// Handling the extension part
|
||||
// Check if the 'rgpstatus' key is set in $resp
|
||||
if (isset($resp['rgpstatus'])) {
|
||||
// Handling the extension part
|
||||
// Begin the extension part if any of the extensions are present
|
||||
if (isset($resp['rgpstatus']) || isset($resp['secDNS'])) {
|
||||
$writer->startElement('extension');
|
||||
|
||||
// Handle RGP status
|
||||
if (isset($resp['rgpstatus'])) {
|
||||
$writer->startElement('rgp:infData');
|
||||
$writer->writeAttribute('xmlns:rgp', 'urn:ietf:params:xml:ns:rgp-1.0');
|
||||
$writer->writeAttribute('xsi:schemaLocation', 'urn:ietf:params:xml:ns:rgp-1.0 rgp-1.0.xsd');
|
||||
|
@ -759,6 +760,49 @@ class EppWriter {
|
|||
$writer->writeAttribute('s', $resp['rgpstatus']);
|
||||
$writer->endElement(); // End of 'rgp:rgpStatus'
|
||||
$writer->endElement(); // End of 'rgp:infData'
|
||||
}
|
||||
|
||||
// Handle secDNS
|
||||
if (isset($resp['secDNS'])) {
|
||||
$writer->startElement('secDNS:infData');
|
||||
$writer->writeAttribute('xmlns:secDNS', 'urn:ietf:params:xml:ns:secDNS-1.1');
|
||||
$writer->writeAttribute('xsi:schemaLocation', 'urn:ietf:params:xml:ns:secDNS-1.1 secDNS-1.1.xsd');
|
||||
|
||||
// maxsiglife
|
||||
if (isset($resp['secDNS'][0]['maxSigLife'])) {
|
||||
$writer->writeElement('secDNS:maxSigLife', $resp['secDNS'][0]['maxSigLife']);
|
||||
}
|
||||
|
||||
// Handle secdns records
|
||||
foreach ($resp['secDNS'] as $secData) {
|
||||
// Start the DS data section
|
||||
if (isset($secData['keyTag'])) {
|
||||
$writer->startElement('secDNS:dsData');
|
||||
|
||||
$writer->writeElement('secDNS:keyTag', $secData['keyTag']);
|
||||
$writer->writeElement('secDNS:alg', $secData['alg']);
|
||||
$writer->writeElement('secDNS:digestType', $secData['digestType']);
|
||||
$writer->writeElement('secDNS:digest', $secData['digest']);
|
||||
|
||||
// If keyData is present, nest it inside the current dsData section
|
||||
if (isset($secData['keyData']) && is_array($secData['keyData'])) {
|
||||
$writer->startElement('secDNS:keyData');
|
||||
|
||||
$writer->writeElement('secDNS:flags', $secData['keyData']['flags']);
|
||||
$writer->writeElement('secDNS:protocol', $secData['keyData']['protocol']);
|
||||
$writer->writeElement('secDNS:alg', $secData['keyData']['alg']);
|
||||
$writer->writeElement('secDNS:pubKey', $secData['keyData']['pubKey']);
|
||||
|
||||
$writer->endElement(); // End of 'secDNS:keyData'
|
||||
}
|
||||
|
||||
$writer->endElement(); // End of 'secDNS:dsData'
|
||||
}
|
||||
}
|
||||
|
||||
$writer->endElement(); // End of 'secDNS:infData'
|
||||
}
|
||||
|
||||
$writer->endElement(); // End of 'extension'
|
||||
}
|
||||
}
|
||||
|
|
|
@ -204,16 +204,22 @@ function processDomainInfo($conn, $db, $xml, $trans) {
|
|||
foreach ($contacts as $contact) {
|
||||
$transformedContacts[] = [$contact['type'], getContactIdentifier($db, $contact['contact_id'])];
|
||||
}
|
||||
|
||||
|
||||
// Fetch hosts
|
||||
$stmt = $db->prepare("SELECT * FROM domain_host_map WHERE domain_id = :id");
|
||||
$stmt->execute(['id' => $domain['id']]);
|
||||
$hosts = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
$transformedHosts = [];
|
||||
foreach ($hosts as $host) {
|
||||
$transformedHosts[] = [getHost($db, $host['host_id'])];
|
||||
if ($hosts) {
|
||||
foreach ($hosts as $host) {
|
||||
$transformedHosts[] = [getHost($db, $host['host_id'])];
|
||||
}
|
||||
}
|
||||
|
||||
$stmt = $db->prepare("SELECT name FROM host WHERE domain_id = :id");
|
||||
$stmt->execute(['id' => $domain['id']]);
|
||||
$hostNames = $stmt->fetchAll(PDO::FETCH_COLUMN, 0);
|
||||
|
||||
// Fetch authInfo
|
||||
$stmt = $db->prepare("SELECT * FROM domain_authInfo WHERE domain_id = :id");
|
||||
|
@ -229,6 +235,45 @@ function processDomainInfo($conn, $db, $xml, $trans) {
|
|||
foreach($statuses as $status) {
|
||||
$statusArray[] = [$status['status']];
|
||||
}
|
||||
|
||||
// Fetch secDNS data
|
||||
$stmt = $db->prepare("SELECT * FROM secdns WHERE domain_id = :id");
|
||||
$stmt->execute(['id' => $domain['id']]);
|
||||
$secDnsRecords = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
$transformedSecDnsRecords = [];
|
||||
if ($secDnsRecords) {
|
||||
foreach ($secDnsRecords as $record) {
|
||||
$tmpRecord = [
|
||||
'keyTag' => $record['keytag'],
|
||||
'alg' => $record['alg'],
|
||||
'digestType' => $record['digesttype'],
|
||||
'digest' => $record['digest']
|
||||
];
|
||||
|
||||
// Add optional fields if they are not null
|
||||
if (!is_null($record['maxsiglife'])) {
|
||||
$tmpRecord['maxSigLife'] = $record['maxsiglife'];
|
||||
}
|
||||
if (!is_null($record['flags'])) {
|
||||
$tmpRecord['keyData']['flags'] = $record['flags'];
|
||||
}
|
||||
if (!is_null($record['protocol'])) {
|
||||
$tmpRecord['keyData']['protocol'] = $record['protocol'];
|
||||
}
|
||||
if (!is_null($record['keydata_alg'])) {
|
||||
$tmpRecord['keyData']['alg'] = $record['keydata_alg'];
|
||||
}
|
||||
if (!is_null($record['pubkey'])) {
|
||||
$tmpRecord['keyData']['pubKey'] = $record['pubkey'];
|
||||
}
|
||||
|
||||
$transformedSecDnsRecords[] = $tmpRecord;
|
||||
}
|
||||
}
|
||||
|
||||
// Fetch RGP status
|
||||
$rgpstatus = isset($domain['rgpstatus']) && $domain['rgpstatus'] ? $domain['rgpstatus'] : null;
|
||||
|
||||
$svTRID = generateSvTRID();
|
||||
$response = [
|
||||
|
@ -242,18 +287,44 @@ function processDomainInfo($conn, $db, $xml, $trans) {
|
|||
'status' => $statusArray,
|
||||
'registrant' => $domain['registrant'],
|
||||
'contact' => $transformedContacts,
|
||||
'hostObj' => $transformedHosts,
|
||||
'clID' => getRegistrarClid($db, $domain['clid']),
|
||||
'crID' => getRegistrarClid($db, $domain['crid']),
|
||||
'crDate' => $domain['crdate'],
|
||||
'upID' => getRegistrarClid($db, $domain['upid']),
|
||||
'upDate' => $domain['update'],
|
||||
'exDate' => $domain['exdate'],
|
||||
'trDate' => $domain['trdate'],
|
||||
'authInfo' => 'valid',
|
||||
'authInfo_type' => $authInfo['authtype'],
|
||||
'authInfo_val' => $authInfo['authinfo']
|
||||
];
|
||||
// Conditionally add upID, upDate, and trDate to the response
|
||||
if (isset($domain['upid']) && $domain['upid']) {
|
||||
$response['upID'] = getRegistrarClid($db, $domain['upid']);
|
||||
}
|
||||
if (isset($domain['update']) && $domain['update']) {
|
||||
$response['upDate'] = $domain['update'];
|
||||
}
|
||||
if (isset($domain['trdate']) && $domain['trdate']) {
|
||||
$response['trDate'] = $domain['trdate'];
|
||||
}
|
||||
|
||||
// Conditionally add hostObj if hosts are available from domain_host_map
|
||||
if (!empty($transformedHosts)) {
|
||||
$response['hostObj'] = $transformedHosts;
|
||||
}
|
||||
|
||||
// Conditionally add hostName if hosts are available from host
|
||||
if (!empty($hostNames)) {
|
||||
$response['host'] = $hostNames;
|
||||
}
|
||||
|
||||
// Add secDNS records to response if they exist
|
||||
if ($transformedSecDnsRecords) {
|
||||
$response['secDNS'] = $transformedSecDnsRecords;
|
||||
}
|
||||
|
||||
// Add RGP status to response if it exists
|
||||
if ($rgpstatus) {
|
||||
$response['rgpstatus'] = $rgpstatus;
|
||||
}
|
||||
|
||||
$epp = new EPP\EppWriter();
|
||||
$xml = $epp->epp_writer($response);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue