From: Aleš Mrázek Date: Wed, 8 Jun 2022 15:51:20 +0000 (+0200) Subject: manager: datamodel: templates: jinja2 macros for policy.slice() X-Git-Tag: v6.0.0a1~34^2~8 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=366bda0c69caa83ae3e079d46bff542b0889bfc5;p=thirdparty%2Fknot-resolver.git manager: datamodel: templates: jinja2 macros for policy.slice() --- diff --git a/manager/knot_resolver_manager/datamodel/templates/config.lua.j2 b/manager/knot_resolver_manager/datamodel/templates/config.lua.j2 index 1910f9bb1..d18c7a999 100644 --- a/manager/knot_resolver_manager/datamodel/templates/config.lua.j2 +++ b/manager/knot_resolver_manager/datamodel/templates/config.lua.j2 @@ -9,51 +9,54 @@ modules.load('nsid') nsid.name('{{ cfg.nsid }}_' .. worker.id) {% endif %} --- LOGGING section +-- LOGGING section ---------------------------------- {% include "logging.lua.j2" %} --- SUPERVISOR section +-- SUPERVISOR section ------------------------------- {% include "supervisor.lua.j2" %} --- WEBMGMT section +-- WEBMGMT section ---------------------------------- {% include "webmgmt.lua.j2" %} --- OPTIONS section +-- OPTIONS section ---------------------------------- {% include "options.lua.j2" %} --- NETWORK section +-- NETWORK section ---------------------------------- {% include "network.lua.j2" %} --- STATIC-HINTS section +-- STATIC-HINTS section ----------------------------- {% include "static_hints.lua.j2" %} --- VIEWS section +-- VIEWS section ------------------------------------ {% include "views.lua.j2" %} --- POLICY section +-- SLICES section ----------------------------------- +{% include "slices.lua.j2" %} + +-- POLICY section ----------------------------------- {% include "policy.lua.j2" %} --- RPZ section +-- RPZ section -------------------------------------- {% include "rpz.lua.j2" %} --- STUB-ZONES section +-- STUB-ZONES section ------------------------------- {% include "stub_zones.lua.j2" %} --- FORWARD-ZONES section +-- FORWARD-ZONES section ---------------------------- {% include "forward_zones.lua.j2" %} --- CACHE section +-- CACHE section ------------------------------------ {% include "cache.lua.j2" %} --- DNSSEC section +-- DNSSEC section ----------------------------------- {% include "dnssec.lua.j2" %} --- DNS64 section +-- DNS64 section ------------------------------------ {% include "dns64.lua.j2" %} {% endif %} --- LUA section +-- LUA section -------------------------------------- -- Custom Lua code cannot be validated {% if cfg.lua.script_file %} diff --git a/manager/knot_resolver_manager/datamodel/templates/macros/policy_macros.lua.j2 b/manager/knot_resolver_manager/datamodel/templates/macros/policy_macros.lua.j2 index f3ba8b79d..8ffd83a52 100644 --- a/manager/knot_resolver_manager/datamodel/templates/macros/policy_macros.lua.j2 +++ b/manager/knot_resolver_manager/datamodel/templates/macros/policy_macros.lua.j2 @@ -12,6 +12,27 @@ policy.add({{ rule }}) {%- endmacro %} +{# Slice #} + +{% macro policy_slice_randomize_psl(seed='') -%} +{%- if seed == '' -%} +policy.slice_randomize_psl() +{%- else -%} +policy.slice_randomize_psl(seed={{ seed }}) +{%- endif -%} +{%- endmacro %} + +{% macro policy_slice(func, actions) -%} +policy.slice( +{%- if func == 'randomize-psl' -%} +policy.slice_randomize_psl() +{%- else -%} +policy.slice_randomize_psl() +{%- endif -%} +,{{ actions }}) +{%- endmacro %} + + {# Flags #} {% macro policy_flags(flags) -%}