一、介紹
對 GitHub 說"愛"太難了:訪問慢、圖片加載不出來。
注: 本項目還處於測試階段,僅在本機測試通過,如有問題歡迎提 issues
本項目無需安裝任何程序,通過修改本地 hosts 文件,試圖解決:
- GitHub 訪問速度慢的問題
- GitHub 項目中的圖片顯示不出的問題
花 5 分鍾時間,讓你"愛"上 GitHub。
二、使用方法
2.1 復制下面的內容
# GitHub520 Host Start 140.82.112.26 alive.github.com 140.82.114.25 live.github.com 185.199.108.154 github.githubassets.com 140.82.113.21 central.github.com 185.199.108.133 desktop.githubusercontent.com 185.199.108.153 assets-cdn.github.com 185.199.108.133 camo.githubusercontent.com 185.199.108.133 github.map.fastly.net 199.232.69.194 github.global.ssl.fastly.net 140.82.113.4 gist.github.com 185.199.108.153 github.io 140.82.112.4 github.com 140.82.114.5 api.github.com 185.199.108.133 raw.githubusercontent.com 185.199.108.133 user-images.githubusercontent.com 185.199.108.133 favicons.githubusercontent.com 185.199.108.133 avatars5.githubusercontent.com 185.199.108.133 avatars4.githubusercontent.com 185.199.108.133 avatars3.githubusercontent.com 185.199.108.133 avatars2.githubusercontent.com 185.199.108.133 avatars1.githubusercontent.com 185.199.108.133 avatars0.githubusercontent.com 185.199.108.133 avatars.githubusercontent.com 140.82.114.9 codeload.github.com 52.217.130.17 github-cloud.s3.amazonaws.com 52.217.98.76 github-com.s3.amazonaws.com 52.216.164.3 github-production-release-asset-2e65be.s3.amazonaws.com 52.216.160.147 github-production-user-asset-6210df.s3.amazonaws.com 52.217.103.12 github-production-repository-file-5c1aeb.s3.amazonaws.com 185.199.108.153 githubstatus.com 64.71.168.201 github.community 185.199.108.133 media.githubusercontent.com # Update time: 2021-07-02T14:04:55+08:00 # Star me GitHub url: https://github.com/521xueweihan/GitHub520 # GitHub520 Host End
上面內容會自動定時更新,保證最新有效。數據更新時間:2021-07-02T14:04:55+08:00(內容無變動不會更新)
- 文件:
https://raw.fastgit.org/521xueweihan/GitHub520/main/hosts
- JSON:
https://raw.fastgit.org/521xueweihan/GitHub520/main/hosts.json
2.1 手動方式
2.1.1 修改 hosts 文件
hosts 文件在每個系統的位置不一,詳情如下:
- Windows 系統:
C:\Windows\System32\drivers\etc\hosts
- Linux 系統:
/etc/hosts
- Mac(蘋果電腦)系統:
/etc/hosts
- Android(安卓)系統:
/system/etc/hosts
- iPhone(iOS)系統:
/etc/hosts
修改方法,把第一步的內容復制到文本末尾:
- Windows 使用記事本。
- Linux、Mac 使用 Root 權限:
sudo vi /etc/hosts
。 - iPhone、iPad 須越獄、Android 必須要 root。
2.1.2 激活生效
大部分情況下是直接生效,如未生效可嘗試下面的辦法,刷新 DNS:
-
Windows:在 CMD 窗口輸入:
ipconfig /flushdns
-
Linux 命令:
sudo nscd restart
,如報錯則須安裝:sudo apt install nscd
-
Mac 命令:
sudo killall -HUP mDNSResponder
Tips: 上述方法無效可以嘗試重啟機器。
2.2 自動方式
Tip:推薦 SwitchHosts (下載安裝 Switch Hosts 地址:https://github.com/oldj/SwitchHosts/releases/tag/v4.0.2)工具管理 hosts
以 SwitchHosts 為例,看一下怎么使用的,配置參考下面:
-
Title: 隨意
-
Type:
Remote
-
URL:
https://raw.fastgit.org/521xueweihan/GitHub520/main/hosts
-
Auto Refresh: 最好選
1 hour
如圖:
這樣每次 hosts 有更新都能及時進行更新,免去手動更新。
2.3 AdGuard Home 用戶(自動方式)
在 過濾器>DNS 封鎖清單>添加阻止列表>添加一個自定義列表,配置如下:
-
名稱: 隨意
-
URL:
https://cdn.jsdelivr.net/gh/521xueweihan/GitHub520@main/hosts
(和上面 SwitchHosts 使用的一樣)
如圖:
更新間隔在 設置>常規設置>過濾器更新間隔(設置一小時一次即可),記得勾選上 使用過濾器和 Hosts 文件以攔截指定域名
Tip:不要添加在 DNS 允許清單 內,只能添加在 DNS 封鎖清單 才管用。另外,AdGuard for Mac、AdGuard for Windows、AdGuard for Android、AdGuard for IOS 等等 AdGuard 家族軟件 添加方法均類似。
2.4 Chrome 插件方式
FasterHosts 是個 Chrome 插件,主要原理是攔截瀏覽器的某些請求,將 domain
替換成訪問速度較快的那個。hosts 資源來自 GitHub520,每 1 小時更新一次。
- 下載 FasterHosts 然后解壓,找到
extension
子目錄- 打開 Chrome,輸入:
chrome://extensions/
- 打開「開發者模式」
- 選擇「加載已解壓的擴展程序」,然后定位到剛才解壓的文件夾里面的
extension
目錄,確定- 這就安裝好了,關閉「開發者模式」
三、效果對比
之前的樣子:
修改完 hosts 的樣子:
TODO
- 定時自動更新 hosts 內容
- hosts 內容無變動不會更新
- 尋到最優 IP 解析結果