Skip to content

Commit

Permalink
Added support for DNSSEC, fixed #15
Browse files Browse the repository at this point in the history
  • Loading branch information
getpinga committed Oct 28, 2024
1 parent ed7db31 commit 88e5212
Show file tree
Hide file tree
Showing 2 changed files with 318 additions and 0 deletions.
194 changes: 194 additions & 0 deletions epp.php
Original file line number Diff line number Diff line change
Expand Up @@ -1469,6 +1469,200 @@ function epp_RequestDelete($params = array())
return $return;
}

function epp_manageDNSSECDSRecords($params = array())
{
_epp_log(__FUNCTION__, $params);
$return = array();
try {
$s = _epp_startEppClient($params);

if (isset($_POST['command']) && ($_POST['command'] === 'secDNSadd')) {
$keyTag = $_POST['keyTag'];
$alg = $_POST['alg'];
$digestType = $_POST['digestType'];
$digest = $_POST['digest'];

$from = $to = array();
$from[] = '/{{ name }}/';
$to[] = htmlspecialchars($params['domainname']);

$from[] = '/{{ keyTag }}/';
$to[] = htmlspecialchars($keyTag);

$from[] = '/{{ alg }}/';
$to[] = htmlspecialchars($alg);

$from[] = '/{{ digestType }}/';
$to[] = htmlspecialchars($digestType);

$from[] = '/{{ digest }}/';
$to[] = htmlspecialchars($digest);

$from[] = '/{{ clTRID }}/';
$clTRID = str_replace('.', '', round(microtime(1), 3));
$to[] = htmlspecialchars($params['registrarprefix'] . '-domain-update-' . $clTRID);
$xml = preg_replace($from, $to, '<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:ietf:params:xml:ns:epp-1.0 epp-1.0.xsd">
<command>
<update>
<domain:update
xmlns:domain="urn:ietf:params:xml:ns:domain-1.0"
xsi:schemaLocation="urn:ietf:params:xml:ns:domain-1.0 domain-1.0.xsd">
<domain:name>{{ name }}</domain:name>
</domain:update>
</update>
<extension>
<secDNS:update xmlns:secDNS="urn:ietf:params:xml:ns:secDNS-1.1">
<secDNS:add>
<secDNS:dsData>
<secDNS:keyTag>{{ keyTag }}</secDNS:keyTag>
<secDNS:alg>{{ alg }}</secDNS:alg>
<secDNS:digestType>{{ digestType }}</secDNS:digestType>
<secDNS:digest>{{ digest }}</secDNS:digest>
</secDNS:dsData>
</secDNS:add>
</secDNS:update>
</extension>
<clTRID>{{ clTRID }}</clTRID>
</command>
</epp>');
$r = $s->write($xml, __FUNCTION__);
}

if (isset($_POST['command']) && ($_POST['command'] === 'secDNSrem')) {
$keyTag = $_POST['keyTag'];
$alg = $_POST['alg'];
$digestType = $_POST['digestType'];
$digest = $_POST['digest'];

$from = $to = array();
$from[] = '/{{ name }}/';
$to[] = htmlspecialchars($params['domainname']);

$from[] = '/{{ keyTag }}/';
$to[] = htmlspecialchars($keyTag);

$from[] = '/{{ alg }}/';
$to[] = htmlspecialchars($alg);

$from[] = '/{{ digestType }}/';
$to[] = htmlspecialchars($digestType);

$from[] = '/{{ digest }}/';
$to[] = htmlspecialchars($digest);

$from[] = '/{{ clTRID }}/';
$clTRID = str_replace('.', '', round(microtime(1), 3));
$to[] = htmlspecialchars($params['registrarprefix'] . '-domain-update-' . $clTRID);
$xml = preg_replace($from, $to, '<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:ietf:params:xml:ns:epp-1.0 epp-1.0.xsd">
<command>
<update>
<domain:update
xmlns:domain="urn:ietf:params:xml:ns:domain-1.0"
xsi:schemaLocation="urn:ietf:params:xml:ns:domain-1.0 domain-1.0.xsd">
<domain:name>{{ name }}</domain:name>
</domain:update>
</update>
<extension>
<secDNS:update xmlns:secDNS="urn:ietf:params:xml:ns:secDNS-1.1">
<secDNS:rem>
<secDNS:dsData>
<secDNS:keyTag>{{ keyTag }}</secDNS:keyTag>
<secDNS:alg>{{ alg }}</secDNS:alg>
<secDNS:digestType>{{ digestType }}</secDNS:digestType>
<secDNS:digest>{{ digest }}</secDNS:digest>
</secDNS:dsData>
</secDNS:rem>
</secDNS:update>
</extension>
<clTRID>{{ clTRID }}</clTRID>
</command>
</epp>');
$r = $s->write($xml, __FUNCTION__);
}

$from = $to = array();
$from[] = '/{{ name }}/';
$to[] = htmlspecialchars($params['domainname']);
$from[] = '/{{ clTRID }}/';
$clTRID = str_replace('.', '', round(microtime(1), 3));
$to[] = htmlspecialchars($params['registrarprefix'] . '-domain-info-' . $clTRID);
$xml = preg_replace($from, $to, '<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:ietf:params:xml:ns:epp-1.0 epp-1.0.xsd">
<command>
<info>
<domain:info
xmlns:domain="urn:ietf:params:xml:ns:domain-1.0"
xsi:schemaLocation="urn:ietf:params:xml:ns:domain-1.0 domain-1.0.xsd">
<domain:name hosts="all">{{ name }}</domain:name>
</domain:info>
</info>
<clTRID>{{ clTRID }}</clTRID>
</command>
</epp>');
$r = $s->write($xml, __FUNCTION__);

$secDNSdsData = array();
if ($r->response->extension && $r->response->extension->children('urn:ietf:params:xml:ns:secDNS-1.1')->infData) {
$DSRecords = 'YES';
$i = 0;
$r = $r->response->extension->children('urn:ietf:params:xml:ns:secDNS-1.1')->infData;
foreach($r->dsData as $dsData) {
$i++;
$secDNSdsData[$i]["domainid"] = (int)$params['domainid'];
$secDNSdsData[$i]["keyTag"] = (string)$dsData->keyTag;
$secDNSdsData[$i]["alg"] = (int)$dsData->alg;
$secDNSdsData[$i]["digestType"] = (int)$dsData->digestType;
$secDNSdsData[$i]["digest"] = (string)$dsData->digest;
}
}
else {
$DSRecords = "You don't have any DS records";
}

$return = array(
'templatefile' => 'manageDNSSECDSRecords',
'requirelogin' => true,
'vars' => array(
'DSRecords' => $DSRecords,
'DSRecordslist' => $secDNSdsData
)
);
}

catch(exception $e) {
$return = array(
'templatefile' => 'manageDNSSECDSRecords',
'requirelogin' => true,
'vars' => array(
'error' => $e->getMessage()
)
);
}

if (!empty($s)) {
$s->logout($params['registrarprefix']);
}

return $return;
}

function epp_ClientAreaCustomButtonArray()
{
$buttonarray = array(
Lang::Trans('Manage DNSSEC DS Records') => 'manageDNSSECDSRecords'
);

return $buttonarray;
}

function epp_AdminCustomButtonArray($params = array())
{
_epp_log(__FUNCTION__, $params);
Expand Down
124 changes: 124 additions & 0 deletions manageDNSSECDSRecords.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
<div class="card">
<div class="card-body">
<h3 class="card-title">Manage DNSSEC DS Records</h3>

{if $error}
<div class="alert alert-warning">
<i class='fas fa-exclamation-circle fa-fw'></i> {$error}
</div>
{else}
{if $DSRecords eq 'YES'}
{foreach $DSRecordslist as $item}
<form method="post" action="clientarea.php">
<input type="hidden" name="action" value="domaindetails" />
<input type="hidden" name="id" value="{$domainid}" />
<input type="hidden" name="modop" value="custom" />
<input type="hidden" name="a" value="manageDNSSECDSRecords" />
<input type="hidden" name="command" value="secDNSrem" />

<h3 class="card-title">DS records:</h3>

<div class="form-group row">
<label for="keytag1a" class="col-md-4 col-form-label">Key tag</label>
<div class="col-md-6">
<input name="keyTag" type="text" maxlength="65535" class="form-control" id="keytag1a" data-supported="True" data-required="True" value="{$item.keyTag}" />
</div>
</div>
<div class="form-group row">
<label for="alg1a" class="col-md-4 col-form-label">Algorithm</label>
<div class="col-md-6">
<input name="alg" class="form-control" id="alg1a" data-supported="True" data-required="True" value="{$item.alg}">
</div>
</div>
<div class="form-group row">
<label for="digestType1" class="col-md-4 col-form-label">Digest type</label>
<div class="col-md-6">
<input name="digestType" class="form-control" id="digestType1" data-supported="True" data-required="True" value="{$item.digestType}">
</div>
</div>
<div class="form-group row">
<label for="digest1a" class="col-md-4 col-form-label">Digest</label>
<div class="col-md-6">
<textarea name="digest" class="form-control" rows="2" data-supported="True" id="digest1a" data-required="True">{$item.digest}</textarea>
</div>
</div>

<div class="text-center">
<button type="submit" class="btn btn-primary">
Remove DS Record
</button>
</div>

</form>
{/foreach}
{else}
<div class="alert alert-info">
<i class='fas fa-info-circle fa-fw'></i> {$DSRecords}
</div>
{/if}
{/if}
</div>
</div>

<div class="card">
<div class="card-body">
<form method="post" action="clientarea.php">
<input type="hidden" name="action" value="domaindetails" />
<input type="hidden" name="id" value="{$domainid}" />
<input type="hidden" name="modop" value="custom" />
<input type="hidden" name="a" value="manageDNSSECDSRecords" />
<input type="hidden" name="command" value="secDNSadd" />

<h3 class="card-title">Create a DS Record</h3>

<div class="form-group row">
<label for="keytag1" class="col-md-4 col-form-label">Key tag</label>
<div class="col-md-6">
<input name="keyTag" type="text" maxlength="65535" class="form-control" id="keytag1" data-supported="True" data-required="True" data-previousvalue="" />
</div>
</div>
<div class="form-group row">
<label for="alg1" class="col-md-4 col-form-label">Algorithm</label>
<div class="col-md-6">
<select name="alg" data-supported="True" class="form-control" id="alg1" data-required="True" data-previousvalue="">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="10">10</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="253">253</option>
<option value="254">254</option>
</select>
</div>
</div>
<div class="form-group row">
<label for="digestType" class="col-md-4 col-form-label">Digest type</label>
<div class="col-md-6">
<select name="digestType" class="form-control" id="digestType" data-supported="True" data-required="True" data-previousvalue="">
<option value="1">1</option>
<option value="2">2</option>
</select>
</div>
</div>
<div class="form-group row">
<label for="digest1" class="col-md-4 col-form-label">Digest</label>
<div class="col-md-6">
<textarea name="digest" class="form-control" rows="2" data-supported="True" id="digest1" data-required="True" data-previousvalue=""></textarea>
</div>
</div>

<div class="text-center">
<button type="submit" class="btn btn-primary">
Create DS Record
</button>
</div>

</form>
</div>
</div>

0 comments on commit 88e5212

Please sign in to comment.