Formatting code for CkOpenNICDNSSpeed


show source only

======""OpenNIC"" fastest DNS server lister======

This script prints a list of ""OpenNIC"" public DNS servers sorted by the shortest ping time (average of 10 tries).

====Requirements====

~-php5-cli
~-coreutils

====The script====
>>Update 2012-05-21: now it shows if a server has timed out>>
%%(php;1;CkOpenNICDNSSpeed.php)
#!/usr/bin/php -q

<?php

/*
CkOpenNICDNSSpeed - a script for finding the fastest OpenNIC DNS servers
Copyright (C) 2012 Ɓukasz "Cyber Killer" Korpalski

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

$dnsaddr=array( //opennic ipv4 dns servers as of 2012-03-27
"66.244.95.20"=>"0",
"74.207.247.4"=>"0",
"216.87.84.211"=>"0",
"64.0.55.201"=>"0",
"69.164.196.21"=>"0",
"72.232.162.195"=>"0",
"205.185.120.143"=>"0",
"184.154.13.11"=>"0",
"128.173.89.246"=>"0",
"68.68.18.197"=>"0",
"74.212.172.171"=>"0",
"108.174.52.189"=>"0",
"89.16.173.11"=>"0",
"192.121.121.14"=>"0",
"192.121.86.100"=>"0",
"109.124.157.251"=>"0",
"27.110.120.30"=>"0",
"109.235.51.12"=>"0",
"195.46.245.59"=>"0",
"217.171.190.12"=>"0",
"92.243.8.139"=>"0",
"82.237.169.10"=>"0",
"178.63.26.173"=>"0",
"178.63.26.174"=>"0",
"83.223.73.116"=>"0",
"217.79.186.148"=>"0",
"178.63.26.172"=>"0",
"217.6.34.47"=>"0",
"217.6.34.48"=>"0",
"78.138.97.33"=>"0",
"62.146.14.194"=>"0",
"89.185.225.28"=>"0",
"67.212.90.199"=>"0",
"66.206.229.62"=>"0",
"216.167.252.195"=>"0",
"216.167.252.197"=>"0",
"74.115.206.100"=>"0",
"202.83.95.227"=>"0",
"85.126.4.170"=>"0"
);

print("Pinging DNS servers, please wait...\n\n");

$i=0;

foreach($dnsaddr as $curip=>$time)
{
exec("ping -q -c 10 ".$curip."|tail -n 1|cut -d/ -f5",$temp);
if($temp[$i]!="")
{
$dnsaddr[$curip]=$temp[$i];
}
else
{
$dnsaddr[$curip]="timeout";
}
$i++;
}

asort($dnsaddr);

print("DNS server\tAverage ping\n");
foreach($dnsaddr as $curip=>$time)
{
print($curip."\t".$time."\n");
}

?>
%%

Just click grab to save the file, or copy&paste it yourself to your favorite editor. Remember to add executable permissions.

====License====

This program is under the [[http://www.gnu.org/licenses/gpl.html GNU GPL v3]] or later.

----::c::
CategoryProjekty
Valid XHTML 1.0 Transitional :: Valid CSS :: Powered by WikkaWiki