From patchwork Mon Apr 20 16:35:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Rakotojaona X-Patchwork-Id: 1600 Return-Path: Delivered-To: patchwork@archlinux.org Received: from apollo.archlinux.org (localhost [127.0.0.1]) by apollo.archlinux.org (Postfix) with ESMTP id 2F929184E1DA8 for ; Mon, 20 Apr 2020 16:34:55 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on apollo.archlinux.org X-Spam-Level: X-Spam-Status: No, score=-1.7 required=5.0 tests=DKIM_ADSP_CUSTOM_MED=0.001, DKIM_INVALID=1,DKIM_SIGNED=0.1,FREEMAIL_FROM=0.5,MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3,SPF_HELO_NONE=0.001,T_DMARC_POLICY_NONE=0.01, T_DMARC_SIMPLE_DKIM=0.01 autolearn=ham autolearn_force=no version=3.4.4 X-Spam-BL-Results: [127.0.0.10] [127.0.9.2] [127.0.0.11] Received: from orion.archlinux.org (orion.archlinux.org [88.198.91.70]) by apollo.archlinux.org (Postfix) with ESMTPS for ; Mon, 20 Apr 2020 16:34:55 +0000 (UTC) Received: from orion.archlinux.org (localhost [127.0.0.1]) by orion.archlinux.org (Postfix) with ESMTP id A902E1B1FBA163; Mon, 20 Apr 2020 16:34:53 +0000 (UTC) Received: from luna.archlinux.org (luna.archlinux.org [5.9.250.164]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits)) (No client certificate requested) (Authenticated sender: luna) by orion.archlinux.org (Postfix) with ESMTPSA id 6E6371B1FBA15F; Mon, 20 Apr 2020 16:34:53 +0000 (UTC) Authentication-Results: orion.archlinux.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=T/JunzuF Received: from luna.archlinux.org (luna.archlinux.org [127.0.0.1]) by luna.archlinux.org (Postfix) with ESMTP id 63B082B29A; Mon, 20 Apr 2020 16:34:53 +0000 (UTC) Authentication-Results: luna.archlinux.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=T/JunzuF Received: from luna.archlinux.org (luna.archlinux.org [127.0.0.1]) by luna.archlinux.org (Postfix) with ESMTP id 1C6F22B2A1 for ; Mon, 20 Apr 2020 16:34:51 +0000 (UTC) Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) by luna.archlinux.org (Postfix) with ESMTPS for ; Mon, 20 Apr 2020 16:34:51 +0000 (UTC) Received: by mail-wr1-x42c.google.com with SMTP id k11so13006073wrp.5 for ; Mon, 20 Apr 2020 09:34:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=scxBQzcff6EkNiVSLQkHtP6u3tnZQeFQ8cAi+tdo564=; b=T/JunzuF91SPdK527BabIZd/54X9aVgG5j9qcKCfbS8zNDEUml4YAeqMnBa94t3XVi PG2HVycIDMlGpKvp+OsLmgeWQO/J5pWL/Bx7sDVH0wOGJqvURagzkk3wFgFbVz1Ysc8e FDM/Vx3x27PN+CMXIS2Gltwqta/pldsfkVymNtiM8OGvCgdmoV2cZONy4P3wEARs2WEE jIFZKdkIZettSF07XwlSMr2BbjgRDWqQK+V7c/Wcv1c1iofdlrm7j5AVDmww/cp1/i4O hgdMP/FeqS2juYbi6UjXNUvYHVclrcD8JS1LmVA8mAuA8pPddrSudL5k0NN5vB9K29c4 KxOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=scxBQzcff6EkNiVSLQkHtP6u3tnZQeFQ8cAi+tdo564=; b=boDU7hu7a5PacQIV6VO3b2vxmt5YQFsf1imID1G++5WLXfI/3BqC9iuUIJO/kcnGwA 8btAr64CY2FnpBpntDg9TE40nHygZe31FKrNBgY2heESXjN7iy6IqFPAEJXeycNs7c4V f4PjtOnkpNZSwWYVtuAuOzO335ffXoqlg3cdFN3+OUpsKXffysC393lUDsdR55ZJTpr+ kn1uE+WQq1NcQZGOy305ALP8+tnX31jozXS6KnfXa1kFSRgT7tcPs/YNp9jZsDP5MEfR 3dxKCxct0RWBv5oyJa/6UYcFump6G2/4kpNXLpG+4wGebfLir53CI+oPx4BxN/FmFWTH bp+Q== X-Gm-Message-State: AGi0PuZlUX0yVsJVxCVxLWHFOUsKVouBNerfo1tmsdAM968A25wYWgrk 2zoq4LW9B2GhxULRwIXqpVB6TMPQ X-Google-Smtp-Source: APiQypLBTo5cPsm28alxqGqX2ItIn/6+/jfVsq0Cyq+PuN3+kC5y3RGI9GirdiI+VH+YNQHesN2Cdg== X-Received: by 2002:adf:dd83:: with SMTP id x3mr19389051wrl.298.1587400489753; Mon, 20 Apr 2020 09:34:49 -0700 (PDT) Received: from kpad.localdomain (87.234.118.80.rev.sfr.net. [80.118.234.87]) by smtp.gmail.com with ESMTPSA id h3sm11602wrm.73.2020.04.20.09.34.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Apr 2020 09:34:48 -0700 (PDT) From: Matthieu Rakotojaona To: pacman-contrib@lists.archlinux.org Subject: [PATCH] [rankmirrors] Follow redirects Date: Mon, 20 Apr 2020 18:35:34 +0200 Message-Id: <20200420163534.157678-1-matthieu.rakotojaona@gmail.com> X-Mailer: git-send-email 2.26.0 MIME-Version: 1.0 X-BeenThere: pacman-contrib@lists.archlinux.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussion list for pacman-contrib development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: pacman-contrib-bounces@lists.archlinux.org Sender: "pacman-contrib" Signed-off-by: Matthieu Rakotojaona --- As initially discussed in https://bbs.archlinux.org/viewtopic.php?id=254562, rankmirrors by default doesn't follow redirects, so when curl returns a 301 it assumes it's not a 4xx and so the mirror is considered valid. However if the 301 works but the actual mirror fails, such as for http://archlinux.vi-di.fr/core/os/x86_84, the mirror is still marked as valid src/rankmirrors.sh.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rankmirrors.sh.in b/src/rankmirrors.sh.in index c2f564b..a8de15c 100644 --- a/src/rankmirrors.sh.in +++ b/src/rankmirrors.sh.in @@ -62,7 +62,7 @@ err() { # gettime fetchurl (e.g gettime http://foo.com/core/os/i686/core.db.tar.gz) # returns the fetching time, or timeout, or unreachable gettime() { - IFS=' ' output=( $(curl -s -m $MAX_TIME -w "%{time_total} %{http_code}" "$1" -o/dev/null) ) + IFS=' ' output=( $(curl -L -s -m $MAX_TIME -w "%{time_total} %{http_code}" "$1" -o/dev/null) ) (( $? == 28 )) && echo timeout && return (( ${output[1]} >= 400 || ! ${output[1]} )) && echo unreachable && return echo "${output[0]}"