summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--interface-definitions/dns-dynamic.xml.in5
-rwxr-xr-xsrc/conf_mode/dynamic_dns.py19
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 @@
</valueHelp>
</properties>
</leafNode>
+ <leafNode name="zone">
+ <properties>
+ <help>DNS zone to update (only available with CloudFlare)</help>
+ </properties>
+ </leafNode>
</children>
</tagNode>
<node name="use-web">
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):