]> git.ipfire.org Git - pbs.git/commitdiff
mirrors: Don't send clients to a mirror they don't support
authorMichael Tremer <michael.tremer@ipfire.org>
Thu, 13 Feb 2025 20:44:29 +0000 (20:44 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Thu, 13 Feb 2025 20:44:29 +0000 (20:44 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/web/mirrors.py

index c477d2285dd37e4820cc1691bce922c1ab0cac48..b68fb6284ae88e6f47bb6bc481f77ad0cf88b28e 100644 (file)
@@ -1,6 +1,7 @@
 #!/usr/bin/python
 
 import datetime
+import ipaddress
 import logging
 import stat
 import tornado.web
@@ -153,6 +154,14 @@ class DownloadsHandler(base.BaseHandler):
 
                # Walk through all mirrors
                for mirror in mirrors:
+                       # Don't send clients to a mirror they don't support
+                       if isinstance(self.current_address, ipaddress.IPv6Address):
+                               if not mirror.supports_ipv6():
+                                       continue
+                       elif isinstance(self.current_address, ipaddress.IPv4Address):
+                               if not mirror.supports_ipv4():
+                                       continue
+
                        # Skip the mirror if it does not serve the file we are looking for
                        if not await mirror.serves_file(path):
                                continue