server:
- instances: 4
+ instances: 1
+
+dns64:
+ prefix: "64:ff9b::/96"
+
lua:
script: |
"""
--- script from 'Lua' configuration section
-{% if cfg.lua.script -%}
+modules = {
+{%- if cfg.dns64 %}
+ dns64 = '{{ cfg.dns64.prefix }}' } -- dns64
+{%- endif %}
+}
+
+-- lua
+{%- if cfg.lua.script %}
{{ cfg.lua.script }}
-{% endif -%}
\ No newline at end of file
+{%- endif %}
\ No newline at end of file
COPY ./config/knot-resolver-manager.service /etc/systemd/system
# Copy knot-resolver-manager YAML configuration file
-COPY ./config/kres-manager.yaml /etc/knot-resolver/
+COPY ./config/kres-manager.yaml /etc/knot-resolver
# Copy only requirements, to cache them in docker layer
# no poetry.lock, because here we have a different python version
# Create knot-resolver-manager systemd service
COPY ./config/knot-resolver-manager.service /etc/systemd/system
+# Copy knot-resolver-manager YAML configuration file
+COPY ./config/kres-manager.yaml /etc/knot-resolver
+
# Copy only requirements, to cache them in docker layer
COPY ./poetry.lock ./pyproject.toml ./yarn.lock ./package.json /code/
"server": {
"instances": 1
},
+ "dns64": {
+ "prefix": "64:ff9b::/96"
+ },
"lua": {
"script_list": [
"-- SPDX-License-Identifier: CC0-1.0",
"net.listen('::1', 53, { kind = 'dns', freebind = true })",
"net.listen('::1', 853, { kind = 'tls', freebind = true })",
"--net.listen('::1', 443, { kind = 'doh2' })",
- "-- Load useful modules","modules = {",
- "'hints > iterate', -- Load /etc/hosts and allow custom root hints",
- "'stats', -- Track internal statistics",
- "'predict', -- Prefetch expiring/frequent records",
+ "-- Load useful modules",
+ "modules = {",
+ " 'hints > iterate', -- Load /etc/hosts and allow custom root hints",
+ " 'stats', -- Track internal statistics",
+ " 'predict', -- Prefetch expiring/frequent records",
"}",
"-- Cache size",
"cache.size = 100 * MB"
# assert that any kresd process is running
systemctl status | grep kresd
+
+# see the rendered Lua configuration
+echo "Lua config in '/etc/knot-resolver/kresd.conf':"
+cat /etc/knot-resolver/kresd.conf
from .datamodel import KresConfig
_LUA_TEMPLATE_STR = """
-{% if lua_config -%}
+modules = {
+{%- if cfg.dns64 %}
+ dns64 = '{{ cfg.dns64.prefix }}' } -- dns64
+{%- endif %}
+}
+
+-- lua
+{%- if cfg.lua.script %}
{{ cfg.lua.script }}
-{% endif -%}
+{%- endif %}
"""
_ENV = Environment(enable_async=True)
from knot_resolver_manager.utils.dataclasses_parservalidator import DataclassParserValidatorMixin
from .compat.dataclasses import dataclass
+from .datamodel_types import IPV6_PREFIX_96
class DataValidationError(Exception):
instances: int = 1
def validate(self):
- if self.instances < 0:
- raise DataValidationError("Number of workers must be non-negative")
+ if not 0 < self.instances <= 256:
+ raise DataValidationError("number of kresd 'instances' must be in range 1..256")
+
+
+@dataclass
+class Dns64Config(DataclassParserValidatorMixin):
+ prefix: str = "64:ff9b::"
+
+ def validate(self):
+ if not bool(IPV6_PREFIX_96.match(self.prefix)):
+ raise DataValidationError("'dns64.prefix' must be valid IPv6 address and '/96' CIDR")
@dataclass
@dataclass
class KresConfig(DataclassParserValidatorMixin):
server: ServerConfig = ServerConfig()
+ dns64: Optional[Dns64Config] = None
lua: LuaConfig = LuaConfig()
def validate(self):
- pass
+ self.server.validate()
+ if self.dns64 is not None:
+ self.dns64.validate()
+ self.lua.validate()
--- /dev/null
+import re
+
+IPV4ADDR = re.compile(r"^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$")
+
+IPV6_PREFIX_96 = re.compile(r"^([0-9A-Fa-f]{1,4}:){2}:($|/96)$")