FluxDown 的 resolver 插件(fluxdown@github-accel):下载 GitHub 文件时自动测速并改写到最快的公共加速源,全部不可用则回退 GitHub 直连——加速失败绝不阻断下载。
对本次要下载的这个文件,在所有适用加速源上并行发起 GET + Range: bytes=0-65535(64 KB 采样)探测,一次探测同时验证可用性与速度:
- 状态
200/206视为可用,比较耗时选最快改写直链;全部失败 → 放行 GitHub 直连。 - 探测到
206时回填rangeSupported,引擎直接按多线程分段规划;Content-Range中的文件总大小一并回填。 - 同一链接会记住上次选中的源(storage 内 LRU),断点续传恢复时不换源,避免 ETag 校验不一致导致整段重下。
| 加速源 | 改写形式 | 支持 | 限制 |
|---|---|---|---|
| jsDelivr CDN | https://fastly.jsdelivr.net/gh/<owner>/<repo>@<ref>/<path> |
仓库内文件(blob / raw),ref 可为分支/标签/提交号 | 单文件 ≤ 20 MB(超限 403,探测自动剔除);不支持 release 资产与源码归档;分支内容有约 12 小时 CDN 缓存 |
| FastGit | https://fastgit.cc/<完整 GitHub URL> |
release 资产、源码归档(archive/*.zip|*.tar.gz)、blob/raw 分支文件、raw./gist.githubusercontent.com |
不支持项目文件夹(基于 hunshcn/gh-proxy) |
覆盖的链接形态:
https://github.com/<owner>/<repo>/releases/download/<tag>/<file> release 资产
https://github.com/<owner>/<repo>/releases/latest/download/<file> release 资产(latest)
https://github.com/<owner>/<repo>/archive/<ref>.zip|.tar.gz 源码归档
https://github.com/<owner>/<repo>/blob|raw/<ref>/<path> 分支文件(含 refs/heads|tags 变体)
https://raw.githubusercontent.com/<owner>/<repo>/<ref>/<path> raw 文件
https://gist.githubusercontent.com/<user>/<id>/raw/... gist 文件
仓库主页、PR、Issues 等非文件链接一律放行,不做改写。
| 设置项 | 说明 |
|---|---|
| 加速源 | 自动(测速优选) / 固定 jsDelivr / 固定 FastGit / 直连(禁用加速)。固定的源不可用时仍回退到其他可用源。 |
| 附加 gh-proxy 加速源 | 每行一个 https:// 前缀(gh-proxy 风格,完整 GitHub 链接直接拼在其后),自动参与测速,例如 https://ghproxy.net/。 |
| 详细日志 | 记录每个加速源的探测状态码与耗时。 |
- 无需改代码:在「附加 gh-proxy 加速源」设置里按行添加前缀。
- 代码级:在
resolve.js的BUILTIN_PROVIDERS注册表追加一项{ id, label, supports(file), rewrite(file) };file.kind ∈ release | archive | blob | raw | gist。
node scripts/pack.mjs
# dist/github-accel-<version>.fxplug + contentHash(确定性构建,字节可复现)产物提交到 zerx-lab/fluxdown-plugin-index:dist/ 放包、plugins/fluxdown@github-accel/<version>.json 加分片(sequence 取当前最大值 +1),跑 node scripts/generate.mjs 后推送。