{%
  set predefined = {
      "aa": "https://adaway.org/hosts.txt",
      "oisd0": "https://small.oisd.nl/domainswild",
      "oisd1": "https://big.oisd.nl/domainswild",
      "oisd2": "https://nsfw.oisd.nl/domainswild",
      "ag": "https://v.firebog.net/hosts/AdguardDNS.txt",
      "bla0": "https://blocklistproject.github.io/Lists/alt-version/abuse-nl.txt",
      "bla": "https://blocklistproject.github.io/Lists/alt-version/ads-nl.txt",
      "blc": "https://blocklistproject.github.io/Lists/alt-version/crypto-nl.txt",
      "bld": "https://blocklistproject.github.io/Lists/alt-version/drugs-nl.txt",
      "blf0": "https://blocklistproject.github.io/Lists/alt-version/facebook-nl.txt",
      "blf": "https://blocklistproject.github.io/Lists/alt-version/fraud-nl.txt",
      "blg": "https://blocklistproject.github.io/Lists/alt-version/gambling-nl.txt",
      "blm": "https://blocklistproject.github.io/Lists/alt-version/malware-nl.txt",
      "blp": "https://blocklistproject.github.io/Lists/alt-version/phishing-nl.txt",
      "blp0": "https://blocklistproject.github.io/Lists/alt-version/piracy-nl.txt",
      "blp1": "https://blocklistproject.github.io/Lists/alt-version/porn-nl.txt",
      "blr": "https://blocklistproject.github.io/Lists/alt-version/ransomware-nl.txt",
      "blr0": "https://blocklistproject.github.io/Lists/alt-version/redirect-nl.txt",
      "bls": "https://blocklistproject.github.io/Lists/alt-version/scam-nl.txt",
      "blt": "https://blocklistproject.github.io/Lists/alt-version/tiktok-nl.txt",
      "blt0": "https://blocklistproject.github.io/Lists/alt-version/torrent-nl.txt",
      "blt1": "https://blocklistproject.github.io/Lists/alt-version/tracking-nl.txt",
      "bly": "https://blocklistproject.github.io/Lists/alt-version/youtube-nl.txt",
      "el": "https://v.firebog.net/hosts/Easylist.txt",
      "ep": "https://v.firebog.net/hosts/Easyprivacy.txt",
      "sb": "https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts",
      "yy": "http://pgl.yoyo.org/adservers/serverlist.php?hostformat=nohtml&mimetype=plaintext",
      "atf": "https://threatfox.abuse.ch/downloads/hostfile",
      "hgz001": "https://raw.githubusercontent.com/hagezi/dns-blocklists/main/wildcard/light.txt",
      "hgz002": "https://raw.githubusercontent.com/hagezi/dns-blocklists/main/wildcard/multi.txt",
      "hgz003": "https://raw.githubusercontent.com/hagezi/dns-blocklists/main/wildcard/pro.txt",
      "hgz004": "https://raw.githubusercontent.com/hagezi/dns-blocklists/main/wildcard/pro.mini.txt",
      "hgz005": "https://raw.githubusercontent.com/hagezi/dns-blocklists/main/wildcard/pro.plus.txt",
      "hgz006": "https://raw.githubusercontent.com/hagezi/dns-blocklists/main/wildcard/pro.plus.mini.txt",
      "hgz007": "https://raw.githubusercontent.com/hagezi/dns-blocklists/main/wildcard/ultimate.txt",
      "hgz008": "https://raw.githubusercontent.com/hagezi/dns-blocklists/main/wildcard/ultimate.mini.txt",
      "hgz009": "https://raw.githubusercontent.com/hagezi/dns-blocklists/main/wildcard/fake.txt",
      "hgz010": "https://raw.githubusercontent.com/hagezi/dns-blocklists/main/wildcard/popupads.txt",
      "hgz011": "https://raw.githubusercontent.com/hagezi/dns-blocklists/main/wildcard/tif.txt",
      "hgz012": "https://raw.githubusercontent.com/hagezi/dns-blocklists/main/wildcard/tif.medium.txt",
      "hgz013": "https://raw.githubusercontent.com/hagezi/dns-blocklists/main/wildcard/tif.mini.txt",
      "hgz014": "https://raw.githubusercontent.com/hagezi/dns-blocklists/main/wildcard/doh-vpn-proxy-bypass.txt",
      "hgz015": "https://raw.githubusercontent.com/hagezi/dns-blocklists/main/wildcard/nosafesearch.txt",
      "hgz016": "https://raw.githubusercontent.com/hagezi/dns-blocklists/main/wildcard/dyndns.txt",
      "hgz017": "https://raw.githubusercontent.com/hagezi/dns-blocklists/main/wildcard/hoster.txt",
      "hgz018": "https://raw.githubusercontent.com/hagezi/dns-blocklists/main/wildcard/anti.piracy.txt",
      "hgz019": "https://raw.githubusercontent.com/hagezi/dns-blocklists/main/wildcard/gambling.txt",
      "hgz020": "https://raw.githubusercontent.com/hagezi/dns-blocklists/main/wildcard/gambling.medium.txt",
      "hgz021": "https://raw.githubusercontent.com/hagezi/dns-blocklists/main/wildcard/gambling.mini.txt",
      "*** below fields are deprecated, but still exist. Not selectable anymore ***":"",
      "sa": "https://s3.amazonaws.com/lists.disconnect.me/simple_ad.txt",
      "st": "https://s3.amazonaws.com/lists.disconnect.me/simple_tracking.txt",
      "nc": "https://raw.githubusercontent.com/hoshsadiq/adblock-nocoin-list/master/hosts.txt",
      "ws": "https://raw.githubusercontent.com/crazy-max/WindowsSpyBlocker/master/data/hosts/spy.txt",
      "wsu": "https://raw.githubusercontent.com/crazy-max/WindowsSpyBlocker/master/data/hosts/update.txt",
      "wse": "https://raw.githubusercontent.com/crazy-max/WindowsSpyBlocker/master/data/hosts/extra.txt",
      "pa": "https://raw.githubusercontent.com/chadmayfield/my-pihole-blocklists/master/lists/pi_blocklist_porn_all.list",
      "pt": "https://raw.githubusercontent.com/chadmayfield/pihole-blocklists/master/lists/pi_blocklist_porn_top1m.list"
  }
%}
{%  if not helpers.empty('OPNsense.unboundplus.dnsbl.enabled') %}
[settings]
rcode={% if not helpers.empty('OPNsense.unboundplus.dnsbl.nxdomain') %}NXDOMAIN{%else%}NOERROR{%endif%}

address={{OPNsense.unboundplus.dnsbl.address|default('0.0.0.0')}}

[blocklists]
{%    if not helpers.empty('OPNsense.unboundplus.dnsbl.type') %}
{%      for shortcode in OPNsense.unboundplus.dnsbl.type.split(',') %}
{%        if shortcode in predefined %}
predefined_{{ shortcode }}={{ predefined[shortcode] }}
{%        else %}
#shortcode=##not_found##
{%        endif %}
{%      endfor %}
{%    endif %}
{%    if not helpers.empty('OPNsense.unboundplus.dnsbl.lists') %}
{%      for uri in OPNsense.unboundplus.dnsbl.lists.split(',') %}
custom_{{loop.index}}={{uri}}
{%      endfor %}
{%    endif %}

[exclude]
# exclude localhost entries
default_pattern_1=.*localhost$
{%    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 %}

[include]
{%    if not helpers.empty('OPNsense.unboundplus.dnsbl.blocklists')%}
# user defined
{%      for pattern in OPNsense.unboundplus.dnsbl.blocklists.split(',') %}
custom_pattern_{{loop.index}}={{ pattern }}
{%      endfor %}
{%    endif %}
{%    if not helpers.empty('OPNsense.unboundplus.dnsbl.wildcards')%}
# wildcards
{%      for pattern in OPNsense.unboundplus.dnsbl.wildcards.split(',') %}
wildcard_pattern_{{loop.index}}={{ pattern }}
{%      endfor %}
{%    endif %}
{%  endif %}
