{"id":13486204,"url":"https://github.com/Licoy/fetch-github-hosts","last_synced_at":"2025-03-27T20:32:20.585Z","repository":{"id":37448824,"uuid":"491782606","full_name":"Licoy/fetch-github-hosts","owner":"Licoy","description":"🌏 同步github的hosts工具，支持多平台的图形化和命令行，内置客户端和服务端两种模式~ | Synchronize GitHub hosts tool, support multi-platform graphical and command line, built-in client and server modes","archived":false,"fork":false,"pushed_at":"2025-02-25T08:42:35.000Z","size":525,"stargazers_count":1254,"open_issues_count":5,"forks_count":128,"subscribers_count":23,"default_branch":"main","last_synced_at":"2025-03-25T13:00:44.923Z","etag":null,"topics":["github","github-hosts","hosts","hosts-tool","sync-hosts"],"latest_commit_sha":null,"homepage":"https://hosts.gitcdn.top","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Licoy.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-05-13T06:28:04.000Z","updated_at":"2025-03-24T22:42:07.000Z","dependencies_parsed_at":"2024-01-06T06:42:22.135Z","dependency_job_id":"2175945d-ace6-4565-aebe-c3d615572193","html_url":"https://github.com/Licoy/fetch-github-hosts","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Licoy%2Ffetch-github-hosts","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Licoy%2Ffetch-github-hosts/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Licoy%2Ffetch-github-hosts/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Licoy%2Ffetch-github-hosts/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Licoy","download_url":"https://codeload.github.com/Licoy/fetch-github-hosts/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245920220,"owners_count":20694049,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["github","github-hosts","hosts","hosts-tool","sync-hosts"],"created_at":"2024-07-31T18:00:41.516Z","updated_at":"2025-03-27T20:32:20.579Z","avatar_url":"https://github.com/Licoy.png","language":"Go","readme":"简体中文 | [English](./README_EN.md)\n\n\u003cdiv align=\"center\"\u003e\n\u003ch2\u003eFetch GitHub Hosts\u003c/h2\u003e\n\n![LOGO](assets/public/logo.png)\n\n`fetch-github-hosts` 是主要为解决研究及学习人员访问 `Github` 过慢或其他问题而提供的 `Github Hosts` 同步工具\n\n[![Release](https://img.shields.io/github/v/release/Licoy/fetch-github-hosts.svg?logo=git)](https://github.com/Licoy/fetch-github-hosts)\n[![Build Linux \u0026 Windows](https://github.com/Licoy/fetch-github-hosts/workflows/Build%20for%20Linux%20\u0026%20Windows/badge.svg)](https://github.com/Licoy/fetch-github-hosts)\n[![Build MacOS](https://github.com/Licoy/fetch-github-hosts/workflows/Build%20for%20MacOS/badge.svg)](https://github.com/Licoy/fetch-github-hosts)\n\n\u003c/div\u003e\n\n## no-gui 构建方法\n\n```bash\ngo build -tags=\"no_gui\"\n```\n\n## 原理\n\n此项目是通过部署此项目本身的服务器来获取 `github.com` 的 `hosts`，而不是通过第三方ip地址接口来进行获取，例如 `ipaddress.com` 等。\n\n## 使用方法\n### 图形化界面\n到 [Releases](https://github.com/Licoy/fetch-github-hosts/releases) 中下载您的系统版本（目前支持`Windows`/`Linux`/`MacOS`\n）\n\n下载完成解压`tar.gz`压缩包，运行对应平台的执行文件即可运行（ ⚠️ 注意：Linux下需要用`sudo`进行启动，Windows和MacOS会自动进行提权操作。）\n\n#### 客户端模式\n![client](assets/public/docs/client.png)\n\n#### 客户端启动\n![client-start](assets/public/docs/client-start.png)\n\n#### 客户端hosts源选择\n![client-select](assets/public/docs/client-select.png)\n\n#### 客户端hosts源自定义\n![client-custom](assets/public/docs/client-custom.png)\n\n#### 服务端模式\n![server](assets/public/docs/server.png)\n\n### 命令行终端\n\n到 [Releases](https://github.com/Licoy/fetch-github-hosts/releases) 中下载您的系统版本（目前支持`Windows`/`Linux`/`MacOS`\n）\n\n#### 参数\n\n| 参数名        | 缩写  | 默认值                                  | 必填  | 描述                                 |\n|------------|-----|--------------------------------------|-----|------------------------------------|\n| `mode`     | `m` | 无                                    | 是   | 启动模式 `server（服务端）` / `client（客户端）` |\n| `interval` | `i` | 60                                   | 否   | 获取记录值间隔（分钟）                        |\n| `port`     | `p` | 9898                                 | 否   | 服务模式监听端口以访问HTTP服务                  |\n| `url`      | `u` | `https://hosts.gitcdn.top/hosts.txt` | 否   | 客户端模式远程hosts获取链接                   |\n| `lang`     | `l` | `zh-CN`                              | 否   | 界面语言                               |\n\n#### 启动客户端：\n\n\u003e 注意：\n\u003e \n\u003e Linux下需要使用`sudo`运行；\n\u003e \n\u003e Windows和MacOS会自动进行提权操作。\n\n- 直接运行\n\n```bash\n# Linux/Macos\nsudo fetch-github-hosts -m=client\n\n# Windows\nfetch-github-hosts.exe -m=client\n```\n\n- 自定义获取时间间隔\n\n```bash\n# Linux/Macos（10分钟获取一次）\nsudo fetch-github-hosts -i=10\n\n# Windows（10分钟获取一次）\nfetch-github-hosts.exe -i=10\n```\n\n- 自定义获取链接\n\n```bash\n# Linux/Macos\nsudo fetch-github-hosts -u=http://127.0.0.1:9898/hosts.json\n\n# Windows\nfetch-github-hosts.exe -u=http://127.0.0.1:9898/hosts.json\n```\n\n#### 启动服务端：\n\n- 直接运行\n\n```bash\n# Linux/Macos\nfetch-github-hosts -m=server\n\n# Windows\nfetch-github-hosts.exe -m=server\n```\n\n- 自定义监听端口\n\n```bash\n# Linux/Macos\nfetch-github-hosts -m=server -p=6666\n\n# Windows\nfetch-github-hosts.exe -m=server -p=6666\n```\n\n### 手动\n\n#### 添加hosts\n\n访问 [https://hosts.gitcdn.top/hosts.txt](https://hosts.gitcdn.top/hosts.txt) ，\n将其全部内容粘贴到你的hosts文件中，即可。\n\n- `Linux / MacOS` hosts路径：`/etc/hosts`\n- `Windows` hosts路径：`C:\\Windows\\System32\\drivers\\etc\\hosts`\n\n#### 刷新生效\n\n- `Linux`: `/etc/init.d/network restart`\n- `Windows`: `ipconfig /flushdns`\n- `Macos`: `sudo killall -HUP mDNSResponder`\n\n#### Unix/Linux 一键使用\n\n```shell\nsed -i \"/# fetch-github-hosts begin/Q\" /etc/hosts \u0026\u0026 curl https://hosts.gitcdn.top/hosts.txt \u003e\u003e /etc/hosts\n```\n\n\u003e 提示：可以设置crontab定时任务定时获取更新即可，解放双手！\n\n## 私有部署\n\n下载最新的发行版（到 [Releases](https://github.com/Licoy/fetch-github-hosts/releases) 进行下载）\n，并选择您的系统对应版本，直接以服务模式运行即可：`fetch-github-hosts -m=server -p=9898`，会自动监听`0.0.0.0:9898`，您可以直接浏览器访问 `http://127.0.0.1:9898`\n以访问您自定义服务。\n（具体方法可参见【启动服务端】小节详细说明）\n\n\u003e 注意：因网络影响，尽量部署到海外服务器节点！\n\n## 趋势\n[![Stargazers over time](https://starchart.cc/Licoy/fetch-github-hosts.svg)](https://starchart.cc/Licoy/fetch-github-hosts)\n\n## 开源协议\n\n[GPL 3.0](https://github.com/Licoy/fetch-github-hosts/blob/main/LICENSE)\n","funding_links":[],"categories":["Go","剪贴板工具","Rust"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FLicoy%2Ffetch-github-hosts","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FLicoy%2Ffetch-github-hosts","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FLicoy%2Ffetch-github-hosts/lists"}