summaryrefslogtreecommitdiffstats
path: root/manager/knot_resolver_manager/datamodel/templates/static_hints.lua.j2
blob: 130facf9a31de84f38bdfc16b82565161ba2353f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
{% if cfg.static_hints.etc_hosts or cfg.static_hints.root_hints_file or cfg.static_hints.hints_files or cfg.static_hints.root_hints or cfg.static_hints.hints %}
modules.load('hints > iterate')

{% if cfg.static_hints.ttl %}
-- static-hints.ttl
hints.ttl({{ cfg.static_hints.ttl.seconds()|string }})
{% endif %}

-- static-hints.no-data
hints.use_nodata({{ 'true' if cfg.static_hints.nodata else 'false' }})

{% if cfg.static_hints.etc_hosts %}
-- static-hints.etc-hosts
hints.add_hosts('/etc/hosts')
{% endif %}

{% if cfg.static_hints.root_hints_file %}
-- static-hints.root-hints-file
hints.root_file('{{ cfg.static_hints.root_hints_file }}')
{% endif %}

{% if cfg.static_hints.hints_files %}
-- static-hints.hints-files
{% for item in cfg.static_hints.hints_files %}
hints.add_hosts('{{ item }}')
{% endfor %}
{% endif %}

{% if cfg.static_hints.root_hints %}
-- static-hints.root-hints
hints.root({
{% for name, addrs in cfg.static_hints.root_hints.items() %}
['{{ name.punycode() }}'] = {
{% for addr in addrs %}
        '{{ addr }}',
{% endfor %}
    },
{% endfor %}
})
{% endif %}

{% if cfg.static_hints.hints %}
-- static-hints.hints
{% for name, addrs in cfg.static_hints.hints.items() %}
{% for addr in addrs %}
hints.set('{{ name.punycode() }} {{ addr }}')
{% endfor %}
{% endfor %}
{% endif %}

{% endif %}