3 * status-srv/ha.php: High-availibility pool - Reverse proxy
4 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Kristian Fiskerstrand
6 * This file is part of SKS Keyserver Pool (http://sks-keyservers.net)
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");
30 $servers = unserialize(file_get_contents(dirname(__FILE__
)."/sks_cache.serialized"));
31 $serverarr = $servers->get_servers();
33 $status_collection = unserialize(file_get_contents(dirname(__FILE__
)."/sks_cache_status_collection.serialized"));
34 $servercolarr = $status_collection->get_servers();
38 $array_of_all_online_servers = array();
39 $array_of_selected_servers = array();
42 foreach($serverarr as $server)
44 if(!(isset($servercolarr[$server->get_hostname()]['last_status']) && $servercolarr[$server->get_hostname()]['last_status']==1))
47 if(!$server->get_is_reverse_proxy())
50 if(!$server->get_is_loadbalanced())
53 $array_of_all_online_servers[] = array($server->get_hostname(), $server->get_ipv6());
56 // Select only 10 random servers
57 if(count($array_of_all_online_servers)>10)
59 $server_keys = array_rand($array_of_all_online_servers,10);
60 foreach($server_keys as $id)
62 $array_of_selected_servers[] = $array_of_all_online_servers[$id];
67 $array_of_selected_servers = $array_of_all_online_servers;
70 // Get IPs and print zone
72 $include_ipv6 = $servers->include_ipv6();
74 foreach($array_of_selected_servers as $server)
76 $ip=gethostbyname($server[0]);
78 // Correct for own host
79 if($ip=="192.168.0.65")
80 $ip = "37.191.231.105";
82 // End correct for own host
84 $pattern = "/^\d+\.\d+\.\d+\.\d+$/";
85 if(!preg_match($pattern, $ip)) continue;
86 echo "ha.pool A ".$ip."\n";
88 if($server[1] && $include_ipv6)
90 $ip=gethostbyname6($server[0]);
92 echo "ha.pool AAAA ".$ip."\n";