Here’s an unfinished version of how I would imagine it would work.
diff --git a/data/actionsmap/yunohost.yml b/data/actionsmap/yunohost.yml
index 966de21..578371d 100644
--- a/data/actionsmap/yunohost.yml
+++ b/data/actionsmap/yunohost.yml
@@ -1261,6 +1261,19 @@ dyndns:
category_help: Subscribe and Update DynDNS Hosts
actions:
+ ### dyndns_allow()
+ allow:
+ action_help: Allow IP version DynDNS platform
+ api: POST /dyndns/ip
+ arguments:
+ ip_version:
+ help: "IP version to allow"
+ choices:
+ - 4
+ - 6
+ - Both
+ default: Both
+
### dyndns_subscribe()
subscribe:
action_help: Subscribe to a DynDNS service
diff --git a/src/yunohost/domain.py b/src/yunohost/domain.py
index f828b09..9a974cd 100644
--- a/src/yunohost/domain.py
+++ b/src/yunohost/domain.py
@@ -325,7 +325,7 @@ def _normalize_domain_path(domain, path):
return domain, path
-def _build_dns_conf(domain, ttl=3600):
+def _build_dns_conf(domain, ttl=3600, incl_ipv4):
"""
Internal function that will returns a data structure containing the needed
information to generate/adapt the dns configuration
@@ -356,10 +356,13 @@ def _build_dns_conf(domain, ttl=3600):
}
"""
- try:
- ipv4 = get_public_ip()
- except:
+ if not incl_ipv4:
ipv4 = None
+ else:
+ try:
+ ipv4 = get_public_ip()
+ except:
+ ipv4 = None
try:
ipv6 = get_public_ip(6)
diff --git a/src/yunohost/dyndns.py b/src/yunohost/dyndns.py
index 55a2be6..8f08935 100644
--- a/src/yunohost/dyndns.py
+++ b/src/yunohost/dyndns.py
@@ -160,7 +160,7 @@ def dyndns_subscribe(subscribe_host="dyndns.yunohost.org", domain=None, key=None
def dyndns_update(dyn_host="dyndns.yunohost.org", domain=None, key=None,
- ipv4=None, ipv6=None):
+ incl_ipv4=True, ipv4=None, ipv6=None):
"""
Update IP on DynDNS platform
@@ -168,6 +168,7 @@ def dyndns_update(dyn_host="dyndns.yunohost.org", domain=None, key=None,
domain -- Full domain to update
dyn_host -- Dynette DNS server to inform
key -- Public DNS key
+ incl_ipv4 -- Include/Exclude IPv4 record
ipv4 -- IP address to send
ipv6 -- IPv6 address to send
@@ -185,7 +186,7 @@ def dyndns_update(dyn_host="dyndns.yunohost.org", domain=None, key=None,
# Get current IPv4 and IPv6
(ipv4_, ipv6_) = get_public_ips()
- if ipv4 is None:
+ if incl_ipv4 and ipv4 is None:
ipv4 = ipv4_
if ipv6 is None:
@@ -224,7 +225,7 @@ def dyndns_update(dyn_host="dyndns.yunohost.org", domain=None, key=None,
'zone %s' % host,
]
- dns_conf = _build_dns_conf(domain)
+ dns_conf = _build_dns_conf(domain, incl_ipv4)
# Delete the old records for all domain/subdomains