mirror of
https://github.com/YunoHost/moulinette.git
synced 2024-09-03 20:06:31 +02:00
[fix] Use http to retrieve public IPv6 due to Let's Encrypt restriction
This commit is contained in:
parent
5afd0c1272
commit
c7a7e01d89
1 changed files with 7 additions and 4 deletions
|
@ -292,12 +292,15 @@ def domain_dns_conf(domain, ttl=None):
|
|||
|
||||
def get_public_ip(protocol=4):
|
||||
"""Retrieve the public IP address from ip.yunohost.org"""
|
||||
if protocol not in [4, 6]:
|
||||
if protocol == 4:
|
||||
url = 'https://ip.yunohost.org'
|
||||
elif protocol == 6:
|
||||
# FIXME: Let's Encrypt does not support IPv6 host only yet
|
||||
url = 'http://ipv6.yunohost.org'
|
||||
else:
|
||||
raise ValueError("invalid protocol version")
|
||||
try:
|
||||
return urlopen("https://ip{protocol}.yunohost.org".format(
|
||||
protocol=('' if protocol == 4 else 'v6')
|
||||
)).read().strip()
|
||||
return urlopen(url).read().strip()
|
||||
except IOError:
|
||||
logger.debug('cannot retrieve public IPv%d' % protocol, exc_info=1)
|
||||
raise MoulinetteError(errno.ENETUNREACH,
|
||||
|
|
Loading…
Add table
Reference in a new issue