使用 Cloudflare Workers 和公共 DNS API 加速访问 GitHub
GitHub 访问加速,解决 GitHub 访问慢的问题。使用 Cloudflare Workers 和公共 DNS API 来获取 IP 地址。
NoKV 版本:已移除 Cloudflare KV 存储,每次请求实时 DNS 查询,无需 KV 配额,永不下线。
原作者:TinsFox/github-hosts | NoKV 版:git clone -b nokv https://github.com/aspnmy/github-hosts.git
sudo curl -fsSL https://github.com/aspnmy/github-hosts/releases/tag/v0.0.0.1_nokv/github-hosts.darwin-arm64 -o github-hosts && sudo chmod +x ./github-hosts && ./github-hosts
⚠️ Windows 与 Linux 的脚本还没有经过测试,遇到问题请提 issue
在管理员权限的 PowerShell 中执行:
irm https://github.com/aspnmy/github-hosts/releases/tag/v0.0.0.1_nokv/github-hosts.windows-amd64.exe | iex
sudo curl -fsSL https://github.com/aspnmy/github-hosts/releases/tag/v0.0.0.1_nokv/github-hosts.linux-amd64 -o github-hosts && sudo chmod +x ./github-hosts && ./github-hosts
更多版本请查看 Release 页面
正在加载 hosts 内容...
C:\Windows\System32\drivers\etc\hosts/etc/hostsipconfig /flushdnssudo killall -HUP mDNSRespondersudo systemd-resolve --flush-caches域名列表由仓库中的 domains.txt 管理。推荐使用以下 raw GitHub 地址作为运行时来源:
https://raw.githubusercontent.com/aspnmy/github-hosts/nokv/domains.txt
更新域名只需修改该文件并推送到 nokv 分支。Worker 会根据 wrangler.toml 中的 DOMAINS_URL 拉取该文件并缓存(默认 5 分钟)。如需立即生效,请在推送后触发部署。
如果你不想维护自己的 Cloudflare 部署,可以 fork 本项目的 nokv 分支,编辑并提交 `domains.txt`,然后将修改推送到我仓库的 nokv 分支。推送后,我在 Cloudflare 上的 Worker 将会读取该文件并解析你维护的域名列表。
注意:请确保你维护的域名不在黑名单中(不要包含恶意或受限域名),否则可能影响服务或触发安全策略。
crontab -l 检查~/.github-hosts/logs/update.log| 接口 | 方法 | 描述 |
|---|---|---|
| /hosts | GET | 获取 hosts 文件内容 |
| /hosts.json | GET | 获取 JSON 格式的数据 |
| /{domain} | GET | 获取指定域名的实时 DNS 解析结果 |
| /reset | POST | 清空缓存并重新获取所有数据(需要 API Key) |
本项目是 NoKV 版本,已移除 Cloudflare KV 存储。
NoKV 版克隆:git clone -b nokv https://github.com/aspnmy/github-hosts.git