from knot_resolver_manager.datamodel.network_schema import NetworkSchema
from knot_resolver_manager.datamodel.options_schema import OptionsSchema
from knot_resolver_manager.datamodel.server_schema import ServerSchema
+from knot_resolver_manager.datamodel.static_hints_schema import StaticHintsSchema
from knot_resolver_manager.utils import SchemaNode
server: ServerSchema = ServerSchema()
options: OptionsSchema = OptionsSchema()
network: NetworkSchema = NetworkSchema()
+ static_hints: StaticHintsSchema = StaticHintsSchema()
cache: CacheSchema = CacheSchema()
dnssec: Union[bool, DnssecSchema] = True
dns64: Union[bool, Dns64Schema] = False
server: ServerSchema
options: OptionsSchema
network: NetworkSchema
+ static_hints: StaticHintsSchema
cache: CacheSchema
dnssec: Union[Literal[False], DnssecSchema]
dns64: Union[Literal[False], Dns64Schema]
{{ "'workarounds < iterate'," if cfg.options.violators_workarounds }}
{{ "'serve_stale < cache'," if cfg.options.serve_stale }}
{{ "dns64 = '"+cfg.dns64.prefix+"'," if cfg.dns64 }}
+ 'hints > iterate'
}
-- SERVER section
{{ "modules.unload('detect_time_jump')" if not cfg.options.time_jump_detection }}
{{ "modules.unload('refuse_nord')" if not cfg.options.refuse_no_rd }}
+-- STATIC-HINTS section
+{{ "hints.ttl("+cfg.static_hints.ttl.seconds()|string+")" if cfg.static_hints.ttl }}
+hints.use_nodata({{ 'true' if cfg.static_hints.no_data else 'false' }})
+{{ "hints.add_hosts()" if cfg.static_hints.etc_hosts }}
+{{ "hints.root_file('"+cfg.static_hints.root_hints_file+"')" if cfg.static_hints.root_hints_file }}
+
+-- static-hints.hints-files
+{% if cfg.static_hints.hints_files %}
+{% for item in cfg.static_hints.hints_files %}
+hints.add_hosts('{{ item }}')
+{% endfor %}
+{% endif %}
+
+-- static-hints.root-hints
+{% if cfg.static_hints.root_hints %}
+hints.root({
+{% for item in cfg.static_hints.root_hints %}
+ ['{{ item.name }}'] = {
+{% for addr in item.addresses %}
+ '{{ addr }}',
+{% endfor %}
+ },
+{% endfor %}
+})
+{% endif %}
+
+-- static-hints.hints
+{% if cfg.static_hints.hints %}
+{% for item in cfg.static_hints.hints %}
+{% for addr in item.addresses %}
+hints.set('{{ item.name }} {{ addr }}')
+{% endfor %}
+{% endfor %}
+{% endif %}
+
-- CACHE section
cache.open({{ cfg.cache.size_max.bytes() }}, 'lmdb://{{ cfg.cache.storage }}')
cache.min_ttl({{ cfg.cache.ttl_min.seconds() }})
--- /dev/null
+from typing import List, Optional
+
+from knot_resolver_manager.datamodel.types import AnyPath, TimeUnit
+from knot_resolver_manager.utils import SchemaNode
+
+
+class Hint(SchemaNode):
+ name: str
+ addresses: List[str]
+
+
+class StaticHintsSchema(SchemaNode):
+ ttl: Optional[TimeUnit] = None
+ no_data: bool = True
+ etc_hosts: bool = False
+ root_hints_file: Optional[AnyPath] = None
+ hints_files: Optional[List[AnyPath]] = None
+ root_hints: Optional[List[Hint]] = None
+ hints: Optional[List[Hint]] = None