+server:
+ workers: 1
network:
interfaces:
- listen:
ip: 127.0.0.1
port: 5353
-server:
- workers: 1
+cache:
+ storage: etc/knot-resolver/cache
--- /dev/null
+from typing import List, Optional
+
+from knot_resolver_manager.datamodel.types import AnyPath, SizeUnit, TimeUnit
+from knot_resolver_manager.utils import SchemaNode
+
+
+class PrefillSchema(SchemaNode):
+ domain: str
+ url: str
+ refresh_interval: TimeUnit = TimeUnit("1d")
+ ca_file: Optional[AnyPath] = None
+
+
+class CacheSchema(SchemaNode):
+ storage: AnyPath = AnyPath("/var/cache/knot-resolver")
+ size_max: SizeUnit = SizeUnit("100M")
+ ttl_min: TimeUnit = TimeUnit("5s")
+ ttl_max: TimeUnit = TimeUnit("6d")
+ ns_timeout: TimeUnit = TimeUnit("1000ms")
+ prefill: Optional[List[PrefillSchema]] = None
+
+ def _validate(self):
+ if self.ttl_min.seconds() >= self.ttl_max.seconds():
+ raise ValueError("'ttl-max' must be larger then 'ttl-min'")
from jinja2 import Environment, Template
from typing_extensions import Literal
+from knot_resolver_manager.datamodel.cache_schema import CacheSchema
from knot_resolver_manager.datamodel.dns64_schema import Dns64Schema
from knot_resolver_manager.datamodel.dnssec_schema import DnssecSchema
from knot_resolver_manager.datamodel.lua_schema import LuaSchema
server: ServerSchema = ServerSchema()
options: OptionsSchema = OptionsSchema()
network: NetworkSchema = NetworkSchema()
+ cache: CacheSchema = CacheSchema()
dnssec: Union[bool, DnssecSchema] = True
dns64: Union[bool, Dns64Schema] = False
lua: LuaSchema = LuaSchema()
server: ServerSchema
options: OptionsSchema
network: NetworkSchema
+ cache: CacheSchema
dnssec: Union[Literal[False], DnssecSchema]
dns64: Union[Literal[False], Dns64Schema]
lua: LuaSchema
{{ "modules.unload('detect_time_jump')" if not cfg.options.time_jump_detection }}
{{ "modules.unload('refuse_nord')" if not cfg.options.refuse_no_rd }}
+-- CACHE section
+cache.open({{ cfg.cache.size_max.bytes() }}, 'lmdb://{{ cfg.cache.storage }}')
+cache.min_ttl({{ cfg.cache.ttl_min.seconds() }})
+cache.max_ttl({{ cfg.cache.ttl_max.seconds() }})
+cache.ns_tout({{ cfg.cache.ns_timeout.millis() }})
+
+-- cache.prefill
+{% if cfg.cache.prefill %}
+modules.load('prefill')
+prefill.config({
+{% for item in cfg.cache.prefill %}
+ ['{{ item.domain }}'] = {
+ url = '{{ item.url }}',
+ interval = {{ item.refresh_interval.seconds() }}
+ {{ "ca_file = '"+item.ca_file+"'," if item.ca_file }}
+ }
+{% endfor %}
+})
+{% endif %}
+
-- DNSSEC section
{% if not cfg.dnssec %}
trust_anchors.remove('.')