Last active
November 8, 2017 13:30
-
-
Save picasso250/10e024caf8e0fa1bde70 to your computer and use it in GitHub Desktop.
fast cygwin mirror
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
foreach (file('http://cygwin.com/mirrors.lst') as $line) { | |
echo $line; | |
if (preg_match('%^\w+://([\w.-]+)/%', $line, $matches)) { | |
$host = $matches[1]; | |
if (!isset($table[$host])) { | |
$output = shell_exec("ping $matches[1]"); | |
echo $output; | |
if (preg_match('/(\d+)ms/', $output, $matches)) { | |
$table[$host] = $matches[1]; | |
error_log("$host\t$matches[1]\n",3,"mirrors_speed.log"); | |
} | |
} | |
} | |
} | |
asort($table); | |
print_r($table); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
mirrors.ustc.edu.cn 56
ftp.kaist.ac.kr 94