📝 项目介绍
GitHub 访问加速,解决 GitHub 访问慢的问题。使用 Cloudflare Workers 和公共 DNS API 来获取 IP 地址。
感谢 GitHub520 提供的灵感。
🚀 特点
- 使用 Cloudflare Workers 部署,无需服务器
- 使用 Cloudflare DNS (1.1.1.1) 和 Google DNS 进行域名解析
- 使用 Cloudflare KV 存储数据,确保高可用性
- 提供 REST API 接口
- 每 60 分钟自动更新一次 DNS 记录
💻 使用方法
1. 命令行工具(推荐)
MacOS 用户
sudo curl -fsSL https://github.com/TinsFox/github-hosts/releases/download/v0.0.1/github-hosts.darwin-arm64 -o github-hosts && sudo chmod +x ./github-hosts && ./github-hosts⚠️ Windows 与 Linux 的脚本还没有经过测试,遇到问题请提 issue
Windows 用户
在管理员权限的 PowerShell 中执行:
irm https://github.com/TinsFox/github-hosts/releases/download/v0.0.1/github-hosts.windows-amd64.exe | iexLinux 用户
sudo curl -fsSL https://github.com/TinsFox/github-hosts/releases/download/v0.0.1/github-hosts.linux-amd64 -o github-hosts && sudo chmod +x ./github-hosts && ./github-hosts更多版本请查看 Release 页面
2. 使用 SwitchHosts 工具
- 下载并安装 SwitchHosts
- 添加规则:
- 方案名:GitHub Hosts
- 类型:远程
- URL:https://github-hosts.tinsfox.com/hosts
- 自动更新:1 小时
当前 hosts 内容
# github hosts # 加速 GitHub 访问 140.82.112.26 alive.github.com 140.82.121.5 api.github.com 185.199.109.153 assets-cdn.github.com 185.199.110.133 avatars.githubusercontent.com 185.199.111.133 avatars0.githubusercontent.com 185.199.111.133 avatars1.githubusercontent.com 185.199.110.133 avatars2.githubusercontent.com 185.199.111.133 avatars3.githubusercontent.com 185.199.111.133 avatars4.githubusercontent.com 185.199.109.133 avatars5.githubusercontent.com 185.199.111.133 camo.githubusercontent.com 140.82.113.22 central.github.com 185.199.108.133 cloud.githubusercontent.com 140.82.121.10 codeload.github.com 140.82.112.22 collector.github.com 185.199.110.133 desktop.githubusercontent.com 185.199.111.133 favicons.githubusercontent.com 140.82.121.3 gist.github.com 54.231.136.17 github-cloud.s3.amazonaws.com 16.15.178.15 github-com.s3.amazonaws.com 3.5.28.235 github-production-release-asset-2e65be.s3.amazonaws.com 16.182.98.137 github-production-repository-file-5c1aeb.s3.amazonaws.com 52.216.60.161 github-production-user-asset-6210df.s3.amazonaws.com 192.0.66.2 github.blog 140.82.121.3 github.com 140.82.112.17 github.community 185.199.108.154 github.githubassets.com 151.101.1.194 github.global.ssl.fastly.net 185.199.109.153 github.io 185.199.108.133 github.map.fastly.net 185.199.108.153 githubstatus.com 140.82.113.25 live.github.com 185.199.110.133 media.githubusercontent.com 185.199.108.133 objects.githubusercontent.com 13.107.42.16 pipelines.actions.githubusercontent.com 185.199.110.133 raw.githubusercontent.com 185.199.111.133 user-images.githubusercontent.com 13.107.246.67 vscode.dev 140.82.114.22 education.github.com 185.199.111.133 private-user-images.githubusercontent.com # 数据更新时间:1/9/2026, 16:04:15
3. 手动更新
- 获取 hosts:访问 https://github-hosts.tinsfox.com/hosts
- 更新本地 hosts 文件:
- Windows:
C:\Windows\System32\drivers\etc\hosts - MacOS/Linux:
/etc/hosts
- Windows:
- 刷新 DNS:
- Windows:
ipconfig /flushdns - MacOS:
sudo killall -HUP mDNSResponder - Linux:
sudo systemd-resolve --flush-caches
- Windows:
❓ 常见问题
权限问题
- Windows:需要以管理员身份运行
- MacOS/Linux:需要 sudo 权限
定时任务未生效
- Windows:检查任务计划程序中的 "GitHub Hosts Updater"
- MacOS/Linux:使用
crontab -l检查
更新失败
- 检查日志:
~/.github-hosts/logs/update.log - 确保网络连接和文件权限正常
🔧 API 接口文档
| 接口 | 方法 | 描述 |
|---|---|---|
| /hosts | GET | 获取 hosts 文件内容 |
| /hosts.json | GET | 获取 JSON 格式的数据 |
| /{domain} | GET | 获取指定域名的实时 DNS 解析结果 |
| /reset | POST | 清空缓存并重新获取所有数据(需要 API Key) |
📦 源码
本项目完全开源,欢迎访问 GitHub 仓库
评论