]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
manager: datamodel: template/macros for local_data_schema
authorAleš Mrázek <ales.mrazek@nic.cz>
Thu, 6 Apr 2023 13:28:50 +0000 (15:28 +0200)
committerAleš Mrázek <ales.mrazek@nic.cz>
Fri, 9 Jun 2023 11:54:07 +0000 (11:54 +0000)
manager/knot_resolver_manager/datamodel/templates/config.lua.j2
manager/knot_resolver_manager/datamodel/templates/local_data.lua.j2
manager/knot_resolver_manager/datamodel/templates/macros/local_data_macros.lua.j2 [new file with mode: 0644]

index 3b51bea777d3598a09476d9b4888d0433916c9f8..bb7e5e34101843f0fa9d79f355e8780547e33c28 100644 (file)
@@ -12,6 +12,9 @@ nsid.name('{{ cfg.nsid }}_' .. worker.id)
 -- LOGGING section ----------------------------------
 {% include "logging.lua.j2" %}
 
+-- MONITORING section -------------------------------
+{% include "monitoring.lua.j2" %}
+
 -- WEBMGMT section ----------------------------------
 {% include "webmgmt.lua.j2" %}
 
@@ -24,8 +27,8 @@ nsid.name('{{ cfg.nsid }}_' .. worker.id)
 -- VIEWS section ------------------------------------
 {# {% include "views.lua.j2" %} #}
 
--- LOCAL-DATA section -----------------------------
-{% include "local_data.lua.j2" %}
+-- LOCAL-DATA section -------------------------------
+{# {% include "local_data.lua.j2" %} #}
 
 -- SLICES section -----------------------------------
 {# {% include "slices.lua.j2" %} #}
@@ -36,7 +39,7 @@ nsid.name('{{ cfg.nsid }}_' .. worker.id)
 -- RPZ section --------------------------------------
 {# {% include "rpz.lua.j2" %} #}
 
--- FORWARD section ----------------------------
+-- FORWARD section ----------------------------------
 {% include "forward.lua.j2" %}
 
 -- CACHE section ------------------------------------
@@ -61,6 +64,3 @@ nsid.name('{{ cfg.nsid }}_' .. worker.id)
 {% if cfg.lua.script %}
 {{ cfg.lua.script }}
 {% endif %}
-
--- manager's monitoring configuration
-{% include "monitoring.lua.j2" %}
\ No newline at end of file
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..dbab321d78b6c333443ce70837f1801985151f1b 100644 (file)
@@ -0,0 +1,39 @@
+{% from 'macros/common_macros.lua.j2' import string_table %}
+{% from 'macros/policy_macros.lua.j2' import policy_get_tagset, policy_todname %}
+{% from 'macros/local_data_macros.lua.j2' import local_data_emptyzone, local_data_nxdomain %}
+
+local C = require('ffi').C
+
+
+{# TODO: implemented all other options/features from local_data_schema #}
+
+
+{% for subtree in cfg.local_data.subnets %}
+
+{# IF subtree.roots is not None #}
+{% if subtree.roots -%}
+{%- for root in subtree.roots -%}
+
+
+{% if subtree.type == 'empty' -%}
+{{ local_data_emptyzone(policy_todname(root), policy_get_tagset(string_table(subtree.tags))) }}
+{%- elif subtree.type == 'nxdomain' -%}
+{{ view_insert_action(policy_todname(root), policy_get_tagset(string_table(subtree.tags))) }}
+{% else %}
+{# TODO: implement other possible types #}
+{%- endif %}
+
+{%- endfor -%}
+{%- endif %}
+
+{# IF subtree.roots_file is not None #}
+{% if subtree.roots_file -%}
+{# TODO: not implemented yet #}
+{%- endif %}
+
+{# IF subtree.roots_url is not None #}
+{% if subtree.roots_url -%}
+{# TODO: not implemented yet #}
+{%- endif %}
+
+{% endfor %}
diff --git a/manager/knot_resolver_manager/datamodel/templates/macros/local_data_macros.lua.j2 b/manager/knot_resolver_manager/datamodel/templates/macros/local_data_macros.lua.j2
new file mode 100644 (file)
index 0000000..cee9fcd
--- /dev/null
@@ -0,0 +1,7 @@
+{% macro local_data_emptyzone(dname, tags) -%}
+assert(C.kr_rule_local_data_emptyzone({{ dname }},{{ tags }})==0)
+{%- endmacro %}
+
+{% macro local_data_nxdomain(dname, tags) -%}
+assert(C.kr_rule_local_data_nxdomain({{ dname }},{{ tags }})==0)
+{%- endmacro %}