Skip to content

Latest commit

 

History

History
47 lines (41 loc) · 2.13 KB

README.md

File metadata and controls

47 lines (41 loc) · 2.13 KB

介绍

fetch-github-hosts 是主要为解决研究及学习人员访问 Github 过慢或其他问题而提供的免费的 Github Hosts 同步服务。

原理

此项目是通过部署此项目本身的服务器来获取 github.hscsec.cnhosts,而不是通过第三方ip地址接口来进行获取,例如 ipaddress.com

使用方法

手动

添加hosts

访问 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 一键使用

sed -i "/# fetch-github-hosts begin/Q" /etc/hosts && curl https://hosts.gitcdn.top/hosts.txt >> /etc/hosts

提示:可以设置crontab定时任务定时获取更新即可,解放双手!

Chrome

使用 FasterHosts 插件,若访问速度过慢可以直接使用 点击此处 来进行下载。

下载完成之后解压压缩包,Chrome地址栏输入chrome://extensions/回车进入,勾选开发者模式,选择加载已解压的扩展程序, 选择刚才的解压目录即可。

Windows /MacOS 及其他桌面端

使用 SwitchHosts 桌面端应用,安装添加新规则:

  • Title: 任意
  • Type: Remote
  • Url: https://hosts.gitcdn.top/hosts.txt
  • Auto refresh: 1 hour

私有部署

下载本仓库的代码:fetch-github-hosts.zip , 部署到任意一个含有PHP环境的服务器即可,部署完成之后可以计划任务脚本定时更新hosts:

cd /wwwroot/fetch-github-hosts #此处更换为你部署的项目路径
php fetch_hosts.php

注意:必须部署到非大陆的服务器节点!

开源协议

GPL 3.0