{% macro set_boolean(name) -%}
    {% if name == '1' %}yes{%else%}no{%endif%}
{%- endmacro %}
{% macro set_numeric_value(key, value) -%}
    {% if value is defined and not empty %}{{ key }}: {{ value }}{% endif %}
{%- endmacro %}
{% if helpers.exists('OPNsense.unboundplus.advanced') %}
hide-identity: {{ set_boolean(OPNsense.unboundplus.advanced.hideidentity) }}
hide-version: {{ set_boolean(OPNsense.unboundplus.advanced.hideversion) }}
prefetch: {{ set_boolean(OPNsense.unboundplus.advanced.prefetch) }}
prefetch-key: {{ set_boolean(OPNsense.unboundplus.advanced.prefetchkey) }}
harden-dnssec-stripped: {{ set_boolean(OPNsense.unboundplus.advanced.dnssecstripped) }}
serve-expired: {{ set_boolean(OPNsense.unboundplus.advanced.serveexpired) }}
{{ set_numeric_value('serve-expired-reply-ttl', OPNsense.unboundplus.advanced.serveexpiredreplyttl) }}
{{ set_numeric_value('serve-expired-ttl', OPNsense.unboundplus.advanced.serveexpiredttl) }}
serve-expired-ttl-reset: {{ set_boolean(OPNsense.unboundplus.advanced.serveexpiredttlreset) }}
{{ set_numeric_value('serve-expired-client-timeout', OPNsense.unboundplus.advanced.serveexpiredclienttimeout) }}
qname-minimisation-strict: {{ set_boolean(OPNsense.unboundplus.advanced.qnameminstrict) }}
extended-statistics: {{ set_boolean(OPNsense.unboundplus.advanced.extendedstatistics) }}
log-queries: {{ set_boolean(OPNsense.unboundplus.advanced.logqueries) }}
log-replies: {{ set_boolean(OPNsense.unboundplus.advanced.logreplies) }}
log-tag-queryreply: {{ set_boolean(OPNsense.unboundplus.advanced.logtagqueryreply) }}
log-servfail: {{ set_boolean(OPNsense.unboundplus.advanced.logservfail) }}
log-local-actions: {{ set_boolean(OPNsense.unboundplus.advanced.loglocalactions) }}
{{ set_numeric_value('verbosity', OPNsense.unboundplus.advanced.logverbosity) }}
{{ set_numeric_value('msg-cache-size', OPNsense.unboundplus.advanced.msgcachesize) }}
{{ set_numeric_value('rrset-cache-size', OPNsense.unboundplus.advanced.rrsetcachesize) }}
{{ set_numeric_value('outgoing-num-tcp', OPNsense.unboundplus.advanced.outgoingnumtcp) }}
{{ set_numeric_value('incoming-num-tcp', OPNsense.unboundplus.advanced.incomingnumtcp) }}
{{ set_numeric_value('num-queries-per-thread', OPNsense.unboundplus.advanced.numqueriesperthread) }}
{{ set_numeric_value('outgoing-range', OPNsense.unboundplus.advanced.outgoingrange) }}
{{ set_numeric_value('jostle-timeout', OPNsense.unboundplus.advanced.jostletimeout) }}
{{ set_numeric_value('cache-max-ttl', OPNsense.unboundplus.advanced.cachemaxttl) }}
{{ set_numeric_value('cache-max-negative-ttl', OPNsense.unboundplus.advanced.cachemaxnegativettl) }}
{{ set_numeric_value('cache-min-ttl', OPNsense.unboundplus.advanced.cacheminttl) }}
{{ set_numeric_value('infra-host-ttl', OPNsense.unboundplus.advanced.infrahostttl) }}
infra-keep-probing: {{ set_boolean(OPNsense.unboundplus.advanced.infrakeepprobing) }}
{{ set_numeric_value('infra-cache-numhosts', OPNsense.unboundplus.advanced.infracachenumhosts) }}
{{ set_numeric_value('unwanted-reply-threshold', OPNsense.unboundplus.advanced.unwantedreplythreshold) }}
{{ set_numeric_value('val-log-level', OPNsense.unboundplus.advanced.valloglevel) }}
{% if not helpers.empty('OPNsense.unboundplus.advanced.privatedomain') %}
{%    for privatedomain in OPNsense.unboundplus.advanced.privatedomain.split(',') %}
private-domain: {{ privatedomain }}
{%    endfor %}
{% endif %}
{% if not helpers.empty('OPNsense.unboundplus.advanced.insecuredomain') %}
{%    for insecuredomain in OPNsense.unboundplus.advanced.insecuredomain.split(',') %}
domain-insecure: {{ insecuredomain }}
{%    endfor %}
{% endif %}
{% endif %}
