-
Notifications
You must be signed in to change notification settings - Fork 127
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
433 additions
and
107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
name: Release | ||
|
||
on: | ||
push: | ||
tags: | ||
- v* | ||
|
||
jobs: | ||
release: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
- name: Set up Go | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: 1.17.4 | ||
- name: Create release on GitHub | ||
uses: goreleaser/goreleaser-action@v2 | ||
with: | ||
version: latest | ||
args: release --rm-dist | ||
env: | ||
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
builds: | ||
- | ||
goos: | ||
- darwin | ||
- linux | ||
- windows | ||
goarch: | ||
- 386 | ||
- amd64 | ||
- arm64 | ||
- arm | ||
env: | ||
- CGO_ENABLED=0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,141 @@ | ||
## 介绍 | ||
`fetch-github-hosts` 是主要为解决研究及学习人员访问 `Github` 过慢或其他问题而提供的免费的 `Github Hosts` 同步服务。 | ||
|
||
`fetch-github-hosts` 是主要为解决研究及学习人员访问 `Github` 过慢或其他问题而提供的 `Github Hosts` 同步服务。 | ||
|
||
## 原理 | ||
此项目是通过部署此项目本身的服务器来获取 `github.com` 的 `hosts`,而不是通过第三方ip地址接口来进行获取,例如 `ipaddress.com` 等 | ||
|
||
此项目是通过部署此项目本身的服务器来获取 `github.com` 的 `hosts`,而不是通过第三方ip地址接口来进行获取,例如 `ipaddress.com` 等。 | ||
|
||
## 使用方法 | ||
|
||
### 自动(推荐) | ||
|
||
到 [Releases](https://github.com/Licoy/fetch-github-hosts/releases) | ||
或 [FastGit镜像](https://hub.fastgit.xyz/Licoy/fetch-github-hosts/releases) 中下载您的系统版本(目前支持`Windows`/`Linux`/`MacOS` | ||
),包括`ARM` | ||
架构的系统。 | ||
|
||
#### 参数 | ||
|
||
| 参数名 | 缩写 | 默认值 | 必填 | 描述 | | ||
|------------|-----|--------------------------------------|-----|------------------------------------| | ||
| `mode` | `m` | client | 否 | 启动模式 `server(服务端)` / `client(客户端)` | | ||
| `interval` | `i` | 60 | 否 | 获取记录值间隔(分钟) | | ||
| `port` | `p` | 9898 | 否 | 服务模式监听端口以访问HTTP服务 | | ||
| `url` | `u` | `https://hosts.gitcdn.top/hosts.txt` | 否 | 客户端模式远程hosts获取链接 | | ||
|
||
#### 启动客户端: | ||
|
||
> 注意: | ||
> | ||
> Windows下需要右键【以管理员身份运行】; | ||
> | ||
> Linux/Macos下需要使用root或具有hosts写入权限的账户执行,或直接使用`sudo`运行; | ||
- 直接运行 | ||
|
||
```bash | ||
# Linux/Macos | ||
fetch-github-hosts | ||
|
||
# Windows | ||
fetch-github-hosts.exe | ||
``` | ||
|
||
- 自定义获取时间间隔 | ||
|
||
```bash | ||
# Linux/Macos(10分钟获取一次) | ||
fetch-github-hosts -i=10 | ||
|
||
# Windows(10分钟获取一次) | ||
fetch-github-hosts.exe -i=10 | ||
``` | ||
|
||
- 自定义获取链接 | ||
|
||
```bash | ||
# Linux/Macos | ||
fetch-github-hosts -u=http://127.0.0.1:9898/hosts.json | ||
|
||
# Windows | ||
fetch-github-hosts.exe -u=http://127.0.0.1:9898/hosts.json | ||
``` | ||
|
||
#### 启动服务端: | ||
|
||
- 直接运行 | ||
|
||
```bash | ||
# Linux/Macos | ||
fetch-github-hosts -m=server | ||
|
||
# Windows | ||
fetch-github-hosts.exe -m=server | ||
``` | ||
|
||
- 自定义监听端口 | ||
|
||
```bash | ||
# Linux/Macos | ||
fetch-github-hosts -m=server -p=6666 | ||
|
||
# Windows | ||
fetch-github-hosts.exe -m=server -p=6666 | ||
``` | ||
|
||
### 手动 | ||
|
||
#### 添加hosts | ||
|
||
访问 [https://hosts.gitcdn.top/hosts.txt](https://hosts.gitcdn.top/hosts.txt) , | ||
将其全部内容粘贴到你的hosts文件中,即可。 | ||
|
||
- `Linux / MacOS` hosts路径:`/etc/hosts` | ||
- `Windows` hosts路径:`C:\Windows\System32\drivers\etc\hosts` | ||
|
||
#### 刷新生效 | ||
|
||
- `Linux`: `/etc/init.d/network restart` | ||
- `Windows`: `ipconfig /flushdns` | ||
- `Macos`: `sudo killall -HUP mDNSResponder` | ||
### Unix/Linux 一键使用 | ||
|
||
#### Unix/Linux 一键使用 | ||
|
||
```shell | ||
sed -i "/# fetch-github-hosts begin/Q" /etc/hosts && curl https://hosts.gitcdn.top/hosts.txt >> /etc/hosts | ||
``` | ||
|
||
> 提示:可以设置crontab定时任务定时获取更新即可,解放双手! | ||
### Chrome | ||
使用 [FasterHosts](https://github.com/gauseen/faster-hosts) 插件,若访问速度过慢可以直接使用 | ||
[点击此处](https://gitcdn.top/https://github.com/gauseen/faster-hosts/archive/refs/heads/master.zip) 来进行下载。 | ||
### 其他自动方式 | ||
|
||
#### Chrome浏览器下 | ||
|
||
使用 [FasterHosts](https://github.com/gauseen/faster-hosts) 插件,点击进入下载。 | ||
|
||
下载完成之后解压压缩包,Chrome地址栏输入`chrome://extensions/`回车进入,勾选`开发者模式`,选择`加载已解压的扩展程序`, | ||
选择刚才的解压目录即可。 | ||
### Windows /MacOS 及其他桌面端 | ||
|
||
#### Windows / MacOS 及其他桌面端 | ||
|
||
使用 [SwitchHosts](https://swh.app/) 桌面端应用,安装添加新规则: | ||
|
||
- `Title`: 任意 | ||
- `Type`: `Remote` | ||
- `Url`: `https://hosts.gitcdn.top/hosts.txt` | ||
- `Auto refresh`: `1 hour` | ||
|
||
## 私有部署 | ||
下载本仓库的代码:[fetch-github-hosts.zip](https://gitcdn.top/https://github.com/Licoy/fetch-github-hosts/archive/refs/heads/main.zip) , | ||
部署到任意一个含有PHP环境的服务器即可,部署完成之后可以计划任务脚本定时更新hosts: | ||
```shell | ||
cd /wwwroot/fetch-github-hosts #此处更换为你部署的项目路径 | ||
php fetch_hosts.php | ||
``` | ||
> 注意:必须部署到非大陆的服务器节点! | ||
|
||
下载最新的发行版(到 [Releases](https://github.com/Licoy/fetch-github-hosts/releases) | ||
或 [FastGit镜像](https://hub.fastgit.xyz/Licoy/fetch-github-hosts/releases) 进行下载) | ||
,并选择您的系统对应版本,直接以服务模式运行即可:`fetch-github-hosts -m=server -p=9898`,会自动监听`0.0.0.0:9898`,您可以直接浏览器访问 `http://127.0.0.1:9898` | ||
以访问您自定义服务。 | ||
(具体方法可参见【启动服务端】小节详细说明) | ||
|
||
> 注意:因网络影响,尽量部署到海外服务器节点! | ||
### 开源协议 | ||
[GPL 3.0](./LICENSE) | ||
|
||
[GPL 3.0](https://github.com/Licoy/fetch-github-hosts/blob/main/LICENSE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,4 @@ | ||
github.com/akavel/rsrc v0.10.2 h1:Zxm8V5eI1hW4gGaYsJQUhxpjkENuG91ki8B4zCrvEsw= | ||
github.com/akavel/rsrc v0.10.2/go.mod h1:uLoCtb9J+EyAqh+26kdrTgmzRBFPGOolLWKpdxkKq+c= | ||
github.com/jessevdk/go-flags v1.5.0 h1:1jKYvbxEjfUl0fmqTCOfonvskHHXMjBySTLW4y9LFvc= | ||
github.com/jessevdk/go-flags v1.5.0/go.mod h1:Fw0T6WPc1dYxT4mKEZRfG5kJhaTDP9pj1c2EWnYs/m4= | ||
github.com/rwtodd/Go.Sed v0.0.0-20210816025313-55464686f9ef h1:UD99BBEz19F21KhOFHLNAI6KodDWUvXaPr4Oqu8yMV8= | ||
github.com/rwtodd/Go.Sed v0.0.0-20210816025313-55464686f9ef/go.mod h1:8AEUvGVi2uQ5b24BIhcr0GCcpd/RNAFWaN2CJFrWIIQ= | ||
golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4 h1:EZ2mChiOa8udjfp6rRmswTbtZN/QzUQp4ptM4rnjHvc= | ||
golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= |
Oops, something went wrong.