Browse Source

Client: use ping or ping6 where appropriate

Baptiste Jonglez 10 years ago
parent
commit
5a9b80539d
1 changed files with 5 additions and 1 deletions
  1. 5 1
      peerfinderv2/client.py

+ 5 - 1
peerfinderv2/client.py

@@ -19,7 +19,11 @@ ping_regexp = re.compile(r"time=(.*) ms")
 
 def ping(target, nb_pings=NB_PINGS):
     """Returns the list of latencies towards the given target"""
-    args = ["ping", "-n", "-c", str(nb_pings), str(target.address)]
+    if target.family == pf.IPAddress.IPV4:
+        ping = "ping"
+    elif target.family == pf.IPAddress.IPV6:
+        ping = "ping6"
+    args = [ping, "-n", "-c", str(nb_pings), str(target.address)]
     try:
         out = subprocess.check_output(args, shell=False)
     except subprocess.CalledProcessError: