Skip to content

Commit

Permalink
Merge pull request #2554 from indrajitr/ddclient-update-20231128
Browse files Browse the repository at this point in the history
ddclient: T5791: Update dynamic dns configuration path for consistency
  • Loading branch information
c-po authored Dec 1, 2023
2 parents 12957f9 + 2d9b005 commit a6d4dd1
Show file tree
Hide file tree
Showing 11 changed files with 354 additions and 310 deletions.
48 changes: 16 additions & 32 deletions data/templates/dns-dynamic/ddclient.conf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -29,44 +29,28 @@ cache={{ config_file | replace('.conf', '.cache') }}
{# ddclient default (web=dyndns) doesn't support ssl and results in process lockup #}
web=googledomains
{# ddclient default (use=ip) results in confusing warning message in log #}
use=disabled
use=no

{% if address is vyos_defined %}
{% for address, service_cfg in address.items() %}
{% if service_cfg.rfc2136 is vyos_defined %}
{% for name, config in service_cfg.rfc2136.items() %}
{% if config.description is vyos_defined %}
{% if name is vyos_defined %}
{% for service, config in name.items() %}
{% if config.description is vyos_defined %}

# {{ config.description }}
{% endif %}
{% for host in config.host_name if config.host_name is vyos_defined %}

# RFC2136 dynamic DNS configuration for {{ name }}: [{{ config.zone }}, {{ host }}]
{# Don't append 'new-style' compliant suffix ('usev4', 'usev6', 'ifv4', 'ifv6' etc.)
to the properties since 'nsupdate' doesn't support that yet. #}
{{ render_config(host, address, service_cfg.web_options,
protocol='nsupdate', server=config.server, zone=config.zone,
password=config.key, ttl=config.ttl) }}
{% endfor %}
{% endfor %}
{% endif %}
{% if service_cfg.service is vyos_defined %}
{% for name, config in service_cfg.service.items() %}
{% if config.description is vyos_defined %}

# {{ config.description }}
{% endif %}
{% for host in config.host_name if config.host_name is vyos_defined %}
{% set ip_suffixes = ['v4', 'v6'] if config.ip_version == 'both'
else [config.ip_version[2:]] %}
{% 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 except 'nsupdate'
ip_suffixes must be [''] for nsupdate since it doesn't support usevX/wantipvX yet #}
{% set ip_suffixes = ['v4', 'v6'] if config.ip_version == 'both'
else ([config.ip_version[2:]] if config.protocol != 'nsupdate'
else ['']) %}
{% set password = config.key if config.protocol == 'nsupdate'
else config.password %}

# Web service dynamic DNS configuration for {{ name }}: [{{ config.protocol }}, {{ host }}]
{{ render_config(host, address, service_cfg.web_options, ip_suffixes,
# Web service dynamic DNS configuration for {{ service }}: [{{ config.protocol }}, {{ host }}]
{{ render_config(host, config.address, config.web_options, ip_suffixes,
protocol=config.protocol, server=config.server, zone=config.zone,
login=config.username, password=config.password, ttl=config.ttl,
login=config.username, password=password, ttl=config.ttl,
min_interval=config.wait_time, max_interval=config.expiry_time) }}
{% endfor %}
{% endfor %}
{% endif %}
{% endfor %}
{% endfor %}
{% endif %}
226 changes: 138 additions & 88 deletions interface-definitions/dns-dynamic.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,48 @@
<help>Dynamic DNS</help>
</properties>
<children>
<tagNode name="address">
<tagNode name="name">
<properties>
<help>Obtain IP address to send Dynamic DNS update for</help>
<help>Dynamic DNS configuration</help>
<valueHelp>
<format>txt</format>
<description>Use interface to obtain the IP address</description>
<description>Dynamic DNS service name</description>
</valueHelp>
<valueHelp>
<format>web</format>
<description>Use HTTP(S) web request to obtain the IP address</description>
</valueHelp>
<completionHelp>
<script>${vyos_completion_dir}/list_interfaces</script>
<list>web</list>
</completionHelp>
<constraint>
#include <include/constraint/interface-name.xml.i>
<regex>web</regex>
</constraint>
</properties>
<children>
#include <include/generic-description.xml.i>
<leafNode name="protocol">
<properties>
<help>ddclient protocol used for Dynamic DNS service</help>
<completionHelp>
<script>${vyos_completion_dir}/list_ddclient_protocols.sh</script>
</completionHelp>
<constraint>
<validator name="ddclient-protocol"/>
</constraint>
</properties>
</leafNode>
<leafNode name="address">
<properties>
<help>Obtain IP address to send Dynamic DNS update for</help>
<valueHelp>
<format>txt</format>
<description>Use interface to obtain the IP address</description>
</valueHelp>
<valueHelp>
<format>web</format>
<description>Use HTTP(S) web request to obtain the IP address</description>
</valueHelp>
<completionHelp>
<script>${vyos_completion_dir}/list_interfaces</script>
<list>web</list>
</completionHelp>
<constraint>
#include <include/constraint/interface-name.xml.i>
<regex>web</regex>
</constraint>
</properties>
</leafNode>
<node name="web-options">
<properties>
<help>Options when using HTTP(S) web request to obtain the IP address</help>
Expand All @@ -50,88 +71,117 @@
</leafNode>
</children>
</node>
<tagNode name="rfc2136">
<leafNode name="ip-version">
<properties>
<help>RFC2136 nsupdate configuration</help>
<help>IP address version to use</help>
<valueHelp>
<format>txt</format>
<description>RFC2136 nsupdate service name</description>
<format>_ipv4</format>
<description>Use only IPv4 address</description>
</valueHelp>
<valueHelp>
<format>_ipv6</format>
<description>Use only IPv6 address</description>
</valueHelp>
<valueHelp>
<format>both</format>
<description>Use both IPv4 and IPv6 address</description>
</valueHelp>
<completionHelp>
<list>ipv4 ipv6 both</list>
</completionHelp>
<constraint>
<regex>(ipv[46]|both)</regex>
</constraint>
<constraintErrorMessage>IP Version must be literal 'ipv4', 'ipv6' or 'both'</constraintErrorMessage>
</properties>
<children>
#include <include/generic-description.xml.i>
#include <include/dns/dynamic-service-host-name-server.xml.i>
#include <include/dns/dynamic-service-wait-expiry-time.xml.i>
<leafNode name="key">
<properties>
<help>File containing the TSIG secret key shared with remote DNS server</help>
<valueHelp>
<format>filename</format>
<description>File in /config/auth directory</description>
</valueHelp>
<constraint>
<validator name="file-path" argument="--strict --parent-dir /config/auth"/>
</constraint>
</properties>
</leafNode>
#include <include/dns/time-to-live.xml.i>
#include <include/dns/dynamic-service-zone.xml.i>
</children>
</tagNode>
<tagNode name="service">
<defaultValue>ipv4</defaultValue>
</leafNode>
<leafNode name="host-name">
<properties>
<help>Hostname to register with Dynamic DNS service</help>
<constraint>
#include <include/constraint/host-name.xml.i>
<regex>(\@|\*)[-.A-Za-z0-9]*</regex>
</constraint>
<constraintErrorMessage>Host-name must be alphanumeric, can contain hyphens and can be prefixed with '@' or '*'</constraintErrorMessage>
<multi/>
</properties>
</leafNode>
<leafNode name="server">
<properties>
<help>Dynamic DNS configuration</help>
<help>Remote Dynamic DNS server to send updates to</help>
<valueHelp>
<format>ipv4</format>
<description>IPv4 address of the remote server</description>
</valueHelp>
<valueHelp>
<format>ipv6</format>
<description>IPv6 address of the remote server</description>
</valueHelp>
<valueHelp>
<format>hostname</format>
<description>Fully qualified domain name of the remote server</description>
</valueHelp>
<constraint>
<validator name="ip-address"/>
<validator name="fqdn"/>
</constraint>
<constraintErrorMessage>Remote server must be IP address or fully qualified domain name</constraintErrorMessage>
</properties>
</leafNode>
<leafNode name="zone">
<properties>
<help>DNS zone to be updated</help>
<valueHelp>
<format>txt</format>
<description>Dynamic DNS service name</description>
<description>Name of DNS zone</description>
</valueHelp>
<constraint>
<validator name="fqdn"/>
</constraint>
</properties>
<children>
#include <include/generic-description.xml.i>
#include <include/dns/dynamic-service-host-name-server.xml.i>
#include <include/dns/dynamic-service-wait-expiry-time.xml.i>
#include <include/generic-username.xml.i>
#include <include/generic-password.xml.i>
#include <include/dns/time-to-live.xml.i>
<leafNode name="protocol">
<properties>
<help>ddclient protocol used for Dynamic DNS service</help>
<completionHelp>
<script>${vyos_completion_dir}/list_ddclient_protocols.sh</script>
</completionHelp>
<constraint>
<validator name="ddclient-protocol"/>
</constraint>
</properties>
</leafNode>
#include <include/dns/dynamic-service-zone.xml.i>
<leafNode name="ip-version">
<properties>
<help>IP address version to use</help>
<valueHelp>
<format>_ipv4</format>
<description>Use only IPv4 address</description>
</valueHelp>
<valueHelp>
<format>_ipv6</format>
<description>Use only IPv6 address</description>
</valueHelp>
<valueHelp>
<format>both</format>
<description>Use both IPv4 and IPv6 address</description>
</valueHelp>
<completionHelp>
<list>ipv4 ipv6 both</list>
</completionHelp>
<constraint>
<regex>(ipv[46]|both)</regex>
</constraint>
<constraintErrorMessage>IP Version must be literal 'ipv4', 'ipv6' or 'both'</constraintErrorMessage>
</properties>
<defaultValue>ipv4</defaultValue>
</leafNode>
</children>
</tagNode>
</leafNode>
#include <include/generic-username.xml.i>
#include <include/generic-password.xml.i>
<leafNode name="key">
<properties>
<help>File containing TSIG authentication key for RFC2136 nsupdate on remote DNS server</help>
<valueHelp>
<format>filename</format>
<description>File in /config/auth directory</description>
</valueHelp>
<constraint>
<validator name="file-path" argument="--strict --parent-dir /config/auth"/>
</constraint>
</properties>
</leafNode>
#include <include/dns/time-to-live.xml.i>
<leafNode name="wait-time">
<properties>
<help>Time in seconds to wait between update attempts</help>
<valueHelp>
<format>u32:60-86400</format>
<description>Time in seconds</description>
</valueHelp>
<constraint>
<validator name="numeric" argument="--range 60-86400"/>
</constraint>
<constraintErrorMessage>Wait time must be between 60 and 86400 seconds</constraintErrorMessage>
</properties>
</leafNode>
<leafNode name="expiry-time">
<properties>
<help>Time in seconds for the hostname to be marked expired in cache</help>
<valueHelp>
<format>u32:300-2160000</format>
<description>Time in seconds</description>
</valueHelp>
<constraint>
<validator name="numeric" argument="--range 300-2160000"/>
</constraint>
<constraintErrorMessage>Expiry time must be between 300 and 2160000 seconds</constraintErrorMessage>
</properties>
</leafNode>
</children>
</tagNode>
<leafNode name="interval">
Expand Down

This file was deleted.

This file was deleted.

14 changes: 0 additions & 14 deletions interface-definitions/include/dns/dynamic-service-zone.xml.i

This file was deleted.

Loading

0 comments on commit a6d4dd1

Please sign in to comment.