diff options
author | Florian Pritz <bluewind@xinu.at> | 2017-02-15 19:55:53 +0100 |
---|---|---|
committer | Angel Velasquez <angvp@archlinux.org> | 2017-02-17 12:17:13 -0500 |
commit | 644864de28eb8ccf992f90558a25e865d71f80f4 (patch) | |
tree | 3e3efa53fa626285e86dfa45c8c1bd0963af8e3b /mirrors/views | |
parent | 210eb68a41b29915312620f46b0b7e43a84061d2 (diff) | |
download | archweb-644864de28eb8ccf992f90558a25e865d71f80f4.tar.gz archweb-644864de28eb8ccf992f90558a25e865d71f80f4.zip |
Remove scored based mirrorlist sorting
Users may use the returned mirror list as-is without sorting it
themselves. This may lead to the first mirror in the list being
overloaded. Prevent this by not returning a sorted list.
References: https://lists.archlinux.org/pipermail/arch-dev-public/2017-January/028681.html
Signed-off-by: Florian Pritz <bluewind@xinu.at>
Diffstat (limited to 'mirrors/views')
-rw-r--r-- | mirrors/views/mirrorlist.py | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/mirrors/views/mirrorlist.py b/mirrors/views/mirrorlist.py index 3c68d036..0c9c0a7b 100644 --- a/mirrors/views/mirrorlist.py +++ b/mirrors/views/mirrorlist.py @@ -10,6 +10,7 @@ from django_countries import countries from ..models import MirrorUrl, MirrorProtocol from ..utils import get_mirror_statuses +import random class MirrorlistForm(forms.Form): country = forms.MultipleChoiceField(required=False, @@ -80,8 +81,8 @@ def status_filter(original_urls): # (as opposed to those that have been set with no score) if (u.id not in scores) or (u.score and u.score < 100.0): urls.append(u) - # if a url doesn't have a score, treat it as the highest possible - return sorted(urls, key=lambda x: x.score or 100.0) + # randomize list to prevent users from overloading the first mirror in the returned list + return random.shuffle(urls) def find_mirrors(request, countries=None, protocols=None, use_status=False, |