Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unboundplus: move dnsbls from .conf to control #4528

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/etc/inc/plugins.inc.d/unbound.inc
Original file line number Diff line number Diff line change
Expand Up @@ -791,6 +791,7 @@ function unbound_hosts_generate()
unbound_add_host_entries();

killbypid('/var/run/unbound.pid', 'HUP');
configd_run("unbound load_dnsbl", true);
}

function unbound_local_zone_types()
Expand Down
7 changes: 3 additions & 4 deletions src/opnsense/scripts/unbound/download_blacklists.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,15 +129,14 @@ def uri_reader(uri):

syslog.syslog(
syslog.LOG_NOTICE,
'blacklist download %(uri)s (lines: %(lines)d exclude: %(skip)d black: %(blacklist)d' % file_stats
'blacklist download %(uri)s (lines: %(lines)d exclude: %(skip)d black: %(blacklist)d') % file_stats
)

# write out results
with open("/var/unbound/etc/dnsbl.conf", 'w') as unbound_outf:
with open("/var/unbound/etc/dnsbl.list", 'w') as unbound_outf:
if blacklist_items:
unbound_outf.write('server:\n')
for entry in blacklist_items:
unbound_outf.write("local-data: \"%s A 0.0.0.0\"\n" % entry)
unbound_outf.write("%s A 0.0.0.0\n" % entry)

syslog.syslog(syslog.LOG_NOTICE, "blacklist download done in %0.2f seconds (%d records)" % (
time.time() - startup_time, len(blacklist_items)
Expand Down
1 change: 1 addition & 0 deletions src/opnsense/scripts/unbound/unbound_start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,4 @@ if [ ! -f /var/unbound/unbound_control.key ]; then
fi

/usr/local/sbin/unbound -c /var/unbound/unbound.conf
/usr/local/sbin/unbound-control -c /var/unbound/unbound.conf local_datas < /var/unbound/etc/dnsbl.list
10 changes: 8 additions & 2 deletions src/opnsense/service/conf/actions.d/actions_unbound.conf
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ type:script
message:cache %s

[reload]
command:/usr/local/sbin/unbound-control -c /var/unbound/unbound.conf reload
command:/usr/local/sbin/unbound-control -c /var/unbound/unbound.conf reload && /usr/local/sbin/unbound-control -c /var/unbound/unbound.conf local_datas < /var/unbound/etc/dnsbl.list
parameters:
type:script
message:Reloading Unbound
Expand All @@ -53,12 +53,18 @@ type:script
message:Start Unbound

[dnsbl]
command:/usr/local/opnsense/scripts/unbound/download_blacklists.py && /usr/local/sbin/unbound-control -c /var/unbound/unbound.conf reload
command:/usr/local/opnsense/scripts/unbound/download_blacklists.py && /usr/local/sbin/unbound-control -c /var/unbound/unbound.conf reload && /usr/local/sbin/unbound-control -c /var/unbound/unbound.conf local_datas < /var/unbound/etc/dnsbl.list
parameters:
type:script
message:fetching and applying DNSBLs
description: Download Unbound DNSBLs and restart

[load_dnsbl]
command:/usr/local/sbin/unbound-control -c /var/unbound/unbound.conf local_datas < /var/unbound/etc/dnsbl.list
parameters:
type:script
message:Loading dnsbls to unbound

[status]
command:pgrep -q -nF /var/run/unbound.pid && echo "unbound is running" || echo "unbound is not running" ;exit 0
parameters:
Expand Down