diff options
author | Christian Poessinger <christian@poessinger.com> | 2020-02-10 20:30:22 +0100 |
---|---|---|
committer | Christian Poessinger <christian@poessinger.com> | 2020-02-13 08:01:35 +0100 |
commit | c624e198974790e5d7fa9a158aa879fe75068090 (patch) | |
tree | c00a43084162f35abf2c6ef9809d171d99a6ee53 /src/conf_mode | |
parent | 1adf2818083c40cf81d7747a4c9d26e85c235a60 (diff) | |
download | vyos-1x-c624e198974790e5d7fa9a158aa879fe75068090.tar.gz vyos-1x-c624e198974790e5d7fa9a158aa879fe75068090.zip |
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.
Diffstat (limited to 'src/conf_mode')
-rwxr-xr-x | src/conf_mode/dynamic_dns.py | 19 |
1 files changed, 15 insertions, 4 deletions
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): |