From 8d8614a8ad68096a6f6ec3a9b84ddc20d3b7aaed Mon Sep 17 00:00:00 2001 From: Xi Xu Date: Sun, 10 May 2026 13:00:03 +0800 Subject: [PATCH] fix(fedora): route through kernel.org mirror Use the kernel.org Fedora mirror to avoid upstream bot challenges. Preserve existing /pub/fedora/linux request paths with a Fedora transformer. Closes #271 --- README.md | 6 +++--- src/config/platform-catalog.js | 2 +- src/routing/platform-transformers.js | 10 ++++++++++ test/unit/platforms.test.js | 17 +++++++++++++++++ 4 files changed, 31 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 9ae9a6d..e83f35b 100644 --- a/README.md +++ b/README.md @@ -330,7 +330,7 @@ instance, simply replace the domain and add the platform prefix: | Flathub | `flathub` | `https://dl.flathub.org/...` | `https://xget.xi-xu.me/flathub/...` | | Debian | `debian` | `https://deb.debian.org/...` | `https://xget.xi-xu.me/debian/...` | | Ubuntu | `ubuntu` | `https://archive.ubuntu.com/...` | `https://xget.xi-xu.me/ubuntu/...` | -| Fedora | `fedora` | `https://dl.fedoraproject.org/...` | `https://xget.xi-xu.me/fedora/...` | +| Fedora | `fedora` | `https://mirrors.kernel.org/fedora/...` | `https://xget.xi-xu.me/fedora/...` | | Rocky Linux | `rocky` | `https://download.rockylinux.org/...` | `https://xget.xi-xu.me/rocky/...` | | openSUSE | `opensuse` | `https://download.opensuse.org/...` | `https://xget.xi-xu.me/opensuse/...` | | Arch Linux | `arch` | `https://geo.mirror.pkgbuild.com/...` | `https://xget.xi-xu.me/arch/...` | @@ -746,10 +746,10 @@ https://archive.ubuntu.com/ubuntu/pool/main/g/git/git_2.34.1-1ubuntu1.9_amd64.de https://xget.xi-xu.me/ubuntu/ubuntu/pool/main/g/git/git_2.34.1-1ubuntu1.9_amd64.deb # Fedora package original URL -https://dl.fedoraproject.org/pub/fedora/linux/releases/39/Everything/x86_64/os/Packages/n/nginx-1.24.0-1.fc39.x86_64.rpm +https://mirrors.kernel.org/fedora/releases/39/Everything/x86_64/os/Packages/n/nginx-1.24.0-1.fc39.x86_64.rpm # Converted (add fedora prefix) -https://xget.xi-xu.me/fedora/pub/fedora/linux/releases/39/Everything/x86_64/os/Packages/n/nginx-1.24.0-1.fc39.x86_64.rpm +https://xget.xi-xu.me/fedora/releases/39/Everything/x86_64/os/Packages/n/nginx-1.24.0-1.fc39.x86_64.rpm # Rocky Linux package original URL https://download.rockylinux.org/pub/rocky/9/BaseOS/x86_64/os/Packages/b/bash-5.1.8-6.el9.x86_64.rpm diff --git a/src/config/platform-catalog.js b/src/config/platform-catalog.js index 89e493a..f65306d 100644 --- a/src/config/platform-catalog.js +++ b/src/config/platform-catalog.js @@ -57,7 +57,7 @@ export const PLATFORM_CATALOG = { // Linux Distributions debian: 'https://deb.debian.org', ubuntu: 'https://archive.ubuntu.com', - fedora: 'https://dl.fedoraproject.org', + fedora: 'https://mirrors.kernel.org/fedora', rocky: 'https://download.rockylinux.org', opensuse: 'https://download.opensuse.org', arch: 'https://geo.mirror.pkgbuild.com', diff --git a/src/routing/platform-transformers.js b/src/routing/platform-transformers.js index 2d9de9a..e90dc18 100644 --- a/src/routing/platform-transformers.js +++ b/src/routing/platform-transformers.js @@ -56,6 +56,15 @@ function transformCratesPath(transformedPath) { return `/api/v1/crates${transformedPath}`; } +/** + * Applies Fedora mirror path normalization. + * @param {string} transformedPath + * @returns {string} Normalized Fedora mirror path. + */ +function transformFedoraPath(transformedPath) { + return transformedPath.replace(/^\/pub\/fedora\/linux(?=\/|$)/, '') || '/'; +} + /** * Applies Jenkins update-center path normalization. * @param {string} transformedPath @@ -88,6 +97,7 @@ function transformJenkinsPath(transformedPath) { /** @type {{ [key: string]: (transformedPath: string) => string }} */ const PLATFORM_PATH_TRANSFORMERS = { crates: transformCratesPath, + fedora: transformFedoraPath, jenkins: transformJenkinsPath }; diff --git a/test/unit/platforms.test.js b/test/unit/platforms.test.js index 703ff77..800926a 100644 --- a/test/unit/platforms.test.js +++ b/test/unit/platforms.test.js @@ -143,6 +143,19 @@ describe('Platform Configuration', () => { ); }); + it('should transform Fedora mirror paths correctly', () => { + expect( + transformPath( + '/fedora/pub/fedora/linux/releases/43/Everything/x86_64/os/repodata/repomd.xml', + 'fedora' + ) + ).toBe('/releases/43/Everything/x86_64/os/repodata/repomd.xml'); + + expect( + transformPath('/fedora/releases/43/Everything/x86_64/os/repodata/repomd.xml', 'fedora') + ).toBe('/releases/43/Everything/x86_64/os/repodata/repomd.xml'); + }); + it('should transform container registry paths correctly', () => { expect( transformPath('/cr/ghcr/v2/nginxinc/nginx-unprivileged/manifests/latest', 'cr-ghcr') @@ -204,6 +217,10 @@ describe('Platform Configuration', () => { expect(PLATFORMS.flathub).toBe('https://dl.flathub.org'); }); + it('should use a Fedora mirror that avoids upstream bot challenges', () => { + expect(PLATFORMS.fedora).toBe('https://mirrors.kernel.org/fedora'); + }); + it('should have correct container registry base URLs', () => { expect(PLATFORMS['cr-ghcr']).toBe('https://ghcr.io'); expect(PLATFORMS['cr-gcr']).toBe('https://gcr.io');