dns/unbound-plus: add whitelisting (#1506)

This commit is contained in:
Michael
2019-09-16 22:55:14 +02:00
committed by Franco Fichtner
parent c48b5e2305
commit 7e61220fbe
8 changed files with 30 additions and 5 deletions
+1 -1
View File
@@ -1,5 +1,5 @@
PLUGIN_NAME= unbound-plus
PLUGIN_VERSION= 0.1
PLUGIN_VERSION= 0.2
PLUGIN_COMMENT= Unbound additions
PLUGIN_MAINTAINER= m.muenz@gmail.com
PLUGIN_DEVEL= yes
@@ -44,6 +44,7 @@ class ServiceController extends ApiMutableServiceControllerBase
$this->sessionClose();
$mdl = new Dnsbl();
$backend = new Backend();
$backend->configdRun('template reload OPNsense/Unboundplus');
$response = $backend->configdpRun('unboundplus dnsbl', array((string)$mdl->type));
return array("response" => $response);
}
@@ -11,4 +11,12 @@
<type>select_multiple</type>
<help>Select which kind of DNSBL you want to use.</help>
</field>
<field>
<id>dnsbl.whitelists</id>
<label>Whitelist Domains</label>
<type>select_multiple</type>
<style>tokenize</style>
<allownew>true</allownew>
<help>List of domains to whitelist.</help>
</field>
</form>
@@ -37,5 +37,8 @@
<yy>YoYo List</yy>
</OptionValues>
</type>
<whitelists type="CSVListField">
<Required>N</Required>
</whitelists>
</items>
</model>
@@ -213,7 +213,12 @@ simpletrack() {
install() {
# Put all files in correct format
for FILE in $(find ${WORKDIR} -type f); do
cat ${FILE} | sort -u | awk '{printf "server:\n", $1; printf "local-data: \"%s A 0.0.0.0\"\n", $1}' > ${FILE}.inc
WHITE=$(cat ${DESTDIR}/whitelist.inc | tr ',' '|')
if [ -z "${WHITE}" ]; then
cat ${FILE} | sort -u | awk '{printf "server:\n", $1; printf "local-data: \"%s A 0.0.0.0\"\n", $1}' > ${FILE}.inc
else
cat ${FILE} | sort -u | egrep -v "$WHITE" | awk '{printf "server:\n", $1; printf "local-data: \"%s A 0.0.0.0\"\n", $1}' > ${FILE}.inc
fi
done
# Merge resulting files (/dev/null in case there are none)
cat $(find ${WORKDIR} -type f -name "*.inc") /dev/null > ${DESTDIR}/dnsbl.conf
@@ -1 +1,2 @@
dnsbl.inc:/var/unbound/etc/dnsbl.inc
whitelist.inc:/var/unbound/etc/whitelist.inc
@@ -1,5 +1,5 @@
{% if helpers.exists('OPNsense.unbound.dnsbl.enabled') and OPNsense.unbound.dnsbl.enabled == '1' %}
{% if helpers.exists('OPNsense.unbound.dnsbl.type') and OPNsense.unbound.dnsbl.type != '' %}
unbound_dnsbl="{{ OPNsense.unbound.dnsbl.type }}"
{% if helpers.exists('OPNsense.unboundplus.dnsbl.enabled') and OPNsense.unboundplus.dnsbl.enabled == '1' %}
{% if helpers.exists('OPNsense.unboundplus.dnsbl.type') and OPNsense.unboundplus.dnsbl.type != '' %}
unbound_dnsbl="{{ OPNsense.unboundplus.dnsbl.type }}"
{% endif %}
{% endif %}
@@ -0,0 +1,7 @@
{% if helpers.exists('OPNsense.unboundplus.dnsbl.enabled') and OPNsense.unboundplus.dnsbl.enabled == '1' %}
{% if helpers.exists('OPNsense.unboundplus.dnsbl.type') and OPNsense.unboundplus.dnsbl.type != '' %}
{% if helpers.exists('OPNsense.unboundplus.dnsbl.whitelists') and OPNsense.unboundplus.dnsbl.whitelists != '' %}
{{ OPNsense.unboundplus.dnsbl.whitelists|default("") }}
{% endif %}
{% endif %}
{% endif %}