dns: Reduce ttls
[sks-keyservers-pool.git] / sks-keyservers.net / status-srv / ip.php
blobf4030b73baa37cb612f6a2e1d26fac2c7c2eeda4
1 <?
2 /*
3 * status-srv/ip.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");
28 header("Content-type: text/plain");
29 $servers = unserialize(file_get_contents(dirname(__FILE__)."/sks_cache.serialized"));
30 $serverarr = $servers->get_servers();
32 $status_collection = unserialize(file_get_contents(dirname(__FILE__)."/sks_cache_status_collection.serialized"));
33 $servercolarr = $status_collection->get_servers();
35 sort($serverarr);
37 $array_of_all_online_servers = array();
38 $array_of_selected_servers = array();
40 // Server selection
41 foreach($serverarr as $server)
43 if(!(isset($servercolarr[$server->get_hostname()]['last_status']) && $servercolarr[$server->get_hostname()]['last_status']==1)) continue;
44 $array_of_all_online_servers[] = array($server->get_hostname(), $server->get_ipv6());
47 // Select only 10 random servers
48 if(count($array_of_all_online_servers)>10)
50 $server_keys = array_rand($array_of_all_online_servers,10);
51 foreach($server_keys as $id)
53 $array_of_selected_servers[] = $array_of_all_online_servers[$id];
56 else
58 $array_of_selected_servers = $array_of_all_online_servers;
61 // Get IPs and print zone
62 foreach($array_of_selected_servers as $server)
64 $ip=gethostbyname($server[0]);
65 // gethostbyname returns the unmodified hostname upon failure,
66 // so continue if this is encountered
67 if($ip == $server[0])
68 continue;
70 // Correct for own host
71 if($ip=="192.168.0.65")
72 $ip = "37.191.231.105";
73 // End correct for own host
75 $pattern = "/^\d+\.\d+\.\d+\.\d+$/";
76 if(!preg_match($pattern, $ip)) continue;
77 echo "pool A ".$ip."\n";
78 echo "ipv4.pool A ".$ip."\n";