mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
Merge remote-tracking branch 'frju_ip/dev' into ip_pool
This commit is contained in:
commit
0c371cea12
2 changed files with 30 additions and 17 deletions
|
@ -203,7 +203,7 @@ class MyDiagnoser(Diagnoser):
|
||||||
|
|
||||||
def get_public_ip(self, protocol=4):
|
def get_public_ip(self, protocol=4):
|
||||||
|
|
||||||
# FIXME - TODO : here we assume that DNS resolution for ip.yunohost.org is working
|
# FIXME - TODO : The best would be to make it configurable
|
||||||
# but if we want to be able to diagnose DNS resolution issues independently from
|
# but if we want to be able to diagnose DNS resolution issues independently from
|
||||||
# internet connectivity, we gotta rely on fixed IPs first....
|
# internet connectivity, we gotta rely on fixed IPs first....
|
||||||
|
|
||||||
|
@ -214,12 +214,20 @@ class MyDiagnoser(Diagnoser):
|
||||||
protocol
|
protocol
|
||||||
)
|
)
|
||||||
|
|
||||||
url = "https://ip%s.yunohost.org" % ("6" if protocol == 6 else "")
|
ip_url_yunohost_tab = ["https://ip%s.yunohost.org" % (protocol if protocol != 4 else ""), "https://0-ip%s.yunohost.org" % (protocol if protocol != 4 else "")]
|
||||||
|
|
||||||
try:
|
# Check URLS
|
||||||
return download_text(url, timeout=30).strip()
|
for url in ip_url_yunohost_tab:
|
||||||
except Exception as e:
|
try:
|
||||||
protocol = str(protocol)
|
return download_text(url, timeout=10).strip()
|
||||||
e = str(e)
|
except Exception as e:
|
||||||
self.logger_debug(f"Could not get public IPv{protocol} : {e}")
|
self.logger_debug(
|
||||||
return None
|
"Could not get public IPv%s from %s : %s" % (str(protocol), url, str(e))
|
||||||
|
)
|
||||||
|
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def main(args, env, loggers):
|
||||||
|
return MyDiagnoser(args, env, loggers).diagnose()
|
||||||
|
|
|
@ -53,7 +53,7 @@ def get_public_ip(protocol=4):
|
||||||
|
|
||||||
|
|
||||||
def get_public_ip_from_remote_server(protocol=4):
|
def get_public_ip_from_remote_server(protocol=4):
|
||||||
"""Retrieve the public IP address from ip.yunohost.org"""
|
"""Retrieve the public IP address from ip.yunohost.org or another Server"""
|
||||||
|
|
||||||
# We can know that ipv6 is not available directly if this file does not exists
|
# We can know that ipv6 is not available directly if this file does not exists
|
||||||
if protocol == 6 and not os.path.exists("/proc/net/if_inet6"):
|
if protocol == 6 and not os.path.exists("/proc/net/if_inet6"):
|
||||||
|
@ -81,14 +81,19 @@ def get_public_ip_from_remote_server(protocol=4):
|
||||||
)
|
)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
url = "https://ip%s.yunohost.org" % (protocol if protocol != 4 else "")
|
ip_url_yunohost_tab = ["https://ip%s.yunohost.org" % (protocol if protocol != 4 else ""), "https://0-ip%s.yunohost.org" % (protocol if protocol != 4 else "")]
|
||||||
logger.debug("Fetching IP from %s " % url)
|
|
||||||
|
|
||||||
try:
|
# Check URLS
|
||||||
return download_text(url, timeout=30).strip()
|
for url in ip_url_yunohost_tab:
|
||||||
except Exception as e:
|
logger.debug("Fetching IP from %s " % url)
|
||||||
logger.debug(f"Could not get public IPv{protocol} : {e}")
|
try:
|
||||||
return None
|
return download_text(url, timeout=30).strip()
|
||||||
|
except Exception as e:
|
||||||
|
logger.debug(
|
||||||
|
"Could not get public IPv%s from %s : %s" % (str(protocol), url, str(e))
|
||||||
|
)
|
||||||
|
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
def get_network_interfaces():
|
def get_network_interfaces():
|
||||||
|
|
Loading…
Add table
Reference in a new issue