Skip to content

Commit 5c95b6f

Browse files
authored
Added support for the HMAC-SHA256 algorithm (#59)
1 parent 7096b05 commit 5c95b6f

File tree

7 files changed

+30
-12
lines changed

7 files changed

+30
-12
lines changed

CHANGES.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# 1.10.4 (1 March 2025)
2+
3+
* [+] Added support for the HMAC-SHA256 algorithm, which is now the new default option.
4+
15
# 1.10.3 (12 October 2023)
26

37
* [*] Internal improvements.

meta.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<name>Slave DNS Manager</name>
66
<description>The extension for managing a remote slave DNS server via rndc protocol (bind).</description>
77
<category>dns</category>
8-
<version>1.10.3</version>
8+
<version>1.10.4</version>
99
<release>0</release>
1010
<vendor>Plesk</vendor>
1111
<url>https://github.com/plesk/ext-slave-dns-manager</url>

plib/library/ApiRpc/DnsSlave/AddCommand.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99

1010
class AddCommand extends AbstractCommand
1111
{
12-
const AVAILABLE_ALGORITHMS = ['hmac-md5'];
13-
const DEFAULT_ALGORITHM = 'hmac-md5';
12+
const AVAILABLE_ALGORITHMS = ['hmac-sha256', 'hmac-md5'];
13+
const DEFAULT_ALGORITHM = 'hmac-sha256';
1414
const DEFAULT_PORT = 953;
1515

1616
protected function _checkParams()

plib/library/Form/Add.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ public function init()
3737
));
3838
$this->addElement('select', 'algorithm', array(
3939
'label' => $this->lmsg('algorithmLabel'),
40-
'multiOptions' => array('hmac-md5' => 'hmac-md5',),
41-
'value' => 'hmac-md5',
40+
'multiOptions' => array('hmac-sha256' => 'hmac-sha256', 'hmac-md5' => 'hmac-md5',),
41+
'value' => 'hmac-sha256',
4242
'required' => true,
4343
));
4444
$this->addElement('text', 'secret', array(

plib/library/Slave.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ public function save(array $data)
105105
}
106106
}
107107

108-
$keyAlgorithm = array_key_exists('algorithm', $data) ? $data['algorithm'] : 'hmac-md5';
108+
$keyAlgorithm = array_key_exists('algorithm', $data) ? $data['algorithm'] : 'hmac-sha256';
109109
$keySecret = $data['secret'];
110110

111111
$this->_saveConfig($this->getConfigPath(), $this->_renderConfig($slaveIp, $keySecret, $keyAlgorithm));
@@ -121,7 +121,7 @@ private function _renderConfig($slaveIp, $keySecret, $keyAlgorithm)
121121

122122
$view = new Zend_View();
123123
$view->setScriptPath(pm_Context::getPlibDir() . 'views/scripts');
124-
$slaveConfiguration = $view->partial('index/slave-config.phtml', ['masterPublicIp' => $masterPublicIp, 'secret' => $keySecret]);
124+
$slaveConfiguration = $view->partial('index/slave-config.phtml', ['masterPublicIp' => $masterPublicIp, 'secret' => $keySecret, 'algorithm' => $keyAlgorithm]);
125125
$slaveConfiguration = trim(html_entity_decode(strip_tags($slaveConfiguration)));
126126
$slaveConfiguration = preg_replace('/^/m', ' ', $slaveConfiguration);
127127

plib/views/scripts/index/add.phtml

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,43 @@
33
?>
44
<script type="text/javascript">
55
Jsw.onReady(function () {
6-
var select = document.getElementById('<?=$this->form->getElement('masterIp')->getId()?>');
6+
var selectMasterPublicIp = document.getElementById('<?=$this->form->getElement('masterIp')->getId()?>');
7+
var selectAlgorithm = document.getElementById('<?=$this->form->getElement('algorithm')->getId()?>');
78

89
function updateMasterPublicIp() {
9-
var value = select.options[select.selectedIndex].text;
10+
var value = selectMasterPublicIp.options[selectMasterPublicIp.selectedIndex].text;
1011
var placeholders = document.getElementsByClassName('js-placeholder-ip');
1112
for (var i = 0; i < placeholders.length; i++) {
1213
placeholders[i].innerHTML = value;
1314
}
1415
}
15-
select.addEventListener('change', updateMasterPublicIp);
16+
17+
function updateAlgorithm() {
18+
var value = selectAlgorithm.options[selectAlgorithm.selectedIndex].text;
19+
var placeholders = document.getElementsByClassName('js-placeholder-algorithm');
20+
for (var i = 0; i < placeholders.length; i++) {
21+
placeholders[i].innerHTML = value;
22+
}
23+
}
24+
25+
selectMasterPublicIp.addEventListener('change', updateMasterPublicIp);
26+
selectAlgorithm.addEventListener('change', updateAlgorithm);
1627

1728
var config = document.getElementById('slave-config');
1829
config.innerHTML = config.innerHTML.replace(/%%js-placeholder-ip%%/g, '<span class="js-placeholder-ip"></span>');
30+
config.innerHTML = config.innerHTML.replace(/%%js-placeholder-algorithm%%/g, '<span class="js-placeholder-algorithm"></span>');
1931
updateMasterPublicIp();
32+
updateAlgorithm()
2033
});
2134
</script>
2235
<div class="hint" id="slave-config">
2336
<?=$this->partial('index/slave-config.phtml', [
2437
'masterPublicIp' => '%%js-placeholder-ip%%',
38+
'algorithm' => '%%js-placeholder-algorithm%%',
2539
'secret' => $this->form->getElement('secret')->getValue(),
2640
])?>
2741
</div>
2842
<p>
29-
<a href="https://www.plesk.com/blog/product-technology/slave-dns-and-plesk" target="_blank"><?php echo $this->lmsg('learnMore') ?></a>
43+
<a href="https://docs.plesk.com/en-US/current/administrator-guide/79004/" target="_blank"><?php echo $this->lmsg('learnMore') ?></a>
3044
</p>
3145
<?php echo $this->form ?>

plib/views/scripts/index/slave-config.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ options {
99
};
1010

1111
key &quot;rndc-key-<i><?=$this->escape($this->masterPublicIp)?></i>&quot; {
12-
algorithm hmac-md5;
12+
algorithm <?=$this->escape($this->algorithm)?>;
1313
secret &quot;<b><?=$this->escape($this->secret)?></b>&quot;;
1414
};
1515

0 commit comments

Comments
 (0)