net = { '{{SELF_ADDR}}' }
{% if ':' in SELF_ADDR %}
net.outgoing_v6('{{SELF_ADDR}}')
{% else %}
net.outgoing_v4('{{SELF_ADDR}}')
{% endif %}

net.bufsize(4096)

modules = {'stats', 'policy', 'hints'}

-- extra verbose logging for all operations
verbose(true)
policy.add(policy.all(policy.DEBUG_ALWAYS))

-- test. domain is used by some tests, allow it
policy.add(policy.suffix(policy.PASS, {todname('test.')}))
{% if FORWARD_ADDR %}
policy.add(policy.all(policy.FORWARD('{{FORWARD_ADDR}}')))
{% endif %}
cache.size = 2*MB
hints.root({['{{ROOT_NAME}}'] = '{{ROOT_ADDR}}'})
{% if QMIN == "false" %}
option('NO_MINIMIZE', true)
{% else %}
option('NO_MINIMIZE', false)
{% endif %}
{% if DO_NOT_QUERY_LOCALHOST == "false" %}
option('ALLOW_LOCAL', true)
{% else %}
option('ALLOW_LOCAL', false)
{% endif %}

{% if HARDEN_GLUE == "true" %}
mode('normal')
{% else %}
mode('permissive')
{% endif %}

-- make sure that value specified at compile-time does not break tests
trust_anchors.remove('.')
{% for TAF in TRUST_ANCHOR_FILES %}
trust_anchors.add_file('{{TAF}}')
{% endfor %}
trust_anchors.set_insecure({
{% for DI in NEGATIVE_TRUST_ANCHORS %}
"{{DI}}",
{% endfor %}
})

{% if DO_IP6 == "true" %}
net.ipv6 = true
{% else %}
net.ipv6 = false
{% endif %}

{% if DO_IP4 == "true" %}
net.ipv4 = true
{% else %}
net.ipv4 = false
{% endif %}

{% if FEATURES.min_ttl is defined %}
cache.min_ttl({{FEATURES.min_ttl}})
{% endif %}

{% if FEATURES.max_ttl is defined %}
cache.max_ttl({{FEATURES.max_ttl}})
{% endif %}

{% if FEATURES.dns64_prefix is defined %}
modules.load( 'dns64')
dns64.config('{{FEATURES.dns64_prefix}}')
{% endif %}

{% if FEATURES.static_hint_name is defined %}
{% if FEATURES.static_hint_addr is defined %}
hints['{{FEATURES.static_hint_name}}'] = '{{FEATURES.static_hint_addr}}'
{% endif %}
{% endif %}

{% if FEATURES.renumber_src is defined %}
{% if FEATURES.renumber_dst is defined %}
modules.load( 'renumber')
renumber.config({{ '{{' }}'{{FEATURES.renumber_src}}','{{FEATURES.renumber_dst}}' {{ '}}' }})
{% endif %}
{% endif %}

{% for policy in FEATURES.policy %}
{{policy}}
{% endfor %}

{% if FEATURES.view is defined %}
modules.load( 'view')
{% for view in FEATURES.view %}
{{view}}
{% endfor %}
{% endif %}

{% if FEATURES.workarounds is defined %}
modules = { 'workarounds < iterate' }
{% endif %}

-- Disable RFC5011 TA update
if ta_update then
        modules.unload('ta_update')
end

-- Disable RFC8145 signaling, scenario doesn't provide expected ansers
if ta_signal_query then
	modules.unload('ta_signal_query')
end

-- Disable RFC8109 priming, scenario doesn't provide expected ansers
if priming then
	modules.unload('priming')
end

-- Disable this module because it make one priming query.
if detect_time_skew then
	modules.unload('detect_time_skew')
end

-- Self-checks on globals
assert(help() ~= nil)
assert(worker.id ~= nil)
-- Self-checks on facilities
assert(cache.count() == 0)
assert(cache.stats() ~= nil)
assert(cache.backends() ~= nil)
assert(worker.stats() ~= nil)
assert(net.interfaces() ~= nil)
-- Self-checks on loaded stuff
assert(net.list()[1].transport.ip == '{{SELF_ADDR}}')
assert(#modules.list() > 0)
-- Self-check timers
ev = event.recurrent(1 * sec, function (ev) return 1 end)
event.cancel(ev)
ev = event.after(0, function (ev) return 1 end)
