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

unbound dnsbl: allow to create inform local-zones #4715

Closed
wants to merge 5 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -11,6 +11,12 @@
<type>select_multiple</type>
<help>Select which kind of DNSBL you want to use.</help>
</field>
<field>
<id>dnsbl.inform</id>
<label>Inform zone type</label>
<type>checkbox</type>
<help>For debugging purposes. Create inform-type local-zone's for blacklisted hosts. Allows to use a 'inform ' keyword to find blacklisted hosts lookups.</help>
</field>
<field>
<id>dnsbl.lists</id>
<label>URLs of Blacklists</label>
Expand Down
4 changes: 4 additions & 0 deletions src/opnsense/mvc/app/models/OPNsense/Unboundplus/Dnsbl.xml
Expand Up @@ -50,6 +50,10 @@
<lists type="CSVListField">
<Required>N</Required>
</lists>
<inform type="BooleanField">
<default>0</default>
<Required>Y</Required>
</inform>
<whitelists type="CSVListField">
<Required>N</Required>
</whitelists>
Expand Down
8 changes: 7 additions & 1 deletion src/opnsense/scripts/unbound/download_blacklists.py
Expand Up @@ -129,14 +129,20 @@ 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
)

inform = False
if cnf.has_section('inform'):
inform = True

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

syslog.syslog(syslog.LOG_NOTICE, "blacklist download done in %0.2f seconds (%d records)" % (
Expand Down
Expand Up @@ -55,12 +55,16 @@ custom_{{loop.index}}={{uri}}
# exclude localhost entries
default_pattern_1=.*localhost$
# exclude non domain entries
default_pattern_2=^(?![a-zA-Z\d]).*
default_pattern_2=^(?![a-zA-Z_\d]).*
{% if not helpers.empty('OPNsense.unboundplus.dnsbl.whitelists')%}
# user defined
{% for pattern in OPNsense.unboundplus.dnsbl.whitelists.split(',') %}
custom_pattern_{{loop.index}}={{ pattern }}
{% endfor %}
{% endif %}
{% if not helpers.empty('OPNsense.unboundplus.dnsbl.inform')%}
[inform]
inform=yes
{% endif %}

{% endif %}