Coder Social home page Coder Social logo

ineo6 / hosts Goto Github PK

View Code? Open in Web Editor NEW
4.8K 76.0 414.0 7.09 MB

GitHub最新hosts。解决GitHub图片无法显示,加速GitHub网页浏览。

Home Page: https://ineo6.github.io/hosts/

License: MIT License

JavaScript 0.63% TypeScript 99.37%
github hosts hosts-file

hosts's Introduction

GitHub Hosts

这个有什么用?最直观的效果是GitHub图片可以正常加载,网页也稳定了。

GitHub Hosts主要是通过修改host的方式加速GitHub访问,解决图片无法加载以及访问速度慢的问题。

全新的GitHub访问加速工具,等待试用和反馈中,点击 FastDev 直达。

特点就是稳定!

hosts地址可能会调整,所以请务必关注GitHub、Gitlab主页,保证不迷路,也可以关注公众号:湖中剑。

使用方式

1. 远程hosts

现在新增了DNS获取方案,欢迎使用并反馈。

请查看 next hosts

内容定时更新,最近更新时间:2023-03-08 20:22:25。

# New!欢迎使用基于DNS的新方案
# https://gitlab.com/ineo6/hosts/-/raw/master/next-hosts
# 地址可能会变动,请务必关注GitHub、Gitlab获取最新消息
# 也可以关注公众号:湖中剑,保证不迷路
# GitHub Host Start

# Please Star : https://github.com/ineo6/hosts
# Mirror Repo : https://gitlab.com/ineo6/hosts

# Update at: 2023-03-08 20:22:25

# GitHub Host End

2. 本地 hosts 服务

本地 hosts 服务获取到的ip是经过本地测试,所以成功率较高。

而且会定时获取最新的ip,尽可能保证访问。

注意,该方案需要结合SwitchHosts一起使用,或者你也可以直接访问地址,手动复制。

macOS (Intel)

执行下面命令, 服务会运行在: http://localhost:8888

curl -L https://github.com/ineo6/hosts/releases/download/v1.0.1/hosts-server-pkg-mac-x64.tar.gz | tar xzvf -
xattr -d com.apple.quarantine ./hosts-server-pkg-mac-x64/hosts-server
./hosts-server-pkg-mac-x64/hosts-server --port=8888

macOS (Apple Silicon)

执行下面命令, 服务会运行在: http://localhost:8888

curl -L https://github.com/ineo6/hosts/releases/download/v1.0.1/hosts-server-pkg-mac-arm64.tar.gz | tar xzvf -
./hosts-server-pkg-mac-arm64/hosts-server --port=8888

Linux (x64, amd64)

执行下面命令, 服务会运行在: http://localhost:8888

curl -L https://github.com/ineo6/hosts/releases/download/v1.0.1/hosts-server-pkg-linuxstatic-x64.tar.gz | tar xzvf -
./hosts-server-pkg-linuxstatic-x64/hosts-server --port=8888

Linux (ARM64)

执行下面命令, 服务会运行在: http://localhost:8888

curl -L https://github.com/ineo6/hosts/releases/download/v1.0.1/hosts-server-pkg-linuxstatic-arm64.tar.gz | tar xzvf -
./hosts-server-pkg-linuxstatic-arm64/hosts-server --port=8888

Run on Linux (ARMv7 32bit)

执行下面命令, 服务会运行在: http://localhost:8888

curl -L https://github.com/ineo6/hosts/releases/download/v1.0.1/hosts-server-pkg-linuxstatic-armv7.tar.gz | tar xzvf -
./hosts-server-pkg-linuxstatic-armv7/hosts-server --port=8888

Windows

下载 https://github.com/ineo6/hosts/releases/download/v1.0.1/hosts-server-pkg-win-x64.zip ,解压后执行下面命令,服务会运行在: http://localhost:8888

.\hosts-server.exe --port=8888

配置hosts教程

通过 SwitchHosts 自动更新

这里推荐使用 SwitchHosts 配置hosts,操作很简单,支持跨平台。

注意:首次使用先备份下本地hosts。

详细介绍可以阅读 SwitchHosts! 还能这样管理hosts,后悔没早点用

操作步骤

添加一条规则:

这样就可以和最新的hosts保持同步。

switchhost-github.png

手动配置

macOS

hosts文件位置:/etc/hosts

macOS系统下修改需要按照如下方式:

1:首先,打开(访达)Finder。
2:使用组合键Shift+Command+G打开"前往文件夹",输入框中输入/etc/hosts
3:然后就会跳转到hosts文件位置。

注意:如果你使用VS Code,可以直接用VS Code修改和保存,不需要复制文件。

复制hosts文件到桌面上,鼠标右键右击它,选择「打开方式」—「文本编辑」,打开这个hosts文件,把前面的hosts内容复制进来。

然后把你修改好的hosts文件替换掉:/etc/hosts 文件。

注意:如果弹出密码输入框,你需要输入你当前登录账号对应的密码。

最后刷新缓存:

sudo killall -HUP mDNSResponder

Windows

hosts文件位置:C:/windows/system32/drivers/etc/hosts

将前文hosts内容追加到hosts文件,然后刷新DNS缓存:

ipconfig /flushdns

我的作品

  • GitMaster:开发者助手,代码仓库结构浏览器扩展
  • homebrew-install:Homebrew快速安装教程和脚本
  • GitHub Hosts:GitHub最新hosts,定时更新
  • Awesome Mirror:镜像收集,旨在帮助你快速安装开发工具
  • mp-ci:微信小程序、小游戏发布助手(CI)

hosts's People

Contributors

bigeyoung avatar ineo6 avatar kylezhang avatar tt1k 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  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

hosts's Issues

更新后git clone命令失败

用了30号跟10月1号的host地址,发现git clone总是失败:

Connection reset by 140.82.113.3 port 22
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

不更新git clone反而好使。

gitee镜像地址不会出现违规吗?

我也写了个脚本解析hosts。但是镜像到gitee总是报违规,导致每次都不能准确同步hosts。
我之前写的其他脚本在gitee上也经常违规!
想问一下作者如何解决gitee违规问题!

你好

就像这种本地获取hosts 链接 http://localhost:8888 有办法直接下载成hosts文件吗 我想用树莓派 直接下载 然后替换hosts文件
就像这种命令
0 */3 * * * cd /etc/storage/dnsmasq;rm -rf hosts;wget --no-check-certificate https://gitlab.com/ineo6/hosts/-/raw/master/hosts -O hosts;restart_dhcpd
本地链接这个 怎么设置 可以直接下载hosts文件
本地链接下载的 如图是 上面那种网页格式的
你的网络链接下载的是hosts文件格式
本地链接能直接下载下面那种格式吗
image

方案缺陷

此方案解决了dns污染问题,但不能解决github tcp rst的本质问题。

我写了一个py小脚本,配置此教程可以一键更新host和dns

`import requests
import os

此脚本需要将hosts.txt的文件文件操作权限(修改、写入)赋予给当前user,不然会显示拒绝访问!

'''
国内镜像地址:https://gitee.com/ineo6/hosts
主站地址为:https://github.com/ineo6/hosts
'''

url = "https://gitee.com/ineo6/hosts/raw/master/hosts" # hosts源码

r = requests.get(url=url)

hosts = r.text

with open('C:\Windows\System32\drivers\etc\hosts.txt', 'w+') as f:
f.write(hosts)

os.system("ipconfig /flushdns")

print("hosts文件更新完毕,DNS缓存刷新完毕!")
`

实现效果如图

微信图片_20220219131318

有办法可以让他每次开机就运行吗?(windows系统)

[BUG]域名解析错误

下图中的判断应该是大于2,不然所有域名都为真,但是github.com这种只有主域名的地址会出现404造成报错

image

结果就是host文件里面所有主域名的ip都没有
github.io
github.com
githubstatus.com
github.community

另外

image

建议增加类型判断或者正则判断ip

image

因为可能会有CNAME、TXT等类型解析

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.