Skip to content

Commit e5a8eab

Browse files
author
Thom
committed
Add API function for enabling dnssec (#6476)
1 parent 9a10982 commit e5a8eab

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

interface/lib/classes/remote.d/dns.inc.php

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -742,6 +742,39 @@ public function dns_zone_set_status($session_id, $primary_id, $status) {
742742
return false;
743743
}
744744
}
745+
746+
/*
747+
* Set DNSSec Algo and activate it if needed.
748+
*
749+
* @param int session id
750+
* @param int client id
751+
* @param string algorithm 'NSEC3RSASHA1', 'ECDSAP256SHA256' or 'NSEC3RSASHA1,ECDSAP256SHA256' string
752+
* @param boolean update serial
753+
*
754+
* @author Tom Albers <kovoks@kovoks.nl> KovoKs B.V. 2023
755+
*/
756+
757+
public function dns_zone_set_dnssec($session_id, $client_id, $primary_id, $algo, $update_serial=false) {
758+
global $app;
759+
if(!$this->checkPerm($session_id, 'dns_zone_set_status')) {
760+
throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
761+
return false;
762+
}
763+
764+
if(!in_array($algo, ['NSEC3RSASHA1', 'ECDSAP256SHA256', 'NSEC3RSASHA1,ECDSAP256SHA256'])) {
765+
throw new SoapFault('permission_denied', 'You are not using a valid algorithm for this function.');
766+
return false;
767+
}
768+
$params["dnssec_wanted"] = "Y";
769+
$params["dnssec_algo"] = $algo;
770+
$affected_rows = $this->updateQuery('../dns/form/dns_soa.tform.php', $client_id, $primary_id, $params);
771+
if($update_serial) {
772+
$this->increase_serial($session_id, $client_id, ["zone" => $primary_id]);
773+
774+
}
775+
return $affected_rows;
776+
}
777+
745778

746779
private function increase_serial($session_id, $client_id, $params) {
747780
global $app;

0 commit comments

Comments
 (0)