GitHub 访问

一、直接使用 GitHub 镜像

https://gitclone.com

https://hunsh.net/archives/23

https://greasyfork.org/scripts/412245

https://ghproxy.link

https://www.jsdelivr.com/github,https://cdn.jsdelivr.net/gh/用户名/仓库名@版本号/文件路径/文件名

 

二、绕过 DNS 解析,配置 hosts 文件直连

速度取决与服务器和你所在的网络环境,不一定换了就速度快。

https://www.ipaddress.com

https://tool.chinaz.com/dns

https://site.ip138.com

https://dns.google

https://boce.aliyun.com

http://119.29.29.29/d?dn=github.com

https://ns.net.kg/dns-query?name=github.com

https://rdnsdb.com

https://github.com/natesales/q/releases & https://github.com/ameshkov/dnslookup/releases

https://github.com/curl/curl/wiki/DNS-over-HTTPS

https://adguard-dns.io/kb/zh-CN/general/dns-providers & https://raw.githubusercontent.com/AdguardTeam/KnowledgeBaseDNS/refs/heads/master/docs/general/dns-providers.md

https://github.com/dibdot/DoH-IP-blocklists

https://dnscrypt.info/public-servers & https://www.dnscrypt.org

https://github.com/xxnuo/dns-benchmark/blob/master/dnspy/res/providers.txt

查询列表

https://github.com/521xueweihan/GitHub520

https://github.com/ineo6/hosts & https://gitlab.com/ineo6/hosts

https://github.com/jianboy/github-host

https://hosts.gitcdn.top

按需要来查询,常用的查询前三个就可以了。

# github-begin
github.com
github.global.ssl.fastly.net
github-cloud.s3.amazonaws.com

gist.github.com
assets-cdn.github.com
raw.githubusercontent.com
gist.githubusercontent.com
cloud.githubusercontent.com
camo.githubusercontent.com

avatars0.githubusercontent.com
avatars1.githubusercontent.com
avatars2.githubusercontent.com
avatars3.githubusercontent.com
avatars4.githubusercontent.com
avatars5.githubusercontent.com
avatars6.githubusercontent.com
avatars7.githubusercontent.com
avatars8.githubusercontent.com

github.githubassets.com
status.github.com
help.github.com
documentcloud.github.com
# github-end

 

将查询到的 IP 对应起来写入 hosts 文件

https://github.com/oldj/SwitchHosts

Windows

@echo off
setlocal enabledelayedexpansion

:: 请求管理员权限
if not "%1"=="am_admin" (powershell start -verb runas '%0' am_admin & exit /b)

:: 定义临时文件路径
set "temp_file=%temp%\\hosts.tmp"
set "hosts_path=%SystemRoot%\\System32\\drivers\\etc\\hosts"

:: 第一阶段:删除旧的github区块
set "in_block=0"
(
for /f "tokens=*" %%a in (%hosts_path%) do (
    set "line=%%a"
    if "!line!"=="# github-begin" set in_block=1
    if !in_block!==0 echo/%%a
    if "!line!"=="# github-end" set in_block=0
)
) > "%temp_file%"

:: 替换原hosts文件
move /y "%temp_file%" "%hosts_path%" >nul

:: 第二阶段:追加新内容
(
echo # github-begin
powershell -Command "(Invoke-WebRequest -Uri 'https://gitlab.com/ineo6/hosts/-/raw/master/next-hosts').Content"
echo # github-end
) >> "%hosts_path%"

:: 显示结果
ipconfig /flushdns
type "%hosts_path%"
pause

Linux

echo -n "sudo sed -i '/^# github-begin$/,/^# github-end$/d' /etc/hosts
sudo sed -i '\$a# github-begin' /etc/hosts
curl -s https://gitlab.com/ineo6/hosts/-/raw/master/next-hosts | sudo tee -a /etc/hosts >/dev/null
sudo sed -i -e '\$a\' -e '# github-end' /etc/hosts
cat /etc/hosts" > ~/github-hosts.sh
sh ~/github-hosts.sh

 

刷新本机 DNS 缓存

Windows,保存为 ANSI 编码 .bat 后缀

# 查询 DNS 缓存
ipconfig /displaydns

# 清空 DNS 缓存
ipconfig /flushdns

# 定时清空 DNS 缓存
@echo off
:a
ipconfig /flushdns > NUL
echo [INFO %time:~0,8%] 已成功刷新 DNS 解析缓存。
echo 1分钟将再次刷新。按下任意键以立即刷新...
timeout /t 60 > NUL
echo.
goto a

chrome 缓存:chrome://net-internals/#dns

 

三、配置 Chromium 参数

hosts 不支持通配符,每个域得写一条,例如 github.com、www.github.com 和 gist.github.com 就只能写成三条规则,很难完全覆盖

Chromium 内核的 --host-rules 和 --host-resolver-rules 参数可实现修改 hosts 类似的效果:

--host-rules="MAP *github.com github" --host-resolver-rules="MAP github 192.30.253.112" --test-type --ignore-certificate-errors

自动配置 Chromium 参数:https://github.com/SpaceTimee/Sheas-Cealer & https://github.com/maoist2009/TlsFragment

 


https://qu.js.cn/how-to-speed-github

https://github.com/StevenBlack/hosts

posted @ 2019-06-10 09:53  江湖小小白  阅读(884)  评论(0)    收藏  举报