From 82affd298452cbab360df4d93303c9817f146707 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Thu, 28 Sep 2023 14:19:00 +0200 Subject: [PATCH] dyndns: fix availability check, polish UX --- locales/en.json | 6 +++--- src/domain.py | 11 +++++++---- src/dyndns.py | 4 ++-- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/locales/en.json b/locales/en.json index d9f42dede..dbf95caa6 100644 --- a/locales/en.json +++ b/locales/en.json @@ -91,7 +91,7 @@ "ask_new_path": "New path", "ask_password": "Password", "ask_dyndns_recovery_password_explain": "Please pick a recovery password for your DynDNS domain, in case you need to reset it later.", - "ask_dyndns_recovery_password_explain_unavailable": "This DynDNS domain is not available, please enter the recovery password if this your domain.", + "ask_dyndns_recovery_password_explain_unavailable": "This DynDNS domain is aleady registered. If you are the person who originally registered this domain, you may enter the recovery password to reclaim this domain.", "ask_dyndns_recovery_password": "DynDNS recovery password", "ask_dyndns_recovery_password_explain_during_unsubscribe": "Please enter the recovery password for this DynDNS domain.", "ask_user_domain": "Domain to use for the user's email address and XMPP account", @@ -397,7 +397,7 @@ "downloading": "Downloading...", "dpkg_is_broken": "You cannot do this right now because dpkg/APT (the system package managers) seems to be in a broken state... You can try to solve this issue by connecting through SSH and running `sudo apt install --fix-broken` and/or `sudo dpkg --configure -a` and/or `sudo dpkg --audit`.", "dpkg_lock_not_available": "This command can't be run right now because another program seems to be using the lock of dpkg (the system package manager)", - "dyndns_availability_too_many_requests": "YunoHost's free domain service received too many requests from you, wait 1 minute or so before trying again.", + "dyndns_availability_too_many_requests": "YunoHost's dyndns service received too many requests from you, wait 1 minute or so before trying again.", "dyndns_could_not_check_available": "Could not check if {domain} is available on {provider}.", "dyndns_domain_not_provided": "DynDNS provider {provider} cannot provide domain {domain}.", "dyndns_ip_update_failed": "Could not update IP address to DynDNS", @@ -412,7 +412,7 @@ "dyndns_unsubscribed": "DynDNS domain unsubscribed", "dyndns_unsubscribe_denied": "Failed to unsubscribe domain: invalid credentials", "dyndns_unsubscribe_already_unsubscribed": "Domain is already unsubscribed", - "dyndns_unsubscribe_too_many_requests": "YunoHost's free domain service received too many requests from you, wait 1 hour or so before trying again.", + "dyndns_unsubscribe_too_many_requests": "YunoHost's dyndns service received too many requests from you, wait 1 hour or so before trying again.", "dyndns_set_recovery_password_denied": "Failed to set recovery password: invalid key", "dyndns_set_recovery_password_unknown_domain": "Failed to set recovery password: domain not registered", "dyndns_set_recovery_password_invalid_password": "Failed to set recovery password: password is not strong enough", diff --git a/src/domain.py b/src/domain.py index 04d8370e4..beedf43e0 100644 --- a/src/domain.py +++ b/src/domain.py @@ -456,10 +456,13 @@ def domain_remove( # If a password is provided, delete the DynDNS record if dyndns: - # Actually unsubscribe - domain_dyndns_unsubscribe( - domain=domain, recovery_password=dyndns_recovery_password - ) + try: + # Actually unsubscribe + domain_dyndns_unsubscribe( + domain=domain, recovery_password=dyndns_recovery_password + ) + except Exception as e: + logger.warning(str(e)) rm(f"/etc/yunohost/certs/{domain}", force=True, recursive=True) for key_file in glob.glob(f"/etc/yunohost/dyndns/K{domain}.+*"): diff --git a/src/dyndns.py b/src/dyndns.py index 78a6b0a90..70f44672d 100644 --- a/src/dyndns.py +++ b/src/dyndns.py @@ -75,7 +75,7 @@ def _dyndns_available(domain): ) if r.status_code == 200: - return r == f"Domain {domain} is available" + return r.text.strip('"') == f"Domain {domain} is available" elif r.status_code == 409: return False elif r.status_code == 429: @@ -112,7 +112,7 @@ def dyndns_subscribe(operation_logger, domain=None, recovery_password=None): if not recovery_password and Moulinette.interface.type == "cli": logger.warning(m18n.n("ask_dyndns_recovery_password_explain_unavailable")) recovery_password = Moulinette.prompt( - m18n.n("ask_dyndns_recovery_password"), is_password=True, confirm=True + m18n.n("ask_dyndns_recovery_password"), is_password=True ) if recovery_password: