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");
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();
40 $array_of_all_online_servers = array();
41 $array_of_selected_servers = array();
44 foreach($serverarr as $server)
46 if(!(isset($servercolarr[$server->get_hostname()]['last_status']) && $servercolarr[$server->get_hostname()]['last_status']==1))
49 if(!$server->get_has_hkps())
52 if($server->get_affected_cve2014_3207())
56 $array_of_all_online_servers[] = array($server->get_hostname(), $server->get_ipv6(), $server->get_hkps_port());
59 // Select only 10 random servers
60 if(count($array_of_all_online_servers)>10)
62 $server_keys = array_rand($array_of_all_online_servers,10);
63 foreach($server_keys as $id)
65 $array_of_selected_servers[] = $array_of_all_online_servers[$id];
70 $array_of_selected_servers = $array_of_all_online_servers;
73 // Get IPs and print zone
75 $include_ipv6 = $servers->include_ipv6();
77 foreach($array_of_selected_servers as $server)
79 $ip=gethostbyname($server[0]);
80 // gethostbyname returns the unmodified hostname upon failure,
81 // so continue if this is encountered
85 // Correct for own host
86 if($ip=="192.168.0.65")
87 $ip = "37.191.231.105";
88 // End correct for own host
90 $pattern = "/^\d+\.\d+\.\d+\.\d+$/";
91 if(!preg_match($pattern, $ip)) continue;
94 echo "hkps.pool A ".$ip."\n";
96 if($server[2] == 443 && $server[1] && $include_ipv6)
98 $ip=gethostbyname6($server[0]);
99 if(!is_array($ip) && $ip != "")
100 echo "hkps.pool AAAA ".$ip."\n";
103 // Disabled due to GnuPG bug 1446 and 1447
104 //echo "_pgpkey-https._tcp.hkps.pool SRV 100 100 {$server[2]} {$server[0]}.\n";