]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
manager: datamodel: templates: jinja2 macros for policy.slice()
authorAleš Mrázek <ales.mrazek@nic.cz>
Wed, 8 Jun 2022 15:51:20 +0000 (17:51 +0200)
committerAleš Mrázek <ales.mrazek@nic.cz>
Wed, 8 Jun 2022 15:51:20 +0000 (17:51 +0200)
manager/knot_resolver_manager/datamodel/templates/config.lua.j2
manager/knot_resolver_manager/datamodel/templates/macros/policy_macros.lua.j2

index 1910f9bb1bdff64a33e48cf5e620212beb1b7b7f..d18c7a9993511d0fc408bdb455ca86ebe2018391 100644 (file)
@@ -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 %}
index f3ba8b79d66da0804dacb791920de4e681c5736a..8ffd83a52497a0b943c3c888973dac591bc3e07e 100644 (file)
@@ -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) -%}