From 112ba5f7ca24776790b295617104a5cb370709d5 Mon Sep 17 00:00:00 2001 From: Daniel Akulenok Date: Wed, 28 Jan 2026 23:02:59 +0100 Subject: [PATCH] feat: implement list_address_port_tls and parent_address_port_tls macros - Add list_address_port_tls macro for rendering address lists with port and tls parameters - Add parent_address_port_tls macro for parent statements with global port/tls - Follow existing naming pattern with separate list_ and parent_ macros - Supports forwarders, primaries, and similar blocks with port/tls grammar --- templates/named.conf.functions.j2 | 32 +++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/templates/named.conf.functions.j2 b/templates/named.conf.functions.j2 index 0ba8399..06cc86a 100644 --- a/templates/named.conf.functions.j2 +++ b/templates/named.conf.functions.j2 @@ -110,4 +110,36 @@ {% else %} {{ name }} "{{ value }}"; {% endif %} +{% endmacro %} + +{% macro list_address_port_tls(dict, indent=bind9_config_indent) %} +{# This macro is for use for statements with grammar like #} +{# address port 00 tls str; address port 00 tls str; #} +{# it is usually called by a parent macro #} +{% filter indent(indent, true) %} +{% for item in dict %} +{% if item is not mapping %} +{{ item }}; +{% else %} +{{ item.address }} +{{- (' port ' + item.port | string) if item.port is defined and item.port -}} +{{- (' tls ' + item.tls | string) if item.tls is defined and item.tls -}}; +{% endif %} +{% endfor %} +{% endfilter %} +{% endmacro %} + +{% macro parent_address_port_tls(name, dict) %} +{# This macro is for use for statements with grammar like #} +{# statement port 00 tls str { address port 00 tls str; address port 00 tls str; } #} +{# the list inside the statement is handled by list_address_port_tls #} +{% if dict is not mapping and dict is iterable %} +{{ name }} { +{{ list_address_port_tls(dict) }}}; +{% else %} +{{ name }} +{{- (' port ' + dict.port | string) if dict.port is defined and dict.port -}} +{{- (' tls ' + dict.tls | string) if dict.tls is defined and dict.tls }} { +{{ list_address_port_tls(dict.addresses) }}}; +{% endif %} {% endmacro %} \ No newline at end of file