mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
Merge branch 'testing' into unstable
This fixes DynDNS update.
This commit is contained in:
commit
d11dd38e42
4 changed files with 53 additions and 18 deletions
|
@ -1168,7 +1168,7 @@ dyndns:
|
||||||
default: "dyndns.yunohost.org"
|
default: "dyndns.yunohost.org"
|
||||||
-d:
|
-d:
|
||||||
full: --domain
|
full: --domain
|
||||||
help: Full domain to subscribe with
|
help: Full domain to update
|
||||||
extra:
|
extra:
|
||||||
pattern: *pattern_domain
|
pattern: *pattern_domain
|
||||||
-k:
|
-k:
|
||||||
|
|
18
debian/changelog
vendored
18
debian/changelog
vendored
|
@ -1,3 +1,15 @@
|
||||||
|
moulinette-yunohost (2.2.4) stable; urgency=low
|
||||||
|
|
||||||
|
[ Jérôme Lebleu ]
|
||||||
|
* [fix] Update first registered domain with DynDNS instead of current_host
|
||||||
|
* [fix] Set found private key and don't validate it in dyndns_update
|
||||||
|
* [fix] Use dyndns.yunohost.org instead of dynhost.yunohost.org
|
||||||
|
|
||||||
|
[ opi ]
|
||||||
|
* [fix] Catch ConnectionError from requests package
|
||||||
|
|
||||||
|
-- Jérôme Lebleu <jerome@yunohost.org> Sun, 27 Mar 2016 16:30:42 +0200
|
||||||
|
|
||||||
yunohost (2.3.11.2) testing; urgency=low
|
yunohost (2.3.11.2) testing; urgency=low
|
||||||
|
|
||||||
* [fix] Don't fail dnsmasq regen if IPv4/6 cannot be retrieved
|
* [fix] Don't fail dnsmasq regen if IPv4/6 cannot be retrieved
|
||||||
|
@ -383,12 +395,6 @@ moulinette-yunohost (2.3.0) testing; urgency=low
|
||||||
|
|
||||||
-- Jérôme Lebleu <jerome.lebleu@mailoo.org> Tue, 08 Sep 2015 14:19:28 +0200
|
-- Jérôme Lebleu <jerome.lebleu@mailoo.org> Tue, 08 Sep 2015 14:19:28 +0200
|
||||||
|
|
||||||
moulinette-yunohost (2.2.3-1) stable; urgency=low
|
|
||||||
|
|
||||||
* [fix] Catch ConnectionError from requests package
|
|
||||||
|
|
||||||
-- opi <opi@zeropi.net> Sun, 06 Mar 2016 21:51:06 +0100
|
|
||||||
|
|
||||||
moulinette-yunohost (2.2.3) stable; urgency=low
|
moulinette-yunohost (2.2.3) stable; urgency=low
|
||||||
|
|
||||||
* [fix] Catch proper exception in backup_list (fix #65)
|
* [fix] Catch proper exception in backup_list (fix #65)
|
||||||
|
|
|
@ -69,6 +69,8 @@
|
||||||
"no_ipv6_connectivity": "IPv6 connectivity is not available",
|
"no_ipv6_connectivity": "IPv6 connectivity is not available",
|
||||||
|
|
||||||
"dyndns_key_generating" : "DNS key is being generated, it may take a while...",
|
"dyndns_key_generating" : "DNS key is being generated, it may take a while...",
|
||||||
|
"dyndns_key_not_found" : "DNS key not found for the domain",
|
||||||
|
"dyndns_no_domain_registered": "No domain has been registered with DynDNS",
|
||||||
"dyndns_unavailable" : "Unavailable DynDNS subdomain",
|
"dyndns_unavailable" : "Unavailable DynDNS subdomain",
|
||||||
"dyndns_registration_failed" : "Unable to register DynDNS domain: {error:s}",
|
"dyndns_registration_failed" : "Unable to register DynDNS domain: {error:s}",
|
||||||
"dyndns_registered" : "DynDNS domain successfully registered",
|
"dyndns_registered" : "DynDNS domain successfully registered",
|
||||||
|
|
|
@ -24,12 +24,12 @@
|
||||||
Subscribe and Update DynDNS Hosts
|
Subscribe and Update DynDNS Hosts
|
||||||
"""
|
"""
|
||||||
import os
|
import os
|
||||||
import requests
|
|
||||||
import re
|
import re
|
||||||
import json
|
import json
|
||||||
import glob
|
import glob
|
||||||
import base64
|
import base64
|
||||||
import errno
|
import errno
|
||||||
|
import requests
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
from moulinette.core import MoulinetteError
|
from moulinette.core import MoulinetteError
|
||||||
|
@ -62,6 +62,10 @@ class IPRouteLine(object):
|
||||||
for k, v in self.m.groupdict().items():
|
for k, v in self.m.groupdict().items():
|
||||||
setattr(self, k, v)
|
setattr(self, k, v)
|
||||||
|
|
||||||
|
re_dyndns_private_key = re.compile(
|
||||||
|
r'.*/K(?P<domain>[^\s\+]+)\.\+157.+\.private$'
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def dyndns_subscribe(subscribe_host="dyndns.yunohost.org", domain=None, key=None):
|
def dyndns_subscribe(subscribe_host="dyndns.yunohost.org", domain=None, key=None):
|
||||||
"""
|
"""
|
||||||
|
@ -120,17 +124,13 @@ def dyndns_update(dyn_host="dyndns.yunohost.org", domain=None, key=None,
|
||||||
Update IP on DynDNS platform
|
Update IP on DynDNS platform
|
||||||
|
|
||||||
Keyword argument:
|
Keyword argument:
|
||||||
domain -- Full domain to subscribe with
|
domain -- Full domain to update
|
||||||
dyn_host -- Dynette DNS server to inform
|
dyn_host -- Dynette DNS server to inform
|
||||||
key -- Public DNS key
|
key -- Public DNS key
|
||||||
ipv4 -- IP address to send
|
ipv4 -- IP address to send
|
||||||
ipv6 -- IPv6 address to send
|
ipv6 -- IPv6 address to send
|
||||||
|
|
||||||
"""
|
"""
|
||||||
if domain is None:
|
|
||||||
with open('/etc/yunohost/current_host', 'r') as f:
|
|
||||||
domain = f.readline().rstrip()
|
|
||||||
|
|
||||||
# IPv4
|
# IPv4
|
||||||
if ipv4 is None:
|
if ipv4 is None:
|
||||||
ipv4 = get_public_ip()
|
ipv4 = get_public_ip()
|
||||||
|
@ -168,6 +168,37 @@ def dyndns_update(dyn_host="dyndns.yunohost.org", domain=None, key=None,
|
||||||
old_ipv6 = '0000:0000:0000:0000:0000:0000:0000:0000'
|
old_ipv6 = '0000:0000:0000:0000:0000:0000:0000:0000'
|
||||||
|
|
||||||
if old_ip != ipv4 or old_ipv6 != ipv6:
|
if old_ip != ipv4 or old_ipv6 != ipv6:
|
||||||
|
if domain is None:
|
||||||
|
# Retrieve the first registered domain
|
||||||
|
for path in glob.iglob('/etc/yunohost/dyndns/K*.private'):
|
||||||
|
match = re_dyndns_private_key.match(path)
|
||||||
|
if not match:
|
||||||
|
continue
|
||||||
|
_domain = match.group('domain')
|
||||||
|
try:
|
||||||
|
# Check if domain is registered
|
||||||
|
if requests.get('https://{0}/test/{1}'.format(
|
||||||
|
dyn_host, _domain)).status_code == 200:
|
||||||
|
continue
|
||||||
|
except requests.ConnectionError:
|
||||||
|
raise MoulinetteError(errno.ENETUNREACH,
|
||||||
|
m18n.n('no_internet_connection'))
|
||||||
|
domain = _domain
|
||||||
|
key = path
|
||||||
|
break
|
||||||
|
if not domain:
|
||||||
|
raise MoulinetteError(errno.EINVAL,
|
||||||
|
m18n.n('dyndns_no_domain_registered'))
|
||||||
|
|
||||||
|
if key is None:
|
||||||
|
keys = glob.glob(
|
||||||
|
'/etc/yunohost/dyndns/K{0}.+*.private'.format(domain))
|
||||||
|
if len(keys) > 0:
|
||||||
|
key = keys[0]
|
||||||
|
if not key:
|
||||||
|
raise MoulinetteError(errno.EIO,
|
||||||
|
m18n.n('dyndns_key_not_found'))
|
||||||
|
|
||||||
host = domain.split('.')[1:]
|
host = domain.split('.')[1:]
|
||||||
host = '.'.join(host)
|
host = '.'.join(host)
|
||||||
lines = [
|
lines = [
|
||||||
|
@ -209,11 +240,7 @@ def dyndns_update(dyn_host="dyndns.yunohost.org", domain=None, key=None,
|
||||||
for line in lines:
|
for line in lines:
|
||||||
zone.write(line + '\n')
|
zone.write(line + '\n')
|
||||||
|
|
||||||
if key is None:
|
if os.system('/usr/bin/nsupdate -k %s /etc/yunohost/dyndns/zone' % key) == 0:
|
||||||
private_key_file = glob.glob('/etc/yunohost/dyndns/*.private')[0]
|
|
||||||
else:
|
|
||||||
private_key_file = key
|
|
||||||
if os.system('/usr/bin/nsupdate -k %s /etc/yunohost/dyndns/zone' % private_key_file) == 0:
|
|
||||||
logger.success(m18n.n('dyndns_ip_updated'))
|
logger.success(m18n.n('dyndns_ip_updated'))
|
||||||
with open('/etc/yunohost/dyndns/old_ip', 'w') as f:
|
with open('/etc/yunohost/dyndns/old_ip', 'w') as f:
|
||||||
f.write(ipv4)
|
f.write(ipv4)
|
||||||
|
|
Loading…
Add table
Reference in a new issue