dns: Reduce ttls
[sks-keyservers-pool.git] / sks-keyservers.net / status-srv / p80.php
blob01576de44be5c66a6018b8ad899b8aad87c782e2
1 <?
2 /*
3 * status-srv/p80.php
4 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Kristian Fiskerstrand
5 *
6 * This file is part of SKS Keyserver Pool (http://sks-keyservers.net)
7 *
8 * The Author can be reached by electronic mail at kf@sumptuouscapital.com
9 * Communication using OpenPGP is preferred - a copy of the public key 0x0B7F8B60E3EDFAE3
10 * is available in all the common keyservers or in hkp://pool.sks-keyservers.net
12 * This program is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation, either version 3 of the License, or
15 * (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program. If not, see <http://www.gnu.org/licenses/>.
26 require("sks.inc.php");
27 require("sks-status.inc.php");
29 header("Content-type: text/plain");
31 sleep(rand(1,10));
32 $servers = unserialize(file_get_contents(dirname(__FILE__)."/sks_cache.serialized"));
33 $serverarr = $servers->get_servers();
35 $status_collection = unserialize(file_get_contents(dirname(__FILE__)."/sks_cache_status_collection.serialized"));
36 $servercolarr = $status_collection->get_servers();
38 sort($serverarr);
40 $array_of_all_online_servers = array();
42 // Server selection
43 foreach($serverarr as $server)
45 if(!$server->get_port80()) continue;
46 if(!(isset($servercolarr[$server->get_hostname()]['last_status']) && $servercolarr[$server->get_hostname()]['last_status']==1)) continue;
47 $array_of_all_online_servers[] = array($server->get_hostname(), $server->get_ipv6());
50 // Select only 10 random servers
51 if(count($array_of_all_online_servers)>10)
53 $server_keys = array_rand($array_of_all_online_servers,10);
54 foreach($server_keys as $id)
56 $array_of_selected_servers[] = $array_of_all_online_servers[$id];
59 else
61 $array_of_selected_servers = $array_of_all_online_servers;
64 $include_ipv6 = $servers->include_ipv6();
66 // Get IPs and print zone
67 foreach($array_of_selected_servers as $servername)
69 $ip = gethostbyname($servername[0]);
70 // gethostbyname returns the unmodified hostname upon failure,
71 // so continue if this is encountered
72 if($ip == $servername[0])
73 continue;
75 // Correct for own host
76 if($ip=="192.168.0.65")
77 $ip = "37.191.231.105";
78 // End correct for own host
80 echo "p80.pool A ".$ip."\n";
82 if($servername[1] && $include_ipv6)
84 $ip6=gethostbyname6($servername[0]);
85 if(!is_array($ip6) && $ip6 != "")
86 echo "p80.pool AAAA ".$ip6."\n";