Code Monkey home page Code Monkey logo

licoy / fetch-github-hosts Goto Github PK

View Code? Open in Web Editor NEW
1.1K 21.0 110.0 1.59 MB

🌏 同步github的hosts工具,支持多平台的图形化和命令行,内置客户端和服务端两种模式~ | Synchronize GitHub hosts tool, support multi-platform graphical and command line, built-in client and server modes

Home Page: https://hosts.gitcdn.top

License: GNU General Public License v3.0

Go 83.09% HTML 16.46% Shell 0.45%
github github-hosts hosts sync-hosts hosts-tool

fetch-github-hosts's Introduction

简体中文 | English

Fetch GitHub Hosts

LOGO

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

Release Build Linux & Windows Build MacOS

原理

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

使用方法

图形化界面

Releases 中下载您的系统版本(目前支持Windows/Linux/MacOS

下载完成解压tar.gz压缩包,运行对应平台的执行文件即可运行( ⚠️ 注意:Linux下需要用sudo进行启动,Windows和MacOS会自动进行提权操作。)

客户端模式

client

客户端启动

client-start

客户端hosts源选择

client-select

客户端hosts源自定义

client-custom

服务端模式

server

命令行终端

Releases 中下载您的系统版本(目前支持Windows/Linux/MacOS

参数

参数名 缩写 默认值 必填 描述
mode m 启动模式 server(服务端) / client(客户端)
interval i 60 获取记录值间隔(分钟)
port p 9898 服务模式监听端口以访问HTTP服务
url u https://hosts.gitcdn.top/hosts.txt 客户端模式远程hosts获取链接
lang l zh-CN 界面语言

启动客户端:

注意:

Linux下需要使用sudo运行;

Windows和MacOS会自动进行提权操作。

  • 直接运行
# Linux/Macos
sudo fetch-github-hosts -m=client

# Windows
fetch-github-hosts.exe -m=client
  • 自定义获取时间间隔
# Linux/Macos(10分钟获取一次)
sudo fetch-github-hosts -i=10

# Windows(10分钟获取一次)
fetch-github-hosts.exe -i=10
  • 自定义获取链接
# Linux/Macos
sudo 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

启动服务端:

  • 直接运行
# Linux/Macos
fetch-github-hosts -m=server

# Windows
fetch-github-hosts.exe -m=server
  • 自定义监听端口
# 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 , 将其全部内容粘贴到你的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定时任务定时获取更新即可,解放双手!

私有部署

下载最新的发行版(到 Releases 进行下载) ,并选择您的系统对应版本,直接以服务模式运行即可:fetch-github-hosts -m=server -p=9898,会自动监听0.0.0.0:9898,您可以直接浏览器访问 http://127.0.0.1:9898 以访问您自定义服务。 (具体方法可参见【启动服务端】小节详细说明)

注意:因网络影响,尽量部署到海外服务器节点!

趋势

Stargazers over time

开源协议

GPL 3.0

fetch-github-hosts's People

Contributors

licoy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fetch-github-hosts's Issues

安卓

大师有大师支持安卓apk和Google之类的嘛?

可以正常连接github,问题是有些图片显示不出来

比如:
1.页面内的图片,例如
页面地址:https://github.com/gidongkwon/logseq-plugin-tags/issues/10
图片地址:https://user-images.githubusercontent.com/315369/149145698-a85ac768-1ac5-45c7-b637-876874681a7f.png

2.用户头像显示不出来(影响不大)

请支持magisk使用

需求:
手机端看一些 github 相关的东西 , 总是破图,不显示;
(不想总是飞机).

问题描述:
miui 13.0.3 , termux 0.118.0 ;
给了777权限 和 su 执行;
报错:
更新Github-Hosts失败:获取最新的hosts失败: Get "https://hosts.gitcdn.top/hosts.txt": dial tcp: lookup hosts.gitcdn.top on [::1]:53: read udp [::1]:48231->[::1]:53: read: connection refused

其他:
电脑端(linux/mac/window)均正常;

访问接口https://hosts.gitcdn.top/hosts.txt超时

有些时候访问不了https://hosts.gitcdn.top/hosts.txt
这个网站

requests.exceptions.ConnectionError: HTTPSConnectionPool(host='hosts.gitcdn.top', port=443): Max retries exceeded with url: /hosts.txt (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x10a21c3d0>: Failed to establish a new connection: [Errno 60] Operation timed out'))

有时候可以访问,好像不是很稳定。
希望可以稳定,辛苦了。

windows10一键更新脚本

@echo off
set curpath=%~dp0
cd %curpath%
set filename=hosts
set url=https://hosts.gitcdn.top/hosts.txt
powershell curl -o "%filename%" "%url%"
copy .\%filename% C:\Windows\System32\drivers\etc\hosts
ipconfig /flushdns

客户端与服务端的区别

如题,客户端与服务端的区别是什么?
难道客户端是修改电脑host的,而服务端是获取可以使用的host的吗?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.