In order to turn the wall convenient, bought a VPN, go to OS X below the official did not provide the right client, can not choose the fastest line. So he wrote a script, manually ping the fastest IP.
The code is as follows |
Copy Code |
$servers = Array ( Array (' VIP Dutch line ', ' nl01.yyuu.me ', ' 81.4.105.195 ', ' 4122 or 3108 '), Array (' VIP French Line ', ' fr01.yyuu.me ', ' 176.31.206.242 ', ' 4122 or 3108 '), Array (' VIP Italian Line ', ' it01.yyuu.me ', ' 37.247.48.226 ', ' 4122 or 3108 '), Array (' VIP Singapore line ', ' sg01.yyuu.me ', ' 128.199.69.209 ', ' 4122 or 3108 ') ); Cooperate with pcntl_signal to use Declare (Ticks=1); Maximum number of child processes $max = count ($servers); Current number of child processes $child = 0; This function is triggered when a child process exits function Sig_handler ($sig) { Switch ($SIG) { Case SIGCHLD: Do something } } function to call when registering child process exits Pcntl_signal (SIGCHLD, "Sig_handler"); foreach ($servers as $server) { $pid = Pcntl_fork (); if ($pid) { Echo ' main thread start ', Php_eol; }else{ EXEC (' ping-c 1 '. $server [2], $result); echo $server [1]. ' '. $server [2]. ' '. $result [1],php_eol; Exit (); } } |