dyndns: fix availability check, polish UX

This commit is contained in:
Alexandre Aubin 2023-09-28 14:19:00 +02:00
parent 2e4f2e8e3a
commit 82affd2984
3 changed files with 12 additions and 9 deletions

View file

@ -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",

View file

@ -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}.+*"):

View file

@ -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: