[enh] Use https to retrieve public IP address

This commit is contained in:
Jérôme Lebleu 2016-03-08 10:44:25 +01:00
parent b27c5208d5
commit 5f08eb06ae
3 changed files with 4 additions and 4 deletions

View file

@ -83,7 +83,7 @@ def domain_add(auth, domain, dyndns=False):
attr_dict = { 'objectClass' : ['mailDomain', 'top'] } attr_dict = { 'objectClass' : ['mailDomain', 'top'] }
try: try:
ip = str(urlopen('http://ip.yunohost.org').read()) ip = str(urlopen('https://ip.yunohost.org').read())
except IOError: except IOError:
ip = "127.0.0.1" ip = "127.0.0.1"
now = datetime.datetime.now() now = datetime.datetime.now()
@ -233,7 +233,7 @@ def domain_dns_conf(domain, ttl=None):
# A/AAAA records # A/AAAA records
try: try:
ip4 = urlopen("http://ip.yunohost.org").read().strip() ip4 = urlopen("https://ip.yunohost.org").read().strip()
except IOError: except IOError:
raise MoulinetteError(errno.ENETUNREACH, raise MoulinetteError(errno.ENETUNREACH,
m18n.n('no_internet_connection')) m18n.n('no_internet_connection'))

View file

@ -131,7 +131,7 @@ def dyndns_update(dyn_host="dynhost.yunohost.org", domain=None, key=None, ip=Non
# IPv4 # IPv4
if ip is None: if ip is None:
try: try:
new_ip = requests.get('http://ip.yunohost.org').text new_ip = requests.get('https://ip.yunohost.org').text
except requests.ConnectionError: except requests.ConnectionError:
raise MoulinetteError(errno.ENETUNREACH, m18n.n('no_internet_connection')) raise MoulinetteError(errno.ENETUNREACH, m18n.n('no_internet_connection'))
else: else:

View file

@ -210,7 +210,7 @@ def monitor_network(units=None, human_readable=False):
logger.debug('interface name %s was not found', iname) logger.debug('interface name %s was not found', iname)
elif u == 'infos': elif u == 'infos':
try: try:
p_ip = str(urlopen('http://ip.yunohost.org').read()) p_ip = str(urlopen('https://ip.yunohost.org').read())
except: except:
p_ip = 'unknown' p_ip = 'unknown'