From: Michael Tremer Date: Thu, 13 Feb 2025 20:44:29 +0000 (+0000) Subject: mirrors: Don't send clients to a mirror they don't support X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=84aeeab123cdbd6c175300f34e909c03bec85365;p=pbs.git mirrors: Don't send clients to a mirror they don't support Signed-off-by: Michael Tremer --- diff --git a/src/web/mirrors.py b/src/web/mirrors.py index c477d228..b68fb628 100644 --- a/src/web/mirrors.py +++ b/src/web/mirrors.py @@ -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