Moar dyndns yagni: we don't need to be able to specify ipv4/ipv6/keyfile during dyndns update

This commit is contained in:
Alexandre Aubin 2021-10-24 22:27:11 +02:00
parent c6dfe08973
commit f7cea60a30
2 changed files with 9 additions and 30 deletions

View file

@ -1501,12 +1501,6 @@ dyndns:
help: Full domain to update help: Full domain to update
extra: extra:
pattern: *pattern_domain pattern: *pattern_domain
-k:
full: --key
help: Public DNS key
-i:
full: --ipv4
help: IP address to send
-f: -f:
full: --force full: --force
help: Force the update (for debugging only) help: Force the update (for debugging only)
@ -1515,9 +1509,6 @@ dyndns:
full: --dry-run full: --dry-run
help: Only display the generated zone help: Only display the generated zone
action: store_true action: store_true
-6:
full: --ipv6
help: IPv6 address to send
### dyndns_installcron() ### dyndns_installcron()
installcron: installcron:

View file

@ -174,9 +174,6 @@ def dyndns_subscribe(
def dyndns_update( def dyndns_update(
operation_logger, operation_logger,
domain=None, domain=None,
key=None,
ipv4=None,
ipv6=None,
force=False, force=False,
dry_run=False, dry_run=False,
): ):
@ -185,15 +182,12 @@ def dyndns_update(
Keyword argument: Keyword argument:
domain -- Full domain to update domain -- Full domain to update
key -- Public DNS key
ipv4 -- IP address to send
ipv6 -- IPv6 address to send
""" """
from yunohost.dns import _build_dns_conf from yunohost.dns import _build_dns_conf
# If domain is not given, try to guess it from keys available... # If domain is not given, try to guess it from keys available...
key = None
if domain is None: if domain is None:
(domain, key) = _guess_current_dyndns_domain() (domain, key) = _guess_current_dyndns_domain()
@ -201,8 +195,7 @@ def dyndns_update(
raise YunohostValidationError("dyndns_no_domain_registered") raise YunohostValidationError("dyndns_no_domain_registered")
# If key is not given, pick the first file we find with the domain given # If key is not given, pick the first file we find with the domain given
else: elif key is None:
if key is None:
keys = glob.glob("/etc/yunohost/dyndns/K{0}.+*.private".format(domain)) keys = glob.glob("/etc/yunohost/dyndns/K{0}.+*.private".format(domain))
if not keys: if not keys:
@ -267,14 +260,8 @@ def dyndns_update(
old_ipv6 = resolve_domain(domain, "AAAA") old_ipv6 = resolve_domain(domain, "AAAA")
# Get current IPv4 and IPv6 # Get current IPv4 and IPv6
ipv4_ = get_public_ip() ipv4 = get_public_ip()
ipv6_ = get_public_ip(6) ipv6 = get_public_ip(6)
if ipv4 is None:
ipv4 = ipv4_
if ipv6 is None:
ipv6 = ipv6_
logger.debug("Old IPv4/v6 are (%s, %s)" % (old_ipv4, old_ipv6)) logger.debug("Old IPv4/v6 are (%s, %s)" % (old_ipv4, old_ipv6))
logger.debug("Requested IPv4/v6 are (%s, %s)" % (ipv4, ipv6)) logger.debug("Requested IPv4/v6 are (%s, %s)" % (ipv4, ipv6))
@ -379,6 +366,7 @@ def _guess_current_dyndns_domain():
# Retrieve the first registered domain # Retrieve the first registered domain
paths = list(glob.iglob("/etc/yunohost/dyndns/K*.private")) paths = list(glob.iglob("/etc/yunohost/dyndns/K*.private"))
for path in paths: for path in paths:
# MD5 is legacy ugh
match = RE_DYNDNS_PRIVATE_KEY_MD5.match(path) match = RE_DYNDNS_PRIVATE_KEY_MD5.match(path)
if not match: if not match:
match = RE_DYNDNS_PRIVATE_KEY_SHA512.match(path) match = RE_DYNDNS_PRIVATE_KEY_SHA512.match(path)