From 6f0914e001221b16bbbfa2a7a3a0c408472f118b Mon Sep 17 00:00:00 2001 From: Xi Xu Date: Fri, 8 Aug 2025 18:44:39 +0800 Subject: [PATCH] Add AOSP, CPAN, and CTAN platform support Added support and documentation for AOSP (Android Open Source Project), CPAN (Perl), and CTAN (TeX/LaTeX) mirrors in both English and Chinese README files. Updated src/config/platforms.js to include these platforms. No functional changes to request handling logic. --- README.en.md | 133 +++++++++++++++++++++++++++++++++++++ README.md | 141 ++++++++++++++++++++++++++++++++++++++++ src/config/platforms.js | 3 + src/index.js | 8 +-- 4 files changed, 281 insertions(+), 4 deletions(-) diff --git a/README.en.md b/README.en.md index 303c92f..9885e26 100644 --- a/README.en.md +++ b/README.en.md @@ -10,6 +10,7 @@ [![Gitea](https://img.shields.io/badge/Gitea-609926?&logo=gitea&logoColor=white)](#gitea) [![Codeberg](https://img.shields.io/badge/Codeberg-2185D0?&logo=codeberg&logoColor=white)](#codeberg) [![SourceForge](https://img.shields.io/badge/SourceForge-FF6600?&logo=sourceforge&logoColor=white)](#sourceforge) +[![AOSP](https://img.shields.io/badge/AOSP-3DDC84?&logo=android&logoColor=white)](#aosp-android-open-source-project) [![Hugging Face](https://img.shields.io/badge/Hugging%20Face-FFD21E?&logo=huggingface&logoColor=white)](#hugging-face-mirror) [![npm](https://img.shields.io/badge/npm-CB3837?logo=npm&logoColor=white)](#npm-package-acceleration) [![PyPI](https://img.shields.io/badge/PyPI-3775A9?logo=pypi&logoColor=white)](#python-package-acceleration) @@ -18,6 +19,8 @@ [![Gradle](https://img.shields.io/badge/Gradle-02303A?logo=gradle&logoColor=white)](#gradle-package-acceleration) [![RubyGems](https://img.shields.io/badge/RubyGems-CC342D?logo=rubygems&logoColor=white)](#ruby-package-acceleration) [![CRAN](https://img.shields.io/badge/CRAN-276DC3?logo=r&logoColor=white)](#r-package-acceleration) +[![CPAN](https://img.shields.io/badge/CPAN-39457E?logo=perl&logoColor=white)](#perl-package-acceleration) +[![CTAN](https://img.shields.io/badge/CTAN-008080?logo=latex&logoColor=white)](#tex-latex-package-acceleration) [![Go](https://img.shields.io/badge/Go-00ADD8?logo=go&logoColor=white)](#go-module-acceleration) [![NuGet](https://img.shields.io/badge/NuGet-004880?logo=nuget&logoColor=white)](#nuget-package-acceleration) [![Rust](https://img.shields.io/badge/Rust-000000?logo=rust&logoColor=white)](#rust-package-acceleration) @@ -125,6 +128,7 @@ Using the public instance [**`xget.xi-xu.me`**](https://xget.xi-xu.me) or your o | Gitea | `gitea` | `https://gitea.com/...` | `https://xget.xi-xu.me/gitea/...` | | Codeberg | `codeberg` | `https://codeberg.org/...` | `https://xget.xi-xu.me/codeberg/...` | | SourceForge | `sf` | `https://sourceforge.net/...` | `https://xget.xi-xu.me/sf/...` | +| AOSP | `aosp` | `https://android.googlesource.com/...` | `https://xget.xi-xu.me/aosp/...` | | Hugging Face | `hf` | `https://huggingface.co/...` | `https://xget.xi-xu.me/hf/...` | | npm | `npm` | `https://registry.npmjs.org/...` | `https://xget.xi-xu.me/npm/...` | | PyPI | `pypi` | `https://pypi.org/...` | `https://xget.xi-xu.me/pypi/...` | @@ -133,6 +137,8 @@ Using the public instance [**`xget.xi-xu.me`**](https://xget.xi-xu.me) or your o | Gradle | `gradle` | `https://plugins.gradle.org/...` | `https://xget.xi-xu.me/gradle/...` | | RubyGems | `rubygems` | `https://rubygems.org/...` | `https://xget.xi-xu.me/rubygems/...` | | CRAN | `cran` | `https://cran.r-project.org/...` | `https://xget.xi-xu.me/cran/...` | +| CPAN | `cpan` | `https://www.cpan.org/...` | `https://xget.xi-xu.me/cpan/...` | +| CTAN | `ctan` | `https://tug.ctan.org/...` | `https://xget.xi-xu.me/ctan/...` | | Go Modules | `golang` | `https://proxy.golang.org/...` | `https://xget.xi-xu.me/golang/...` | | NuGet | `nuget` | `https://api.nuget.org/...` | `https://xget.xi-xu.me/nuget/...` | | Rust Crates | `crates` | `https://crates.io/...` | `https://xget.xi-xu.me/crates/...` | @@ -199,6 +205,22 @@ https://sourceforge.net/projects/sevenzip/files/7-Zip/23.01/7z2301-x64.exe/downl https://xget.xi-xu.me/sf/projects/sevenzip/files/7-Zip/23.01/7z2301-x64.exe/download ``` +#### AOSP (Android Open Source Project) + +```url +# AOSP project original link +https://android.googlesource.com/platform/frameworks/base + +# Converted (add aosp prefix) +https://xget.xi-xu.me/aosp/platform/frameworks/base + +# AOSP device tree original link +https://android.googlesource.com/device/google/pixel + +# Converted (add aosp prefix) +https://xget.xi-xu.me/aosp/device/google/pixel +``` + #### Hugging Face ```url @@ -327,6 +349,38 @@ https://cran.r-project.org/web/packages/dplyr/DESCRIPTION https://xget.xi-xu.me/cran/web/packages/dplyr/DESCRIPTION ``` +#### CPAN (Perl Package Management) + +```url +# CPAN module original link +https://www.cpan.org/modules/by-module/DBI/DBI-1.643.tar.gz + +# Converted (add cpan prefix) +https://xget.xi-xu.me/cpan/modules/by-module/DBI/DBI-1.643.tar.gz + +# CPAN author package original link +https://www.cpan.org/authors/id/T/TI/TIMB/DBI-1.643.tar.gz + +# Converted (add cpan prefix) +https://xget.xi-xu.me/cpan/authors/id/T/TI/TIMB/DBI-1.643.tar.gz +``` + +#### CTAN (TeX/LaTeX Package Management) + +```url +# CTAN package file original link +https://tug.ctan.org/tex-archive/macros/latex/contrib/beamer.zip + +# Converted (add ctan prefix) +https://xget.xi-xu.me/ctan/tex-archive/macros/latex/contrib/beamer.zip + +# CTAN font file original link +https://tug.ctan.org/tex-archive/fonts/cm/pk/ljfour/public/cm/dpi600/cmr10.pk + +# Converted (add ctan prefix) +https://xget.xi-xu.me/ctan/tex-archive/fonts/cm/pk/ljfour/public/cm/dpi600/cmr10.pk +``` + #### Go Modules ```url @@ -536,6 +590,9 @@ git clone https://xget.xi-xu.me/codeberg/forgejo/forgejo.git # Clone SourceForge repository git clone https://xget.xi-xu.me/sf/projects/mingw-w64/code.git +# Clone AOSP repository +git clone https://xget.xi-xu.me/aosp/platform/frameworks/base.git + # Add remote repository git remote add upstream https://xget.xi-xu.me/gh/[owner]/[repository].git @@ -555,6 +612,7 @@ git config --global url."https://xget.xi-xu.me/gl/".insteadOf "https://gitlab.co git config --global url."https://xget.xi-xu.me/gitea/".insteadOf "https://gitea.com/" git config --global url."https://xget.xi-xu.me/codeberg/".insteadOf "https://codeberg.org/" git config --global url."https://xget.xi-xu.me/sf/".insteadOf "https://sourceforge.net/" +git config --global url."https://xget.xi-xu.me/aosp/".insteadOf "https://android.googlesource.com/" # Verify configuration git config --global --get-regexp url @@ -563,6 +621,7 @@ git config --global --get-regexp url git clone https://github.com/microsoft/vscode.git # Automatically converted to Xget link git clone https://gitlab.com/gitlab-org/gitlab.git # Automatically converted to Xget link git clone https://codeberg.org/forgejo/forgejo.git # Automatically converted to Xget link +git clone https://android.googlesource.com/platform/frameworks/base.git # Automatically converted to Xget link ``` ### Mainstream Download Tool Integration @@ -1010,6 +1069,80 @@ go get -u ./... go clean -modcache ``` +### Perl Package Acceleration + +#### Configure CPAN to use Xget mirror + +```bash +# Configure cpan to use Xget mirror +cpan -o conf urllist push https://xget.xi-xu.me/cpan/ + +# Or configure cpanm +cpanm --mirror https://xget.xi-xu.me/cpan/ Module::Name + +# Configure in .cpan/CPAN/MyConfig.pm +$CPAN::Config->{urllist} = [qw[https://xget.xi-xu.me/cpan/]]; +``` + +#### Use in projects + +```bash +# Install Perl modules using cpanm +cpanm --mirror https://xget.xi-xu.me/cpan/ DBI +cpanm --mirror https://xget.xi-xu.me/cpan/ Moose +cpanm --mirror https://xget.xi-xu.me/cpan/ LWP::UserAgent + +# Install from cpanfile +cpanm --mirror https://xget.xi-xu.me/cpan/ --installdeps . + +# Install specific version +cpanm --mirror https://xget.xi-xu.me/cpan/ DBI@1.643 +``` + +### TeX/LaTeX Package Acceleration + +#### Configure TeX Live to use Xget mirror + +```bash +# Configure TeX Live package manager +tlmgr option repository https://xget.xi-xu.me/ctan/systems/texlive/tlnet + +# Verify configuration +tlmgr option repository + +# Update package database +tlmgr update --self --all +``` + +#### Configure MiKTeX to use Xget mirror + +```bash +# Configure MiKTeX to use Xget mirror +mpm --set-repository https://xget.xi-xu.me/ctan/systems/win32/miktex/tm/packages/ + +# Update package database +mpm --update-db + +# Install packages +mpm --install beamer +mpm --install pgf +``` + +#### Use in projects + +```bash +# Install LaTeX packages using tlmgr +tlmgr install beamer +tlmgr install pgf +tlmgr install tikz + +# Install packages from requirements file +tlmgr install --file package-list.txt + +# Update all packages +tlmgr update --all +``` + ### NuGet Package Acceleration #### Configure NuGet to use Xget mirror diff --git a/README.md b/README.md index 8b34150..004c6ac 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,7 @@ [![Gitea](https://img.shields.io/badge/Gitea-609926?&logo=gitea&logoColor=white)](#gitea) [![Codeberg](https://img.shields.io/badge/Codeberg-2185D0?&logo=codeberg&logoColor=white)](#codeberg) [![SourceForge](https://img.shields.io/badge/SourceForge-FF6600?&logo=sourceforge&logoColor=white)](#sourceforge) +[![AOSP](https://img.shields.io/badge/AOSP-3DDC84?&logo=android&logoColor=white)](#aosp-android-%E5%BC%80%E6%BA%90%E9%A1%B9%E7%9B%AE) [![Hugging Face](https://img.shields.io/badge/Hugging%20Face-FFD21E?&logo=huggingface&logoColor=white)](#hugging-face-镜像) [![npm](https://img.shields.io/badge/npm-CB3837?logo=npm&logoColor=white)](#npm-包管理加速) [![PyPI](https://img.shields.io/badge/PyPI-3775A9?logo=pypi&logoColor=white)](#python-包管理加速) @@ -18,6 +19,8 @@ [![Gradle](https://img.shields.io/badge/Gradle-02303A?logo=gradle&logoColor=white)](#gradle-包管理加速) [![RubyGems](https://img.shields.io/badge/RubyGems-CC342D?logo=rubygems&logoColor=white)](#ruby-包管理加速) [![CRAN](https://img.shields.io/badge/CRAN-276DC3?logo=r&logoColor=white)](#r-包管理加速) +[![CPAN](https://img.shields.io/badge/CPAN-39457E?logo=perl&logoColor=white)](#perl-包管理加速) +[![CTAN](https://img.shields.io/badge/CTAN-008080?logo=latex&logoColor=white)](#tex-latex-包管理加速) [![Go](https://img.shields.io/badge/Go-00ADD8?logo=go&logoColor=white)](#go-模块加速) [![NuGet](https://img.shields.io/badge/NuGet-004880?logo=nuget&logoColor=white)](#nuget-包管理加速) [![Rust](https://img.shields.io/badge/Rust-000000?logo=rust&logoColor=white)](#rust-包管理加速) @@ -125,6 +128,7 @@ | Gitea | `gitea` | `https://gitea.com/...` | `https://xget.xi-xu.me/gitea/...` | | Codeberg | `codeberg` | `https://codeberg.org/...` | `https://xget.xi-xu.me/codeberg/...` | | SourceForge | `sf` | `https://sourceforge.net/...` | `https://xget.xi-xu.me/sf/...` | +| AOSP | `aosp` | `https://android.googlesource.com/...` | `https://xget.xi-xu.me/aosp/...` | | Hugging Face | `hf` | `https://huggingface.co/...` | `https://xget.xi-xu.me/hf/...` | | npm | `npm` | `https://registry.npmjs.org/...` | `https://xget.xi-xu.me/npm/...` | | PyPI | `pypi` | `https://pypi.org/...` | `https://xget.xi-xu.me/pypi/...` | @@ -133,6 +137,8 @@ | Gradle | `gradle` | `https://plugins.gradle.org/...` | `https://xget.xi-xu.me/gradle/...` | | RubyGems | `rubygems` | `https://rubygems.org/...` | `https://xget.xi-xu.me/rubygems/...` | | CRAN | `cran` | `https://cran.r-project.org/...` | `https://xget.xi-xu.me/cran/...` | +| CPAN | `cpan` | `https://www.cpan.org/...` | `https://xget.xi-xu.me/cpan/...` | +| CTAN | `ctan` | `https://tug.ctan.org/...` | `https://xget.xi-xu.me/ctan/...` | | Go 模块 | `golang` | `https://proxy.golang.org/...` | `https://xget.xi-xu.me/golang/...` | | NuGet | `nuget` | `https://api.nuget.org/...` | `https://xget.xi-xu.me/nuget/...` | | Rust Crates | `crates` | `https://crates.io/...` | `https://xget.xi-xu.me/crates/...` | @@ -199,6 +205,22 @@ https://sourceforge.net/projects/sevenzip/files/7-Zip/23.01/7z2301-x64.exe/downl https://xget.xi-xu.me/sf/projects/sevenzip/files/7-Zip/23.01/7z2301-x64.exe/download ``` +#### AOSP (Android 开源项目) + +```url +# AOSP 项目原始链接 +https://android.googlesource.com/platform/frameworks/base + +# 转换后(添加 aosp 前缀) +https://xget.xi-xu.me/aosp/platform/frameworks/base + +# AOSP 设备树原始链接 +https://android.googlesource.com/device/google/pixel + +# 转换后(添加 aosp 前缀) +https://xget.xi-xu.me/aosp/device/google/pixel +``` + #### Hugging Face ```url @@ -327,6 +349,38 @@ https://cran.r-project.org/web/packages/dplyr/DESCRIPTION https://xget.xi-xu.me/cran/web/packages/dplyr/DESCRIPTION ``` +#### CPAN (Perl 包管理) + +```url +# CPAN 模块原始链接 +https://www.cpan.org/modules/by-module/DBI/DBI-1.643.tar.gz + +# 转换后(添加 cpan 前缀) +https://xget.xi-xu.me/cpan/modules/by-module/DBI/DBI-1.643.tar.gz + +# CPAN 作者包原始链接 +https://www.cpan.org/authors/id/T/TI/TIMB/DBI-1.643.tar.gz + +# 转换后(添加 cpan 前缀) +https://xget.xi-xu.me/cpan/authors/id/T/TI/TIMB/DBI-1.643.tar.gz +``` + +#### CTAN (TeX/LaTeX 包管理) + +```url +# CTAN 包文件原始链接 +https://tug.ctan.org/tex-archive/macros/latex/contrib/beamer.zip + +# 转换后(添加 ctan 前缀) +https://xget.xi-xu.me/ctan/tex-archive/macros/latex/contrib/beamer.zip + +# CTAN 字体文件原始链接 +https://tug.ctan.org/tex-archive/fonts/cm/pk/ljfour/public/cm/dpi600/cmr10.pk + +# 转换后(添加 ctan 前缀) +https://xget.xi-xu.me/ctan/tex-archive/fonts/cm/pk/ljfour/public/cm/dpi600/cmr10.pk +``` + #### Go 模块 ```url @@ -536,6 +590,9 @@ git clone https://xget.xi-xu.me/codeberg/forgejo/forgejo.git # 克隆 SourceForge 存储库 git clone https://xget.xi-xu.me/sf/projects/mingw-w64/code.git +# 克隆 AOSP 存储库 +git clone https://xget.xi-xu.me/aosp/platform/frameworks/base.git + # 添加远程存储库 git remote add upstream https://xget.xi-xu.me/gh/[所有者]/[存储库].git @@ -555,6 +612,7 @@ git config --global url."https://xget.xi-xu.me/gl/".insteadOf "https://gitlab.co git config --global url."https://xget.xi-xu.me/gitea/".insteadOf "https://gitea.com/" git config --global url."https://xget.xi-xu.me/codeberg/".insteadOf "https://codeberg.org/" git config --global url."https://xget.xi-xu.me/sf/".insteadOf "https://sourceforge.net/" +git config --global url."https://xget.xi-xu.me/aosp/".insteadOf "https://android.googlesource.com/" # 验证配置 git config --global --get-regexp url @@ -563,6 +621,7 @@ git config --global --get-regexp url git clone https://github.com/microsoft/vscode.git # 自动转换为 Xget 链接 git clone https://gitlab.com/gitlab-org/gitlab.git # 自动转换为 Xget 链接 git clone https://codeberg.org/forgejo/forgejo.git # 自动转换为 Xget 链接 +git clone https://android.googlesource.com/platform/frameworks/base.git # 自动转换为 Xget 链接 ``` ### 主流下载工具集成 @@ -980,6 +1039,88 @@ install.packages(packages) " ``` +### Perl 包管理加速 + +#### 配置 CPAN 使用 Xget 镜像 + +```bash +# 配置 CPAN 使用 Xget 镜像 +cpan o conf urllist push https://xget.xi-xu.me/cpan/ +cpan o conf commit + +# 或者直接编辑配置文件 ~/.cpan/CPAN/MyConfig.pm +# 添加: +# 'urllist' => [q[https://xget.xi-xu.me/cpan/]], +``` + +#### 使用 cpanm 安装模块 + +```bash +# 安装 cpanm(如果没有) +curl -L https://cpanmin.us | perl - --sudo App::cpanminus + +# 使用 Xget 镜像安装模块 +cpanm --mirror https://xget.xi-xu.me/cpan/ DBI +cpanm --mirror https://xget.xi-xu.me/cpan/ Mojolicious + +# 从 Makefile.PL 安装依赖 +cpanm --mirror https://xget.xi-xu.me/cpan/ --installdeps . +``` + +#### 在项目中使用 + +```perl +# 在 cpanfile 中列出依赖 +requires 'DBI'; +requires 'Mojolicious'; +requires 'JSON'; + +# 然后使用 Xget 镜像安装 +cpanm --mirror https://xget.xi-xu.me/cpan/ --installdeps . +``` + +### TeX/LaTeX 包管理加速 + +#### 配置 TeX Live 使用 Xget CTAN 镜像 + +```bash +# 配置 tlmgr 使用 Xget CTAN 镜像 +tlmgr option repository https://xget.xi-xu.me/ctan/systems/texlive/tlnet + +# 更新包数据库 +tlmgr update --self --all + +# 安装包 +tlmgr install beamer +tlmgr install tikz +``` + +#### 配置 MiKTeX 使用 Xget 镜像 + +```bash +# Windows MiKTeX 配置 +mpm --set-repository=https://xget.xi-xu.me/ctan/systems/win32/miktex + +# 更新包数据库 +mpm --update-db + +# 安装包 +mpm --install=beamer +mpm --install=pgf +``` + +#### 在项目中使用 + +```bash +# LaTeX 文档编译时自动安装缺失包 +pdflatex --shell-escape document.tex + +# 或手动安装特定包 +tlmgr install caption +tlmgr install subcaption +tlmgr install algorithm2e +``` + ### Go 模块加速 #### 配置 Go 使用 Xget 代理 diff --git a/src/config/platforms.js b/src/config/platforms.js index ec12e31..83966cc 100644 --- a/src/config/platforms.js +++ b/src/config/platforms.js @@ -8,6 +8,7 @@ export const PLATFORMS = { gitea: 'https://gitea.com', codeberg: 'https://codeberg.org', sf: 'https://sourceforge.net', + aosp: 'https://android.googlesource.com', hf: 'https://huggingface.co', npm: 'https://registry.npmjs.org', pypi: 'https://pypi.org', @@ -18,6 +19,8 @@ export const PLATFORMS = { gradle: 'https://plugins.gradle.org', rubygems: 'https://rubygems.org', cran: 'https://cran.r-project.org', + cpan: 'https://www.cpan.org', + ctan: 'https://tug.ctan.org', golang: 'https://proxy.golang.org', nuget: 'https://api.nuget.org', crates: 'https://crates.io', diff --git a/src/index.js b/src/index.js index 91828f3..72bf5f0 100644 --- a/src/index.js +++ b/src/index.js @@ -433,19 +433,19 @@ async function handleRequest(request, env, ctx) { if (request.method === 'HEAD') { // First, try the HEAD request response = await fetch(targetUrl, finalFetchOptions); - + // If HEAD request succeeds but lacks Content-Length, do a GET request to get it if (response.ok && !response.headers.get('Content-Length')) { const getResponse = await fetch(targetUrl, { ...finalFetchOptions, method: 'GET' }); - + if (getResponse.ok) { // Create a new response with HEAD method but include Content-Length from GET const headHeaders = new Headers(response.headers); const contentLength = getResponse.headers.get('Content-Length'); - + if (contentLength) { headHeaders.set('Content-Length', contentLength); } else { @@ -453,7 +453,7 @@ async function handleRequest(request, env, ctx) { const arrayBuffer = await getResponse.arrayBuffer(); headHeaders.set('Content-Length', arrayBuffer.byteLength.toString()); } - + response = new Response(null, { status: getResponse.status, statusText: getResponse.statusText,