From 296cf837d26a6a138c28902a8813cf73b2545a97 Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Fri, 7 Jun 2019 21:32:35 +0200 Subject: pool.php: only offer mirror of correct IP version --- pool.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pool.php b/pool.php index 16da13a..ff26e5b 100644 --- a/pool.php +++ b/pool.php @@ -12,6 +12,12 @@ if (array_key_exists('HTTPS',$_SERVER) && ($_SERVER['HTTPS']=='on')) else $protocol = 'http'; +$ipv_filter = ''; +if (filter_var($_SERVER['SERVER_ADDR'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) + $ipv_filter .= ' AND `mirror_statuses`.`ipv4`'; +if (filter_var($_SERVER['SERVER_ADDR'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) + $ipv_filter .= ' AND `mirror_statuses`.`ipv6`'; + $result = mysql_run_query( 'SELECT `mirror_statuses`.`url` FROM `mirror_statuses`' . ' WHERE `mirror_statuses`.`active`' . @@ -19,6 +25,7 @@ $result = mysql_run_query( ' AND `mirror_statuses`.`start` > UNIX_TIMESTAMP(NOW())-' . $cutoff . ' AND `mirror_statuses`.`protocol` = "' . $protocol . '"' . ' AND `mirror_statuses`.`url` NOT LIKE "%.oss/%"' . + $ipv_filter . ' GROUP BY `mirror_statuses`.`url`' . ' ORDER BY SHA2(' . 'CONCAT(' . -- cgit v1.2.3-70-g09d2