diff options
| author | Indrajit Raychaudhuri <irc@indrajit.com> | 2024-12-30 19:03:34 -0600 |
|---|---|---|
| committer | Indrajit Raychaudhuri <irc@indrajit.com> | 2026-07-24 12:17:23 -0500 |
| commit | 65c8d1538d0fa68d4e7306aa152cdc39ba082b6b (patch) | |
| tree | 4f7797b8c5ee5515cc45e20c2bbf696b8fcee92c | |
| parent | 282e1c4d27543bf7941b10685e633056dd04b2be (diff) | |
| download | vyos-1x-65c8d1538d0fa68d4e7306aa152cdc39ba082b6b.tar.gz vyos-1x-65c8d1538d0fa68d4e7306aa152cdc39ba082b6b.zip | |
ddclient: T6981: Move nsupdate key mapping to Python
Relocate key mapping for 'nsupdate' (rfc2136) from
Jinja template to Python. This keeps the template
simpler and allows for more complex dict handling
in Python.
| -rw-r--r-- | data/templates/dns-dynamic/ddclient.conf.j2 | 10 | ||||
| -rwxr-xr-x | src/conf_mode/service_dns_dynamic.py | 7 |
2 files changed, 11 insertions, 6 deletions
diff --git a/data/templates/dns-dynamic/ddclient.conf.j2 b/data/templates/dns-dynamic/ddclient.conf.j2 index 98d1584a1..fd50a529d 100644 --- a/data/templates/dns-dynamic/ddclient.conf.j2 +++ b/data/templates/dns-dynamic/ddclient.conf.j2 @@ -29,19 +29,17 @@ if{{ ipv }}={{ address }}, \ # {{ config.description }} {% endif %} {% for host in config.host_name if config.host_name is vyos_defined %} -{# ip_suffixes can be either of ['v4'], ['v6'], ['v4', 'v6'] for all protocols #} -{% set ip_suffixes = ['v4', 'v6'] if config.ip_version == 'both' - else [config.ip_version[2:]] %} -{% set password = config.key if config.protocol == 'nsupdate' - else config.password %} {% set address = 'web' if config.address.web is vyos_defined else config.address.interface %} {% set web_options = config.address.web | default({}) %} +{# ip_suffixes can be either of ['v4'], ['v6'], ['v4', 'v6'] for all protocols #} +{% set ip_suffixes = ['v4', 'v6'] if config.ip_version == 'both' + else [config.ip_version[2:]] %} # Web service dynamic DNS configuration for {{ service }}: [{{ config.protocol }}, {{ host }}] {{ render_config(host, address, web_options, ip_suffixes, protocol=config.protocol, server=config.server, zone=config.zone, - login=config.username, password=password, ttl=config.ttl, + login=config.username, password=config.password, ttl=config.ttl, min_interval=config.wait_time, max_interval=config.expiry_time) }} {% endfor %} {% endfor %} diff --git a/src/conf_mode/service_dns_dynamic.py b/src/conf_mode/service_dns_dynamic.py index 08ee80a6b..682daa8a2 100755 --- a/src/conf_mode/service_dns_dynamic.py +++ b/src/conf_mode/service_dns_dynamic.py @@ -156,6 +156,13 @@ def generate(dyndns): if not dyndns or 'name' not in dyndns: return None + # Adjust protocol specific keys + for name in dyndns['name']: + # nsupdate (RFC2136) uses: + # - 'password' in ddclient.conf instead of 'key' in vyos conf + if dyndns['name'][name]['protocol'] == 'nsupdate': + dyndns['name'][name]['password'] = dyndns['name'][name].pop('key') + render(config_file, 'dns-dynamic/ddclient.conf.j2', dyndns, permission=0o600) render(systemd_override, 'dns-dynamic/override.conf.j2', dyndns) return None |
