MCPcopy Index your code
hub / github.com/xixu-me/xget

github.com/xixu-me/xget @main sqlite

repository ↗ · DeepWiki ↗
144 symbols 423 edges 73 files 60 documented · 42%
README

Xget 🚀

xixu-me%2FXget | Trendshift

Ask Zread Ask DeepWiki codecov Chromium Firefox

Cloudflare EdgeOne Vercel Netlify Deno Docker Podman

English | 汉语(简体) | 漢語(繁體)

[!TIP] 歡迎加入「Xget 開源與 AI 交流群」,一起交流開源專案、AI 應用、工程實踐、效率工具和獨立開發;如果你也在做產品、寫程式、折騰專案或者對開源和 AI 感興趣,歡迎進群認識更多認真做事、樂於分享的朋友。

面向開發者資源的超高效能、安全、一體化加速引擎,為程式碼託管、模型和資料集中心、軟體包管理儲存庫、容器註冊表、AI 推理供應商等提供統一、高效的加速,同時替你處理快取、重試、安全回應標頭,以及各種協定相容行為。

技術深度解析文章:《深入剖析 Xget:一個高效能、多協定、高安全性的開發者資源加速引擎》

受邀入駐 GitCode,並被認證為 G-Star 畢業專案。作為「一個被廣泛使用的公共專案」,獲得 OpenAI 的 Codex for Open Source 計畫支援,也獲得多位技術博主自發推薦,包括阮一峰GitHubDaily魚 C玄離 199 等。感謝所有支持、分享、推薦和實際使用 Xget 的個人、團隊與社群。

支援的平台

[!NOTE] 下方徽章會跳轉到 README 中對應的使用或部署章節。

GitHub GitLab Gitea Codeberg SourceForge AOSP Hugging Face Civitai npm PyPI conda Maven Apache Gradle Homebrew RubyGems CRAN CPAN CTAN Go NuGet Rust Packagist Flathub Debian Ubuntu Fedora Rocky Linux openSUSE Arch Linux arXiv F-Droid Jenkins 容器註冊表 AI 推理供應商

快速開始

預部署實例:xget.xi-xu.me - 僅適合評估與試用,正式環境或對可用性敏感的場景建議自行部署。

[!WARNING] 如果你選擇自託管,除非你明確要做公開鏡像,否則請至少加上驗證、IP 白名單,或同時啟用兩者。

URL 轉換器:xuc.xi-xu.me - 一鍵轉換任意支援平台的 URL 為 Xget 的加速格式

Agent Skills:npx skills add xixu-me/skills -s xget

為什麼選擇 Xget

面向效能的設計

  • 全球邊緣執行環境:基於 Cloudflare Workers,盡量讓請求更靠近使用者與上游服務
  • 協定感知處理:支援 HTTP/3、Range 請求、Git 流量、容器註冊表流程與 AI 推理 API
  • 快取與重試鏈路:對可相容回應提供邊緣快取,對暫時性上游失敗提供重試,並對支援的平台做請求規範化
  • 連線重用:在執行環境與上游允許的前提下,重用標準 HTTP keep-alive 與連線重用能力
  • 請求耗時可觀測:在協定相容的情況下,可透過 X-Performance-Metrics 回應標頭暴露階段性耗時資訊

多平台深度整合

  • 一站式多平台支援:統一支援各種開發場景中的主流平台
  • 智慧識別與轉換:自動識別平台前綴並轉換為目標平台的正確 URL 結構
  • 一致的加速體驗:無論檔案類型或來源,均可享受統一且穩定的極速下載體驗

企業級安全保障

  • 多層安全標頭
  • Strict-Transport-Security:強制 HTTPS 傳輸,預防中間人攻擊
  • X-Frame-Options: DENY:防止點擊劫持攻擊
  • Content-Security-Policy:嚴格的內容安全策略
  • Referrer-Policy:控制參照來源資訊洩露
  • Permissions-Policy:預設限制瀏覽器中的隱私敏感能力
  • X-XSS-Protection:面向舊版瀏覽器的相容性回應標頭
  • 請求驗證機制
  • HTTP 方法白名單:常規請求限制為 GET/HEAD,而 Git/LFS、容器映像儲存庫、AI 推理與 Hugging Face API 請求會按需允許 POSTPUTPATCHDELETE
  • 路徑長度限制:防止超長 URL 攻擊(最大 2048 字元)
  • 輸入清理:防止路徑遍歷和注入攻擊
  • 逾時保護:30 秒請求逾時,防止資源耗盡和惡意請求

現代架構與可靠性

  • 智慧重試機制
  • 最大 3 次重試,線性延遲策略(1000ms × 重試次數)
  • 自動錯誤恢復,提高下載成功率
  • 逾時檢測和中斷處理
  • 高效快取策略
  • 基於策略的快取時長,讓可變中繼資料保持新鮮,同時對不可變製品使用更長快取
  • Git 操作跳過快取,確保即時性
  • 基於 Cloudflare Cache API 和 Cloudflare fetch 快取控制的邊緣快取
  • 效能監控系統
  • 內建 PerformanceMonitor 類別,即時追蹤請求各階段耗時
  • 透過 X-Performance-Metrics 回應標頭提供詳細效能數據
  • 支援快取命中率統計和最佳化建議

Git 協定完全相容

  • 智慧協定檢測
  • 自動識別 Git 特定端點(/info/refs/git-upload-pack/git-receive-pack
  • 檢測 Git 用戶端 User-Agent 模式
  • 支援 service=git-upload-pack 等查詢參數
  • 完整操作支援
  • git clone:完整儲存庫克隆,支援淺克隆和分支指定
  • git push:程式碼推送和分支管理
  • git pull/fetch:增量更新和遠端同步
  • git submodule:子模組遞迴克隆
  • 協定最佳化
  • 保持 Git 專用請求標頭和驗證資訊
  • 智慧 User-Agent 處理(預設 git/2.34.1
  • 支援 Git LFS 大檔案傳輸

生態系統整合

  • 專用瀏覽器擴充功能Xget Now 提供無縫體驗
  • 自動 URL 轉址,無需手動修改 URL
  • 支援自訂 Xget 實例網域
  • 多平台偏好設定和黑白名單管理
  • 本地處理,確保隱私安全
  • 下載工具相容性:完美支援 wget、cURL、aria2、IDM 等主流下載工具
  • CI/CD 整合:可直接在 GitHub Actions、GitLab CI 等環境中使用

系統架構

請求處理流程

graph TD
    Request[使用者請求 / User-Agent] --> Identify{識別平台}
    Identify -->|無效| Error[返回錯誤]
    Identify -->|有效| Transform[轉換路徑]

    Transform --> CheckProtocol{檢查協定}

    CheckProtocol -->|Git| GitHandler[Git 協定適配器]
    CheckProtocol -->|Docker| DockerHandler[Docker 協定適配器]
    CheckProtocol -->|AI| AIHandler[AI 推理適配器]
    CheckProtocol -->|標準| StdHandler[標準適配器]

    GitHandler --> Upstream[獲取上游]
    DockerHandler --> Upstream
    AIHandler --> Upstream

    StdHandler --> CacheCheck{檢查快取}
    CacheCheck -->|命中| ReturnCache[返回快取回應]
    CacheCheck -->|未命中| Upstream

    Upstream -->|成功| ProcessResponse[處理回應]
    Upstream -->|失敗| Retry{重試?}

    Retry -->|是| Wait["等待 (退避)"] --> Upstream
    Retry -->|否| Error

    ProcessResponse --> Finalize[添加標頭並返回]
    Finalize --> Response[回應]

組件架構

classDiagram
    class Worker {
        +fetch(request)
    }
    class AppHandler {
        +handleRequest(request, env, ctx)
    }
    class PlatformCatalog {
        +PLATFORM_CATALOG
    }
    class PlatformRouting {
        +transformPath()
        +resolveTarget()
    }
    class Validation {
        +validateRequest()
        +isDockerRequest()
    }
    class GitProtocol {
        +configureGitHeaders()
        +isGitRequest()
    }
    class DockerProtocol {
        +handleDockerAuth()
        +fetchToken()
    }
    class AIProtocol {
        +configureAIHeaders()
    }
    class UpstreamPipeline {
        +tryReadCachedResponse()
        +fetchUpstreamResponse()
    }
    class ResponsePipeline {
        +finalizeResponse()
    }
    class Security {
        +addSecurityHeaders()
    }
    class Performance {
        +monitor()
    }

    Worker --> AppHandler
    AppHandler --> PlatformCatalog
    AppHandler --> PlatformRouting
    AppHandler --> Validation
    AppHandler --> GitProtocol
    AppHandler --> DockerProtocol
    AppHandler --> AIProtocol
    AppHandler --> UpstreamPipeline
    AppHandler --> ResponsePipeline
    AppHandler --> Security
    AppHandler --> Performance
    PlatformRouting --> PlatformCatalog

URL 轉換規則

使用預部署實例 xget.xi-xu.me 或您自己部署的實例,只需簡單替換網域並新增平台前綴:

轉換格式

平台 平台前綴 原始 URL 格式 加速 URL 格式
GitHub gh https://github.com/... https://xget.xi-xu.me/gh/...
GitHub Gist gist https://gist.github.com/... https://xget.xi-xu.me/gist/...
GitLab gl https://gitlab.com/... https://xget.xi-xu.me/gl/...
Gitea gitea https://gitea.com/... https://xget.xi-xu.me/gitea/...
Codeberg codeberg https://codeberg.org/... https://xget.xi-xu.me/codeberg/...
SourceForg

Extension points exported contracts — how you extend this code

ExecutionContext (Interface)
* Cloudflare Workers execution context * Provides methods for managing background tasks
src/types.d.ts
DenoEnv (Interface)
(no doc)
src/types.d.ts
DenoGlobal (Interface)
(no doc)
src/types.d.ts

Core symbols most depended-on inside this repo

get
called by 197
src/types.d.ts
transformPath
called by 87
src/routing/platform-transformers.js
createConfig
called by 23
src/config/index.js
createErrorResponse
called by 13
src/utils/security.js
validateRequest
called by 9
src/utils/validation.js
mark
called by 9
src/utils/performance.js
createRequestContext
called by 9
src/app/request-context.js
fetch
called by 8
src/index.js

Shape

Function 120
Method 15
Class 6
Interface 3

Languages

TypeScript100%

Modules by API surface

src/upstream/cache-policy.js18 symbols
src/protocols/docker.js10 symbols
test/helpers/index.js9 symbols
src/utils/validation.js8 symbols
src/types.d.ts7 symbols
test/helpers/mocks.js6 symbols
src/utils/performance.js6 symbols
src/routing/platform-transformers.js6 symbols
test/features/performance.test.js5 symbols
src/upstream/fetch-upstream.js5 symbols
scripts/fix-badge-colors.js5 symbols
test/unit/worker-regressions.test.js4 symbols

Dependencies from manifests, versioned

@cloudflare/vitest-pool-workers0.16.20 · 1×
@cloudflare/workers-types4.20260621.1 · 1×
@commitlint/cli21.1.0 · 1×
@commitlint/config-conventional21.0.2 · 1×
@eslint/js10.0.1 · 1×
@types/node26.0.1 · 1×
@vercel/node3.0.0 · 1×
@vitest/coverage-istanbul4.1.5 · 1×
eslint10.6.0 · 1×
eslint-plugin-jsdoc63.0.10 · 1×
istanbul-lib-coverage3.2.2 · 1×

For agents

$ claude mcp add xget \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact