diff --git a/dns/unbound-plus/Makefile b/dns/unbound-plus/Makefile index 0e296dd61..b02461eb7 100644 --- a/dns/unbound-plus/Makefile +++ b/dns/unbound-plus/Makefile @@ -1,7 +1,7 @@ PLUGIN_NAME= unbound-plus -PLUGIN_VERSION= 0.2 +PLUGIN_VERSION= 0.3 PLUGIN_COMMENT= Unbound additions PLUGIN_MAINTAINER= m.muenz@gmail.com -PLUGIN_DEVEL= yes +PLUGIN_DEVEL= yes .include "../../Mk/plugins.mk" diff --git a/dns/unbound-plus/src/opnsense/mvc/app/controllers/OPNsense/Unboundplus/Api/MiscellaneousController.php b/dns/unbound-plus/src/opnsense/mvc/app/controllers/OPNsense/Unboundplus/Api/MiscellaneousController.php new file mode 100644 index 000000000..5e9878820 --- /dev/null +++ b/dns/unbound-plus/src/opnsense/mvc/app/controllers/OPNsense/Unboundplus/Api/MiscellaneousController.php @@ -0,0 +1,37 @@ + + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +namespace OPNsense\Unboundplus\Api; + +use OPNsense\Base\ApiMutableModelControllerBase; + +class MiscellaneousController extends ApiMutableModelControllerBase +{ + protected static $internalModelClass = '\OPNsense\Unboundplus\Miscellaneous'; + protected static $internalModelName = 'miscellaneous'; +} diff --git a/dns/unbound-plus/src/opnsense/mvc/app/controllers/OPNsense/Unboundplus/Api/ServiceController.php b/dns/unbound-plus/src/opnsense/mvc/app/controllers/OPNsense/Unboundplus/Api/ServiceController.php index 9983e2843..66fa74857 100644 --- a/dns/unbound-plus/src/opnsense/mvc/app/controllers/OPNsense/Unboundplus/Api/ServiceController.php +++ b/dns/unbound-plus/src/opnsense/mvc/app/controllers/OPNsense/Unboundplus/Api/ServiceController.php @@ -31,6 +31,7 @@ namespace OPNsense\Unboundplus\Api; use OPNsense\Base\ApiMutableServiceControllerBase; use OPNsense\Core\Backend; use OPNsense\Unboundplus\Dnsbl; +use OPNsense\Unboundplus\Miscellaneous; class ServiceController extends ApiMutableServiceControllerBase { @@ -48,4 +49,14 @@ class ServiceController extends ApiMutableServiceControllerBase $response = $backend->configdpRun('unboundplus dnsbl', array((string)$mdl->type)); return array("response" => $response); } + + public function reloadunboundAction() + { + $this->sessionClose(); + $mdl = new Miscellaneous(); + $backend = new Backend(); + $backend->configdRun('template reload OPNsense/Unboundplus'); + $response = $backend->configdpRun('unbound reload', array((string)$mdl->type)); + return array("response" => $response); + } } diff --git a/dns/unbound-plus/src/opnsense/mvc/app/controllers/OPNsense/Unboundplus/MiscellaneousController.php b/dns/unbound-plus/src/opnsense/mvc/app/controllers/OPNsense/Unboundplus/MiscellaneousController.php new file mode 100644 index 000000000..25bdb9e63 --- /dev/null +++ b/dns/unbound-plus/src/opnsense/mvc/app/controllers/OPNsense/Unboundplus/MiscellaneousController.php @@ -0,0 +1,38 @@ + + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +namespace OPNsense\Unboundplus; + +class MiscellaneousController extends \OPNsense\Base\IndexController +{ + public function indexAction() + { + $this->view->miscellaneousForm = $this->getForm('miscellaneous'); + $this->view->pick('OPNsense/Unboundplus/miscellaneous'); + } +} diff --git a/dns/unbound-plus/src/opnsense/mvc/app/controllers/OPNsense/Unboundplus/forms/miscellaneous.xml b/dns/unbound-plus/src/opnsense/mvc/app/controllers/OPNsense/Unboundplus/forms/miscellaneous.xml new file mode 100644 index 000000000..3945c3405 --- /dev/null +++ b/dns/unbound-plus/src/opnsense/mvc/app/controllers/OPNsense/Unboundplus/forms/miscellaneous.xml @@ -0,0 +1,10 @@ +
+ + miscellaneous.privatedomain + + select_multiple + + true + List of domains to mark as private. You only need this for some DNSBL lists which resolve to private addresses. + +
diff --git a/dns/unbound-plus/src/opnsense/mvc/app/models/OPNsense/Unboundplus/Menu/Menu.xml b/dns/unbound-plus/src/opnsense/mvc/app/models/OPNsense/Unboundplus/Menu/Menu.xml index 2522fb4a4..a63bd5e52 100644 --- a/dns/unbound-plus/src/opnsense/mvc/app/models/OPNsense/Unboundplus/Menu/Menu.xml +++ b/dns/unbound-plus/src/opnsense/mvc/app/models/OPNsense/Unboundplus/Menu/Menu.xml @@ -2,6 +2,7 @@ + diff --git a/dns/unbound-plus/src/opnsense/mvc/app/models/OPNsense/Unboundplus/Miscellaneous.php b/dns/unbound-plus/src/opnsense/mvc/app/models/OPNsense/Unboundplus/Miscellaneous.php new file mode 100644 index 000000000..9cc112378 --- /dev/null +++ b/dns/unbound-plus/src/opnsense/mvc/app/models/OPNsense/Unboundplus/Miscellaneous.php @@ -0,0 +1,35 @@ + + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +namespace OPNsense\Unboundplus; + +use OPNsense\Base\BaseModel; + +class Miscellaneous extends BaseModel +{ +} diff --git a/dns/unbound-plus/src/opnsense/mvc/app/models/OPNsense/Unboundplus/Miscellaneous.xml b/dns/unbound-plus/src/opnsense/mvc/app/models/OPNsense/Unboundplus/Miscellaneous.xml new file mode 100644 index 000000000..5a3b3e858 --- /dev/null +++ b/dns/unbound-plus/src/opnsense/mvc/app/models/OPNsense/Unboundplus/Miscellaneous.xml @@ -0,0 +1,10 @@ + + //OPNsense/unboundplus/miscellaneous + Unbound Miscellaneous configuration + 0.0.1 + + + N + + + diff --git a/dns/unbound-plus/src/opnsense/mvc/app/views/OPNsense/Unboundplus/dnsbl.volt b/dns/unbound-plus/src/opnsense/mvc/app/views/OPNsense/Unboundplus/dnsbl.volt index 29f6853a0..eb53cf0e6 100644 --- a/dns/unbound-plus/src/opnsense/mvc/app/views/OPNsense/Unboundplus/dnsbl.volt +++ b/dns/unbound-plus/src/opnsense/mvc/app/views/OPNsense/Unboundplus/dnsbl.volt @@ -44,10 +44,10 @@ // link save button to API set action $("#saveAct").click(function(){ saveFormToEndpoint(url="/api/unboundplus/dnsbl/set", formid='frm_dnsbl_settings',callback_ok=function(){ - $("#saveAct_progress").addClass("fa fa-spinner fa-pulse"); - ajaxCall(url="/api/unboundplus/service/dnsbl", sendData={}, callback=function(data,status) { - $("#saveAct_progress").removeClass("fa fa-spinner fa-pulse"); - }); + $("#saveAct_progress").addClass("fa fa-spinner fa-pulse"); + ajaxCall(url="/api/unboundplus/service/dnsbl", sendData={}, callback=function(data,status) { + $("#saveAct_progress").removeClass("fa fa-spinner fa-pulse"); + }); }); }); }); diff --git a/dns/unbound-plus/src/opnsense/mvc/app/views/OPNsense/Unboundplus/miscellaneous.volt b/dns/unbound-plus/src/opnsense/mvc/app/views/OPNsense/Unboundplus/miscellaneous.volt new file mode 100644 index 000000000..dda6369f2 --- /dev/null +++ b/dns/unbound-plus/src/opnsense/mvc/app/views/OPNsense/Unboundplus/miscellaneous.volt @@ -0,0 +1,54 @@ +{# + # Copyright (c) 2019 Deciso B.V. + # Copyright (c) 2019 Michael Muenz + # All rights reserved. + # + # Redistribution and use in source and binary forms, with or without modification, + # are permitted provided that the following conditions are met: + # + # 1. Redistributions of source code must retain the above copyright notice, + # this list of conditions and the following disclaimer. + # + # 2. Redistributions in binary form must reproduce the above copyright notice, + # this list of conditions and the following disclaimer in the documentation + # and/or other materials provided with the distribution. + # + # THIS SOFTWARE IS PROVIDED “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, + # INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + # AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + # AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + # OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + # POSSIBILITY OF SUCH DAMAGE. + #} + +
+ {{ partial("layout_partials/base_form",['fields':miscellaneousForm,'id':'frm_miscellaneous_settings'])}} +
+
+ +
+
+ + diff --git a/dns/unbound-plus/src/opnsense/scripts/OPNsense/Unboundplus/dnsbl.sh b/dns/unbound-plus/src/opnsense/scripts/OPNsense/Unboundplus/dnsbl.sh index 842c53c36..3f305094d 100755 --- a/dns/unbound-plus/src/opnsense/scripts/OPNsense/Unboundplus/dnsbl.sh +++ b/dns/unbound-plus/src/opnsense/scripts/OPNsense/Unboundplus/dnsbl.sh @@ -2,6 +2,7 @@ # Copyright (c) 2018-2019 Michael Muenz # Copyright (c) 2018 Franco Fichtner +# Copyright (c) 2019 Martin Wasley # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions @@ -221,11 +222,14 @@ install() { fi done # Merge resulting files (/dev/null in case there are none) - cat $(find ${WORKDIR} -type f -name "*.inc") /dev/null > ${DESTDIR}/dnsbl.conf - chown unbound:unbound ${DESTDIR}/dnsbl.conf + if [ -s "/var/unbound/etc/dnsbl.inc" ]; then + cat $(find ${WORKDIR} -type f -name "*.inc") /dev/null > ${DESTDIR}/dnsbl.conf + chown unbound:unbound ${DESTDIR}/dnsbl.conf + else + rm -rf ${DESTDIR}/dnsbl.conf + fi rm -rf ${WORKDIR} pluginctl -s unbound restart - } DNSBL=${1} diff --git a/dns/unbound-plus/src/opnsense/service/templates/OPNsense/Unboundplus/+TARGETS b/dns/unbound-plus/src/opnsense/service/templates/OPNsense/Unboundplus/+TARGETS index 115f95f26..c9be1287b 100644 --- a/dns/unbound-plus/src/opnsense/service/templates/OPNsense/Unboundplus/+TARGETS +++ b/dns/unbound-plus/src/opnsense/service/templates/OPNsense/Unboundplus/+TARGETS @@ -1,2 +1,3 @@ dnsbl.inc:/var/unbound/etc/dnsbl.inc whitelist.inc:/var/unbound/etc/whitelist.inc +miscellaneous.conf:/var/unbound/etc/miscellaneous.conf diff --git a/dns/unbound-plus/src/opnsense/service/templates/OPNsense/Unboundplus/miscellaneous.conf b/dns/unbound-plus/src/opnsense/service/templates/OPNsense/Unboundplus/miscellaneous.conf new file mode 100644 index 000000000..849bf8b10 --- /dev/null +++ b/dns/unbound-plus/src/opnsense/service/templates/OPNsense/Unboundplus/miscellaneous.conf @@ -0,0 +1,6 @@ +{% if helpers.exists('OPNsense.unboundplus.miscellaneous.privatedomain') and OPNsense.unboundplus.miscellaneous.privatedomain != '' %} +server: +{% for privatedomain in OPNsense.unboundplus.miscellaneous.privatedomain.split(',') %} +private-domain: {{ privatedomain }} +{% endfor %} +{% endif %}