From c624e198974790e5d7fa9a158aa879fe75068090 Mon Sep 17 00:00:00 2001 From: Christian Poessinger Date: Mon, 10 Feb 2020 20:30:22 +0100 Subject: ddclient: T1908: CloudFlares zone option can now also be specified manually If there is no zone option given it will be "guessed" as in the past. This means (hostname -> resulting zone entry) domain.com -> com foo.domain.com -> domain.com bar.foo.domain.com -> foo.domain.com I have zero experience in the CloudFlare zone option what it is and what it does. SO maybe we still have a chance to auto render this setting. --- interface-definitions/dns-dynamic.xml.in | 5 +++++ src/conf_mode/dynamic_dns.py | 19 +++++++++++++++---- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/interface-definitions/dns-dynamic.xml.in b/interface-definitions/dns-dynamic.xml.in index 498fd3f2f..143c04ef6 100644 --- a/interface-definitions/dns-dynamic.xml.in +++ b/interface-definitions/dns-dynamic.xml.in @@ -207,6 +207,11 @@ + + + DNS zone to update (only available with CloudFlare) + + diff --git a/src/conf_mode/dynamic_dns.py b/src/conf_mode/dynamic_dns.py index 9ba8659a1..d55e732df 100755 --- a/src/conf_mode/dynamic_dns.py +++ b/src/conf_mode/dynamic_dns.py @@ -66,9 +66,8 @@ password='{{ srv.password }}', {% if srv.server -%} server={{ srv.server }}, {% endif -%} -{% if 'cloudflare' in srv.protocol -%} -{% set zone = host.split('.',1) -%} -zone={{ zone[1] }}, +{% if srv.zone -%} +zone={{ srv.zone }}, {% endif -%} {{ host }} {% endfor %} @@ -157,7 +156,8 @@ def get_config(): 'password': '', 'protocol': '', 'server': '', - 'custom' : False + 'custom' : False, + 'zone' : '' } # preload protocol from default service mapping @@ -181,6 +181,13 @@ def get_config(): if conf.exists('service {0} server'.format(service)): srv['server'] = conf.return_value('service {0} server'.format(service)) + if conf.exists('service {0} zone'.format(service)): + srv['zone'] = conf.return_value('service {0} zone'.format(service)) + elif srv['provider'] == 'cloudflare': + # default populate zone entry with bar.tld if + # host-name is foo.bar.tld + srv['zone'] = srv['host'][0].split('.',1)[1] + node['service'].append(srv) # Additional settings in CLI @@ -237,6 +244,10 @@ def verify(dyndns): if not service['server']: raise ConfigError('Set server for service "{0}" to send DDNS updates for interface "{1}"'.format(service['provider'], node['interface'])) + if service['zone']: + if service['provider'] != 'cloudflare': + raise ConfigError('Zone option not allowed for "{0}", it can only be used for CloudFlare'.format(service['provider'])) + return None def generate(dyndns): -- cgit v1.2.3