Hmm somehow there seem to be different version of ping supporting or not the -4 / -6 ... let's see if this workaroud works in all contexts

This commit is contained in:
Alexandre Aubin 2019-10-10 16:48:58 +02:00
parent 02d6a0212f
commit e67e9e27ba

View file

@ -113,9 +113,7 @@ class IPDiagnoser(Diagnoser):
# So let's try to ping the first 4~5 resolvers (shuffled)
# If we succesfully ping any of them, we conclude that we are indeed connected
def ping(protocol, target):
print("ping -c1 -%s -W 3 %s >/dev/null 2>/dev/null" % (protocol, target))
return os.system("ping -c1 -%s -W 3 %s >/dev/null 2>/dev/null" % (protocol, target)) == 0
return os.system("ping%s -c1 -W 3 %s >/dev/null 2>/dev/null" % ("" if protocol == 4 else "6", target)) == 0
random.shuffle(resolvers)
return any(ping(protocol, resolver) for resolver in resolvers[:5])