diff --git a/dns/unbound-plus/Makefile b/dns/unbound-plus/Makefile index 6bd8c6fd8..6505c828c 100644 --- a/dns/unbound-plus/Makefile +++ b/dns/unbound-plus/Makefile @@ -1,5 +1,5 @@ PLUGIN_NAME= unbound-plus -PLUGIN_VERSION= 0.3 +PLUGIN_VERSION= 0.4 PLUGIN_COMMENT= Unbound additions PLUGIN_MAINTAINER= m.muenz@gmail.com PLUGIN_DEVEL= yes diff --git a/dns/unbound-plus/src/opnsense/mvc/app/controllers/OPNsense/Unboundplus/forms/dnsbl.xml b/dns/unbound-plus/src/opnsense/mvc/app/controllers/OPNsense/Unboundplus/forms/dnsbl.xml index 2f7626943..6fd6fc607 100644 --- a/dns/unbound-plus/src/opnsense/mvc/app/controllers/OPNsense/Unboundplus/forms/dnsbl.xml +++ b/dns/unbound-plus/src/opnsense/mvc/app/controllers/OPNsense/Unboundplus/forms/dnsbl.xml @@ -25,6 +25,6 @@ select_multiple true - List of domains to whitelist. You can use regex expressions. + List of domains to whitelist. You can use regular expressions. diff --git a/dns/unbound-plus/src/opnsense/scripts/OPNsense/Unboundplus/dnsbl.py b/dns/unbound-plus/src/opnsense/scripts/OPNsense/Unboundplus/dnsbl.py index 08ac8503a..1b6acba98 100755 --- a/dns/unbound-plus/src/opnsense/scripts/OPNsense/Unboundplus/dnsbl.py +++ b/dns/unbound-plus/src/opnsense/scripts/OPNsense/Unboundplus/dnsbl.py @@ -81,8 +81,8 @@ def parse_line(line): def process_url(url): """ Reads and parses blacklisted domains from URL into BL set. """ - print(f"Processing BL items from: {url}") - + print(f"Processing BL items from: {url}") + try: http = urllib3.PoolManager() r = http.request('GET', url) @@ -111,10 +111,10 @@ def save_config_file(): exit(1) def load_list(path, separator=None): - """ Reads file with specified path into set to ensure unique values. + """ Reads file with specified path into set to ensure unique values. Splits lines with defined separator. If sperator==None no split is performed. """ result = set() - + try: with open(path, 'r') as file: for line in file.readlines(): @@ -162,7 +162,7 @@ def load_predefined_lists(): for type in first: types.add(type) break - + print(f"Loaded {len(types)} predefined blacklists URLs") for type in types: @@ -185,9 +185,9 @@ if __name__ == "__main__": t.start() for t in threads: t.join() - + save_config_file() print("Restarting unbound service") subprocess.Popen(["pluginctl", "-s", "unbound", "restart"]) - exit(0) \ No newline at end of file + exit(0) diff --git a/dns/unbound-plus/src/opnsense/service/conf/actions.d/actions_unboundplus.conf b/dns/unbound-plus/src/opnsense/service/conf/actions.d/actions_unboundplus.conf index 86d4c3f0c..e354a4e12 100644 --- a/dns/unbound-plus/src/opnsense/service/conf/actions.d/actions_unboundplus.conf +++ b/dns/unbound-plus/src/opnsense/service/conf/actions.d/actions_unboundplus.conf @@ -2,11 +2,5 @@ command:/usr/local/opnsense/scripts/OPNsense/Unboundplus/dnsbl.py parameters: type:script -message:fetching DNSBLs - -[dnsblcron] -command:/usr/local/opnsense/scripts/OPNsense/Unboundplus/dnsbl.py -parameters: -type:script -message:fetching DNSBLs and restart Unbound +message:fetching and applying DNSBLs description: Download Unbound DNSBLs and restart 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 edd98110e..d7f6d3cbb 100644 --- a/dns/unbound-plus/src/opnsense/service/templates/OPNsense/Unboundplus/+TARGETS +++ b/dns/unbound-plus/src/opnsense/service/templates/OPNsense/Unboundplus/+TARGETS @@ -1,4 +1,4 @@ dnsbl.inc:/var/unbound/etc/dnsbl.inc whitelist.inc:/var/unbound/etc/whitelist.inc miscellaneous.conf:/var/unbound/etc/miscellaneous.conf -lists.inc:/var/unbound/etc/lists.inc \ No newline at end of file +lists.inc:/var/unbound/etc/lists.inc diff --git a/dns/unbound-plus/src/opnsense/service/templates/OPNsense/Unboundplus/whitelist.inc b/dns/unbound-plus/src/opnsense/service/templates/OPNsense/Unboundplus/whitelist.inc index 04cde11c3..925e665f7 100644 --- a/dns/unbound-plus/src/opnsense/service/templates/OPNsense/Unboundplus/whitelist.inc +++ b/dns/unbound-plus/src/opnsense/service/templates/OPNsense/Unboundplus/whitelist.inc @@ -1,5 +1,5 @@ -{% if helpers.exists('OPNsense.unboundplus.dnsbl.enabled') and OPNsense.unboundplus.dnsbl.enabled == '1' %} -{% if helpers.exists('OPNsense.unboundplus.dnsbl.whitelists') and OPNsense.unboundplus.dnsbl.whitelists != '' %} +{% if helpers.exists('OPNsense.unboundplus.dnsbl.enabled') and OPNsense.unboundplus.dnsbl.enabled == '1' %} +{% if helpers.exists('OPNsense.unboundplus.dnsbl.whitelists') and OPNsense.unboundplus.dnsbl.whitelists != '' %} {{ OPNsense.unboundplus.dnsbl.whitelists|default("") }} -{% endif %} -{% endif %} +{% endif %} +{% endif %}