GithubHelp home page GithubHelp logo

521xueweihan / github520 Goto Github PK

View Code? Open in Web Editor NEW
19.9K 256.0 2.0K 8.59 MB

:kissing_heart: 让你“爱”上 GitHub,解决访问时图裂、加载慢的问题。(无需安装)

Python 100.00%
dns github hosts

github520's Introduction

GitHub520


HelloGitHub 分享 GitHub 上有趣、入门级的开源项目。
兴趣是最好的老师,这里能够帮你找到编程的兴趣!

服务器续费到 2024.12 共花了:1500+💰 点击扫码赞助,感谢🙏

一、介绍

对 GitHub 说"爱"太难了:访问慢、图片加载不出来。

本项目无需安装任何程序,仅需 5 分钟。

通过修改本地 hosts 文件,试图解决:

  • GitHub 访问速度慢的问题
  • GitHub 项目中的图片显示不出的问题

让你"爱"上 GitHub。

注: 本项目还处于测试阶段,仅在本机测试通过,如有问题欢迎提 issues

二、使用方法

下面的地址无需访问 GitHub 即可获取到最新的 hosts 内容:

  • 文件:https://raw.hellogithub.com/hosts
  • JSON:https://raw.hellogithub.com/hosts.json

2.1 手动方式

2.1.1 复制下面的内容

# GitHub520 Host Start
140.82.112.26                 alive.github.com
140.82.113.6                  api.github.com
185.199.109.153               assets-cdn.github.com
185.199.111.133               avatars.githubusercontent.com
185.199.111.133               avatars0.githubusercontent.com
185.199.111.133               avatars1.githubusercontent.com
185.199.111.133               avatars2.githubusercontent.com
185.199.111.133               avatars3.githubusercontent.com
185.199.111.133               avatars4.githubusercontent.com
185.199.111.133               avatars5.githubusercontent.com
185.199.111.133               camo.githubusercontent.com
140.82.112.22                 central.github.com
185.199.111.133               cloud.githubusercontent.com
140.82.114.10                 codeload.github.com
140.82.114.21                 collector.github.com
185.199.111.133               desktop.githubusercontent.com
185.199.111.133               favicons.githubusercontent.com
140.82.112.3                  gist.github.com
52.216.209.97                 github-cloud.s3.amazonaws.com
52.216.132.179                github-com.s3.amazonaws.com
3.5.22.29                     github-production-release-asset-2e65be.s3.amazonaws.com
52.217.18.52                  github-production-repository-file-5c1aeb.s3.amazonaws.com
52.217.206.65                 github-production-user-asset-6210df.s3.amazonaws.com
192.0.66.2                    github.blog
140.82.114.4                  github.com
140.82.112.17                 github.community
185.199.111.154               github.githubassets.com
151.101.193.194               github.global.ssl.fastly.net
185.199.109.153               github.io
185.199.111.133               github.map.fastly.net
185.199.109.153               githubstatus.com
140.82.112.26                 live.github.com
185.199.111.133               media.githubusercontent.com
185.199.111.133               objects.githubusercontent.com
13.107.42.16                  pipelines.actions.githubusercontent.com
185.199.111.133               raw.githubusercontent.com
185.199.111.133               user-images.githubusercontent.com
13.107.213.40                 vscode.dev
140.82.114.21                 education.github.com


# Update time: 2024-04-26T14:06:11+08:00
# Update url: https://raw.hellogithub.com/hosts
# Star me: https://github.com/521xueweihan/GitHub520
# GitHub520 Host End

该内容会自动定时更新, 数据更新时间:2024-04-26T14:06:11+08:00

2.1.2 修改 hosts 文件

hosts 文件在每个系统的位置不一,详情如下:

  • Windows 系统:C:\Windows\System32\drivers\etc\hosts
  • Linux 系统:/etc/hosts
  • Mac(苹果电脑)系统:/etc/hosts
  • Android(安卓)系统:/system/etc/hosts
  • iPhone(iOS)系统:/etc/hosts

修改方法,把第一步的内容复制到文本末尾:

  1. Windows 使用记事本。
  2. Linux、Mac 使用 Root 权限:sudo vi /etc/hosts
  3. iPhone、iPad 须越狱、Android 必须要 root。

2.1.3 激活生效

大部分情况下是直接生效,如未生效可尝试下面的办法,刷新 DNS:

  1. Windows:在 CMD 窗口输入:ipconfig /flushdns

  2. Linux 命令:sudo nscd restart,如报错则须安装:sudo apt install nscdsudo /etc/init.d/nscd restart

  3. Mac 命令:sudo killall -HUP mDNSResponder

Tips: 上述方法无效可以尝试重启机器。

2.2 自动方式(SwitchHosts)

Tip:推荐 SwitchHosts 工具管理 hosts

以 SwitchHosts 为例,看一下怎么使用的,配置参考下面:

  • Hosts 类型: Remote

  • Hosts 标题: 随意

  • URL: https://raw.hellogithub.com/hosts

  • 自动刷新: 最好选 1 小时

如图:

这样每次 hosts 有更新都能及时进行更新,免去手动更新。

2.3 一行命令 (适用于类 Unix 系统)

GNU(Ubuntu/CentOS/Fedora)

sudo sh -c 'sed -i "/# GitHub520 Host Start/Q" /etc/hosts && curl https://raw.hellogithub.com/hosts >> /etc/hosts'

BSD/macOS

sudo sed -i "" "/# GitHub520 Host Start/,/# Github520 Host End/d" /etc/hosts && curl https://raw.hellogithub.com/hosts | sudo tee -a /etc/hosts

将上面的命令添加到 cron,可定时执行。使用前确保 GitHub520 内容在该文件最后部分。

在 Dcker 中运行,若遇到 Device or resource busy 错误,可使用以下命令执行

cp /etc/hosts ~/hosts.new && sed -i "/# GitHub520 Host Start/Q" ~/hosts.new && curl https://raw.hellogithub.com/hosts >> ~/hosts.new && cp -f ~/hosts.new /etc/hosts

2.4 AdGuard 用户(自动方式)

过滤器>DNS 封锁清单>添加阻止列表>添加一个自定义列表,配置如下:

  • 名称:随意

  • URL:https://raw.hellogithub.com/hosts(和上面 SwitchHosts 使用的一样)

如图:

更新间隔在 设置 > 常规设置 > 过滤器更新间隔(设置一小时一次即可),记得勾选上 使用过滤器和 Hosts 文件以拦截指定域名

Tip:不要添加在 DNS 允许清单 内,只能添加在 DNS 封锁清单 才管用。 另外,AdGuard for Mac、AdGuard for Windows、AdGuard for Android、AdGuard for IOS 等等 AdGuard 家族软件 添加方法均类似。

三、效果对比

之前的样子:

修改完 hosts 的样子:

TODO

  • 定时自动更新 hosts 内容
  • hosts 内容无变动不会更新
  • 寻到最优 IP 解析结果

声明

知识共享许可协议
本作品采用 署名-非商业性使用-禁止演绎 4.0 国际 进行许可。

github520's People

Contributors

521hellogithub avatar 521xueweihan avatar abeautifulsnow avatar bond-aspecta avatar doveboy avatar gauseen avatar goodcoder666 avatar harrywang29 avatar herberthe avatar lc6464 avatar potterli20 avatar tsubamei avatar westxu avatar wuyuncheng-26 avatar zhonglu 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

github520's Issues

感觉作业创作思路有问题

guthub小白,有什么说得不对的还希望大家谅解指正。
github actions 是自动服务,是在非本机环境下跑的程序,作者python文件只是测出了在那个环境下访问各个目的网址的最快ip,并不是我们本机访问这些网址的最快ip。
不知道我理解的是否有问题,理解有错的话还希望谅解指正。

Github Desktop push error.

很有用,非常感谢!但最近似乎出了一个问题。

应用 hosts 之后,使用 Github Desktop push 失败:

Details

image

关闭该 hosts 后 push 成功。

我写了一个 [油猴脚本] 成功解决 Github 各种文件下载速度慢的问题!(和该项目互补)

Github 的一些域名可以通过修改 Hosts 来有效提高访问速度,但是 Github Release 等文件下载域名就只有美国服务器,无论怎么改 Hosts,对下载速度的提升也很有限,因此去年我写了这个油猴脚本来解决该问题。

该脚本只能解决 Github 中各种文件下载速度慢的问题,对于 Github 访问慢还是需要改 Hosts,所以和该项目很配!(互补)

如果觉得我写的这个油猴脚本还不错,那就让这个“小广告”在这里帮到更多的人吧!

该脚本有什么用?

安装后为 Github 的 Clone、Release、Raw、Code(ZIP) 等任何需要下载的文件添加 高速下载(加速下载)
以及在项目列表页,添加单文件快捷下载 (☁) 链接!

如果觉得还不错,就去 Github 点个 [⭐ Star] 鼓励一下下吧!https://github.com/XIU2/UserScript

26

目前 Raw 文件快捷下载加速源共 4 个:Github 原生、**国内(两个)、**香港,按照这个顺序循环切换。

19


如何安装/使用该脚本?

要使用该脚本,需要浏览器安装一个 Tampermonkey 脚本管理器扩展(Chrome / Firefox / Edge)。

安装该浏览器扩展后,前往以下任意地址,并点击网页中的 [安装脚本] 后扩展会弹出安装提示,再点击 [安装] 即可。

其他基于 Chromium 内核的浏览器(如国内套皮浏览器)都可以使用 Chrome 的扩展。

请确保使用 Tampermonkey 扩展,其他的用户脚本管理器可能导致无法正常使用脚本。

不会离线安装 .crx 扩展?Chrome、Edge 重新开启隐藏的 [拖入安装 .crx 扩展] 功能!


如何进一步提速?

如果要进一步提速,可以尝试开启 Chrome 浏览器隐藏的多线程下载功能 ,这样理论上下载速度会翻几倍。


原理是什么?

目前有很多 Github 文件下载加速的网站或开源项目,脚本只是将加速后的文件下载地址添加到了网页,省去了手动获取的麻烦,方便直接点击高速下载!

只要你链接这些网站的速度比 Github 原生用的亚马逊 CDN 的速度更快,就是加速下载!


为什么快捷下载 [ ☁ ] 不能直接点击下载?

这是因为浏览器安全策略禁止了跨域下载文件(即文件下载地址的域名与当前网站域名不一致),浏览器为了安全性从根本上限制了该功能,所以只能通过 [Alt + 左键] 或 [右键 - 另存为...] 来下载文件了。

使用本项目中的 hosts 无法访问 github

从今天下午开始,github 的网页突然无法访问了,具体情况是 ping 得通,但是一访问网页就显示连接被重置。

目前的解决方案:
重置 hosts 文件,使用 9.9.9.9 解析 github 相关的域名可正常访问大部分内容,且用 aria2 从 github releases 下载文件很快。gist.github.com 还需要额外在 hosts 中指定服务器为 140.82.112.4 才能正常访问。

网络环境:广东电信

大牛能给个教程吗

大牛我想在别的网站上获取ip,访问也是一愣一愣的,但不知道怎么做这种自动更新,能教教吗😁

gitee

请问,gitee直链是怎么弄的,谢谢

建议

由于Github的更新,建议您的Python文件URL中加入avatars.githubusercontent.com的扫描,以便更方便的显示图片
非常感谢您的作品,一直在用

Github.com 域名(hosts)指向任意 IP 就会出现 TCPing IP 443 端口超时 3 分钟。

本贴仅为学习交流,希望大家不要跑题~

起因

从前几天开始,我发现 Github 总是频繁无法访问(直连),而我这么多年很少遇到这种情况

稍微注意了下,发现竟然有规律,于是花了一下午时间不停测试,得出了一些不成熟的结论。


复现

测试环境:Windows10(联通家庭宽带)、Android 手机(联通 4G)

一开始我是拿了一些 github.com 的 IP 放在 Hosts 文件中轮番指向 github.com 来测试。

一旦指向后去访问 Github,就会发现这个 IP 的 443 端口会超时(TCPing),然后浏览器提示超时。

如果我关闭网页(避免浏览器一直重试),等 3 分钟后(TCPing 超时 90 次,超时时间 2 秒)443 端口就通了。

在此期间,该 IP 的 80 端口和 ICMP Ping 是一直正常通顺的,只有 443 端口超时。

在此期间,整个局域网下全都 443 超时(准确说是整个宽带网络下),而独立的手机 4G 网络 TCPing 443 正常(包括其他在线端口测试网站也都 443 正常,国外更不用说了一切正常)。

在此期间,对该 IP 进行 TCP 路由追踪时,会在出口处完全中断。


看到这里,其实就发现不对劲了,于是我又尝试手机共享流量数据网络给电脑,同样可以复现。

这时候,因为手机和电脑在同一个局域网(流量数据网络)下,所以也都 443 超时的。


进阶

测着侧着,突发奇想如果指向其他非 Github 的 IP 会怎么样?

于是我就找了个能用的 Cloudflare CDN IP(只要 443 端口可以 TCPing 就行)指向 Github 后,发现也会出现 443 端口超时的情况。。。

我也尝试过把 Github 的 IP 指向其他域名,结果一切正常,没有出现类似情况,只是针对 Github。


其他机制

因为持续测试了好几个小时的原因,还发现了一些其他机制:

触发时间/超时时间

有时候是一旦触发条件,就会直接超时 3 分钟(TCPing 超时 90 次,超时时间 2 秒),期间完全超时。

而有的时候是这 3 分钟期间还会漏掉一些正常延迟的 TCPing 结果,但经过测试依然无法访问网页,应该是模拟丢包

而有的时候触发条件后,如果立即停止访问 Github,则就会发现 443 端口不再超时了。而如果一直不停的重试网页,那么超时时间就会无限长(重置为 3 分钟),这时候再去停止重试网页,超时时间就固定为 3 分钟了。

随机/轮番针对

有意思的是,似乎是随机或轮番针对 Github IP 的。

因为我发现有时候 IP A 在某一段时间内是可以正常访问的,相应其他的 IP B C D 等这段时间就会无法使用(一旦访问就 443 超时)。而过一段时间 IP A 又无法访问了,但又有另一个 IP B 可以正常访问了(顺序没有发现规律)。

也就是说,在任意时间总有一个(或几个) IP 是可以正常访问的,且不停变换。


目前为止,我只在我的联通宽带+联通 4G 网络下可以稳定复现,不清楚其他地区、运营商是否也一样。

欢迎大家测试、交流、分析。

未知原因无法加速

Screenshot 2020-11-01 at 10 23 28

Screenshot 2020-11-01 at 10 23 38

mac平台 使用了SwitchHost客户端并添加了远程更新 依旧没能加速,想请教下原因

希望添加国内git站发布

我打不开github,于是想要修改github的hosts,于是我要打开github520项目来获取,但我打不开github?

新形势下的使用教程

image
手动或是使用uTools等软件编辑hosts。
完成后刷新DNS缓存。
打开浏览器访问https://github.com/ ,此时大概率访问不了。
放置一段时间,然后就可以打开了。
联通亲测OK。

大牛可以给*.github.io的地址吗

配置了host之后,之前裂开的图片现在可以加载出来了。但是*.github.io的地址还是不能访问,可以加上这个地址的ip吗

switchhost配置后无效

使用全局梯子,根据图片配置后。
关闭梯子仍然裂图。
我是遗漏了某些操作设置吗?

image

image

关于实现原理

您好
这个的原理是手动找出最快的cdn节点 并解析过去吗
并不是反代?

请教一些设置问题。

@521xueweihan 能不能自己托管一个。但是下边的值,不明白。求教:
···
gitee_token: ${{ secrets.GITEE_TOKEN }}
gitee_gist_id: ${{ secrets.GITEE_GIST_ID }}
gitee_gist_file_name: ${{ secrets.GITEE_GIST_FILE_NAME }}
···
请问以上三个,要填写什么,能不能给个稍详细点的说明。谢谢啦。

padavan路由器自动更新dns

我的路由器是用的padavan固件,通过如下操作来自动更新路由器的hosts信息

  1. 打开浏览器进入路由器的管理页面找到:【高级设置->系统管理->服务栏】里面的计划任务 (Crontab),如下图:
    01

  2. 添加以下订阅代码
    0 6 * * * sed -i '/# GitHub520 Host Start/,/# Github520 Host End/d' /etc/storage/dnsmasq/hosts;wget --no-check-certificate https://raw.hellogithub.com/hosts -O /etc/storage/dnsmasq/hosts.bak;cat /etc/storage/dnsmasq/hosts.bak >> /etc/storage/dnsmasq/hosts;restart_dhcpd

  3. ##代码解释:
    3.1 前面的0 6 是代表每天06:00更新一次,时间自己也可以根据cron格式更改。
    3.2 sed -i '/# GitHub520 Host Start/,/# Github520 Host End/d' /etc/storage/dnsmasq/hosts 是删除用户自定义hosts中的失效内容
    3.3 wget --no-check-certificate https://raw.hellogithub.com/hosts -O /etc/storage/dnsmasq/hosts.bak;cat /etc/storage/dnsmasq/hosts.bak >> /etc/storage/dnsmasq/hosts; 下载并添加hosts内容
    3.4 restart_dhcpd 重启dhcp服务加载新的hosts

希望能增加fetch_ips.py中的注释

希望能增加fetch_ips.py中的注释,鄙人是非专业程序猿 QAQ,阅读这个程序的时候感觉代码比较长,阅读理解起来有点费劲,希望您方便的话能够增加一些注释,让俺们能够学习一下这个思路 QvQ🙇‍

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.