In this article, we will share a php program that can ping multiple ip addresses at the same time and then compare and find the fastest ip address in the network. This program is used to find the proxy ip address, but it is an artifact. In this article, we will share a php program that can ping multiple ip addresses at the same time and then compare and find the fastest ip address in the network. This program is used to find the proxy ip address, but it is an artifact.
Script ec (2); script
For the convenience of turning the wall, I bought a vpn and switched it to osx. The official website did not provide a suitable client, so I could not select the fastest line. So I wrote a script and manually pinged the fastest IP address.
The Code is as follows: |
|
$ Servers = array ( Array ('vip Dutch line 01', 'nl01. yyuu. me', '81. 4.105.195 ', '2017 or 123 '), Array ('vip French line 01', 'fr01. yyuu. me', '192. 31.206.242 ', '192, 176, 4122 '), Array ('vip Italian line 01', 'it01. yyuu. me', '37. 247.48.226 ', '2017 or 123 '), Array ('vip Singapore line 01', 'sg01. yyuu. me', '199.69.209 ', '2017 or 123 ') );
// Used with pcntl_signal Declare (ticks = 1 ); // Maximum number of sub-Processes $ Max = count ($ servers ); // Current number of sub-Processes $ Child = 0;
// This function is triggered when the sub-process exits. Function sig_handler ($ sig ){ Switch ($ sig ){ Case SIGCHLD: // Do something } }
// Register the function called when the sub-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 (); } } |