From ebdf49363e86267588a87f0bfc7a1b963f86ca8b Mon Sep 17 00:00:00 2001 From: Stephan de Wit <33954429+swhite2@users.noreply.github.com> Date: Mon, 4 Apr 2022 15:37:23 +0200 Subject: [PATCH] unbound: clean up references to legacy code, use mvc instead. also minor style fix (#5663) --- src/etc/inc/plugins.inc.d/unbound.inc | 5 ++- .../Unbound/Api/SettingsController.php | 31 ------------------- .../OPNsense/Unbound/forms/forwarding.xml | 4 +-- .../OPNsense/Unbound/Migrations/M1_0_2.php | 5 +++ .../app/models/OPNsense/Unbound/Unbound.xml | 5 +-- .../mvc/app/views/OPNsense/Unbound/dot.volt | 28 ++++++++--------- src/wizard/system.xml | 3 -- 7 files changed, 28 insertions(+), 53 deletions(-) diff --git a/src/etc/inc/plugins.inc.d/unbound.inc b/src/etc/inc/plugins.inc.d/unbound.inc index 94d881784..23698653d 100644 --- a/src/etc/inc/plugins.inc.d/unbound.inc +++ b/src/etc/inc/plugins.inc.d/unbound.inc @@ -255,10 +255,13 @@ EOF; $include_dhcpleases = ''; } + $unbound_mdl = new \OPNsense\Unbound\Unbound(); + $unbound_enabled = (string)$unbound_mdl->forwarding->enabled; + $forward_conf = ''; $forward_local = ''; $resolv_conf_root = ''; - if (isset($config['unbound']['forwarding'])) { + if ($unbound_enabled) { $dnsservers = get_nameservers(); if (!empty($dnsservers)) { diff --git a/src/opnsense/mvc/app/controllers/OPNsense/Unbound/Api/SettingsController.php b/src/opnsense/mvc/app/controllers/OPNsense/Unbound/Api/SettingsController.php index 3051f7939..226d8592e 100644 --- a/src/opnsense/mvc/app/controllers/OPNsense/Unbound/Api/SettingsController.php +++ b/src/opnsense/mvc/app/controllers/OPNsense/Unbound/Api/SettingsController.php @@ -40,37 +40,6 @@ class SettingsController extends ApiMutableModelControllerBase private $type = 'dot'; - public function toggleSystemForwardAction() - { - if ($this->request->isPost() && $this->request->hasPost('forwarding')) { - $this->sessionClose(); - Config::getInstance()->lock(); - $config = Config::getInstance()->object(); - - $val = $this->request->getPost('forwarding')['enabled']; - - /* Write to config exactly as legacy would */ - $config->unbound->forwarding = !empty($val); - if ($val != "1") { - /* legacy uses isset() */ - unset($config->unbound->forwarding); - } - - /* save and release lock */ - Config::getInstance()->save(); - } - } - - public function getSystemForwardAction() - { - $config = Config::getInstance()->object(); - return array("forwarding" => - array( "enabled" => - empty($config->unbound->forwarding) ? 0 : 1 - ) - ); - } - public function getNameserversAction() { if ($this->request->isGet()) { diff --git a/src/opnsense/mvc/app/controllers/OPNsense/Unbound/forms/forwarding.xml b/src/opnsense/mvc/app/controllers/OPNsense/Unbound/forms/forwarding.xml index c40ece719..03786bac6 100755 --- a/src/opnsense/mvc/app/controllers/OPNsense/Unbound/forms/forwarding.xml +++ b/src/opnsense/mvc/app/controllers/OPNsense/Unbound/forms/forwarding.xml @@ -1,6 +1,6 @@