summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2019-06-07 21:32:35 +0200
committerErich Eckner <git@eckner.net>2019-06-07 21:32:35 +0200
commit296cf837d26a6a138c28902a8813cf73b2545a97 (patch)
treea9e27154bdb6a511de5bd5a42ee6746cb769610c
parente1752f263031860b7b374f7d715c395f8f87eaaa (diff)
downloadarchweb32-296cf837d26a6a138c28902a8813cf73b2545a97.tar.xz
pool.php: only offer mirror of correct IP version
-rw-r--r--pool.php7
1 files changed, 7 insertions, 0 deletions
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(' .