使用 Cloudflare Workers 和公共 DNS API 智能优选域名 IP
正在加载 hosts 内容...
推荐使用,可自动更新
加载中...一键安装和更新
curl -fsSL https://github.com/Yan-nian/custom-host/releases/download/v1.0.0/install.sh | sudo bash
| 接口 | 方法 | 参数 | 描述 |
|---|---|---|---|
| /hosts | GET | refresh=[true|false], custom=[true|false] | 获取 hosts 文件内容,支持强制刷新缓存 |
| /hosts.json | GET | refresh=[true|false] | 获取 JSON 格式的域名数据,包含统计信息 |
| /{domain} | GET | - | 获取指定域名的实时 DNS 解析结果 |
| 接口 | 方法 | 描述 |
|---|---|---|
| /api/custom-domains | GET | 获取自定义域名列表 |
| /api/custom-domains | POST | 添加自定义域名,需要提供domain字段,可选description字段 |
| /api/custom-domains/batch | POST | 批量添加自定义域名,需要提供domains数组,每个元素包含domain字段 |
| /api/custom-domains/{domain} | DELETE | 删除指定的自定义域名 |
| /api/custom-domains | DELETE | 清空所有自定义域名 |
| /api/optimize/{domain} | POST | 优选指定域名的 IP 地址 |
| /api/optimize-all | POST | 优选所有自定义域名的 IP 地址(需要 API Key 或管理后台访问) |
| /api/cache/status | GET | 查看缓存状态和统计信息 |
| /api/cache/refresh | POST | 手动刷新 GitHub 域名缓存(需要 API Key 或管理后台访问) |
| /api/cache | DELETE | 清空所有缓存数据(需要 API Key 或管理后台访问) |
| /api/reset | POST | 清空缓存并重新获取GitHub域名数据 |
| 接口 | 方法 | 描述 |
|---|---|---|
| /api/system/config | GET | 获取系统配置信息(需要管理后台访问) |
| /api/system/api-key | PUT | 更新 API Key(需要管理后台访问) |
| 接口 | 方法 | 描述 |
|---|---|---|
| /test-custom-domains | GET | 测试所有自定义域名的解析状态 |
| /debug | GET | 获取系统调试信息和域名统计 |
sudo curl -fsSL https://github.com/Yan-nian/custom-host/releases/download/v1.0.0/custom-hosts.darwin-arm64 -o custom-hosts && sudo chmod +x ./custom-hosts && ./custom-hosts
在管理员权限的 PowerShell 中执行:
irm https://github.com/Yan-nian/custom-host/releases/download/v1.0.0/custom-hosts.windows-amd64.exe | iex
sudo curl -fsSL https://github.com/Yan-nian/custom-host/releases/download/v1.0.0/custom-hosts.linux-amd64 -o custom-hosts && sudo chmod +x ./custom-hosts && ./custom-hosts
C:\Windows\System32\drivers\etc\hosts/etc/hostsipconfig /flushdnssudo killall -HUP mDNSRespondersudo systemd-resolve --flush-cachesGET /hostsGET /hosts?refresh=trueGET /hosts?custom=falseGET /hosts.jsonGET /api/cache/statusGET /hosts.json注意:管理类 API 需要通过管理后台访问,或使用 API Key 验证。管理后台地址在部署时配置。
curl -X POST -H "x-api-key: YOUR_API_KEY" /api/optimize-allcurl -X POST -H "x-api-key: YOUR_API_KEY" /api/cache/refreshPOST /api/custom-domains(需要管理后台)POST /api/custom-domains/batch(需要管理后台)特殊功能:主页刷新按钮使用限制权限的特殊 API Key。
main-page-refresh