mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
[mod] don't request the server if a dyndns domain is already subscribed
This commit is contained in:
parent
3f65543dc2
commit
a8e57d9c6a
1 changed files with 5 additions and 4 deletions
|
@ -83,20 +83,21 @@ def domain_add(auth, domain, dyndns=False):
|
|||
if dyndns:
|
||||
if len(domain.split('.')) < 3:
|
||||
raise MoulinetteError(errno.EINVAL, m18n.n('domain_dyndns_invalid'))
|
||||
from yunohost.dyndns import dyndns_subscribe
|
||||
|
||||
if os.path.exists('/etc/cron.d/yunohost-dyndns'):
|
||||
raise MoulinetteError(errno.EPERM,
|
||||
m18n.n('domain_dyndns_already_subscribed'))
|
||||
try:
|
||||
r = requests.get('https://dyndns.yunohost.org/domains', timeout=30)
|
||||
except requests.ConnectionError as e:
|
||||
raise MoulinetteError(errno.EHOSTUNREACH,
|
||||
m18n.n('domain_dyndns_dynette_is_unreachable', error=str(e)))
|
||||
|
||||
from yunohost.dyndns import dyndns_subscribe
|
||||
|
||||
dyndomains = json.loads(r.text)
|
||||
dyndomain = '.'.join(domain.split('.')[1:])
|
||||
if dyndomain in dyndomains:
|
||||
if os.path.exists('/etc/cron.d/yunohost-dyndns'):
|
||||
raise MoulinetteError(errno.EPERM,
|
||||
m18n.n('domain_dyndns_already_subscribed'))
|
||||
dyndns_subscribe(domain=domain)
|
||||
else:
|
||||
raise MoulinetteError(errno.EINVAL,
|
||||
|
|
Loading…
Add table
Reference in a new issue