import os
+import pathlib
import sys
from typing import Dict, Optional, Union
return obj.dns64
def render_lua(self) -> str:
- return _MAIN_TEMPLATE.render(cfg=self) # pyright: reportUnknownMemberType=false
+ # FIXME the `cwd` argument is used only for configuring control socket path
+ # it should be removed and relative path used instead as soon as issue
+ # https://gitlab.nic.cz/knot/knot-resolver/-/issues/720 is fixed
+ return _MAIN_TEMPLATE.render(cfg=self, cwd=os.getcwd()) # pyright: reportUnknownMemberType=false
{% if cfg.lua.script %}
{{ cfg.lua.script }}
{% endif %}
+
+-- static config used for manager's needs
+local ffi = require('ffi')
+local id = os.getenv('SYSTEMD_INSTANCE')
+if not id then
+ log_err(ffi.C.LOG_GRP_SYSTEM, 'environment variable $SYSTEMD_INSTANCE not set, which should not have been possible due to running under manager')
+else
+ -- Bind to control socket in CWD (= rundir in config)
+ -- FIXME replace with relative path after fixing https://gitlab.nic.cz/knot/knot-resolver/-/issues/720
+ local path = '{{ cwd }}/control/'..id
+ log_warn(ffi.C.LOG_GRP_SYSTEM, 'path = ' .. path)
+ local ok, err = pcall(net.listen, path, nil, { kind = 'control' })
+ if not ok then
+ log_warn(ffi.C.LOG_GRP_NETWORK, 'bind to '..path..' failed '..err)
+ end
+end