This commit is contained in:
菠萝包趣多多
2023-02-26 01:56:38 +08:00
committed by GitHub
parent 2054709de8
commit 6847d0559e
3 changed files with 0 additions and 286 deletions

View File

@ -1,286 +0,0 @@
## GitHub 镜像地址
网速慢或被封锁,在这个镜像地址访问、下载也是可以的。
* https://hub.fastgit.xyz
### git下载
使用淘宝源加快国内git下载
https://npmmirror.com/mirrors/git-for-windows/
npm/yarn下载组件方面均可使用淘宝镜像
```
npm install -g cnpm --registry=https://registry.npmmirror.com
yarn config set registry https://registry.npmmirror.com
```
### host
将以下host复制进`C:\Windows\System32\drivers\etc\hosts`,再使用命令行输入`ipconfig /flushdns`刷新dns缓存。目的此host只为解除GFW对GitHubasw、ssh下载及克隆的网络限制干扰不排除服务器吞吐、光缆受地理限制等原因
详情 [关于Github克隆及下载过慢的解决方案](https://hoochanlon.github.io/note/2019/10-01/4ee4554a.html)
**如果某条hosts的IP、域名变更而又没及时更新容易引发浏览器的连接错误重置指向造成站点无法访问**
详情 [GitHub RST与Git SSL_ERR_SYSCALL综合分析](https://hoochanlon.github.io/note/2020/06-06/74ae1ae6.html)
<details><summary>** 该host文件已废弃仅作植入IP-DNS映射阻断联网实验** </summary>
```
## GitHub Start
192.30.253.112 github.com
192.30.253.113 github.com
151.101.184.133 assets-cdn.github.com
151.101.185.194 github.global.ssl.fastly.net
192.30.253.112 github.com
192.30.253.113 github.com
192.30.253.118 gist.github.com
151.101.185.194 github.global.ssl.fastly.net
151.101.129.194 github.global.ssl.fastly.net
151.101.65.194 github.global.ssl.fastly.net
151.101.1.194 github.global.ssl.fastly.net
151.101.193.194 github.global.ssl.fastly.net
151.101.77.194 github.global.ssl.fastly.net
151.101.229.194 github.global.ssl.fastly.net
151.101.113.194 github.global.ssl.fastly.net
151.101.196.133 assets-cdn.github.com
151.101.24.133 assets-cdn.github.com
185.199.111.153 assets-cdn.github.com
185.199.110.153 assets-cdn.github.com
185.199.108.153 assets-cdn.github.com
185.199.109.153 assets-cdn.github.com
151.101.112.133 assets-cdn.github.com
151.101.112.133 avatars0.githubusercontent.com
151.101.112.133 avatars1.githubusercontent.com
151.101.184.133 avatars2.githubusercontent.com
151.101.12.133 avatars3.githubusercontent.com
151.101.12.133 avatars4.githubusercontent.com
151.101.184.133 avatars5.githubusercontent.com
151.101.184.133 avatars6.githubusercontent.com
151.101.184.133 avatars7.githubusercontent.com
151.101.12.133 avatars8.githubusercontent.com
151.101.184.133 raw.githubusercontent.com
151.101.112.133 gist.githubusercontent.com
151.101.184.133 cloud.githubusercontent.com
151.101.112.133 camo.githubusercontent.com
52.216.227.168 github-cloud.s3.amazonaws.com
192.30.253.112 github.com
185.199.108.153 assets-cdn.github.com
151.101.185.194 github.global.ssl.fastly.net
140.82.113.10 codeload.github.com
## GitHub End
```
</details>
<details><summary>** 新GitHub hosts 转自 [ineo6/hosts](https://github.com/ineo6/hosts) ,这部分可算有人做了 ** </summary>
```
# GitHub Host Start
185.199.111.154 github.githubassets.com
140.82.112.21 central.github.com
185.199.111.133 desktop.githubusercontent.com
185.199.109.153 assets-cdn.github.com
185.199.109.133 camo.githubusercontent.com
185.199.110.133 github.map.fastly.net
151.101.1.194 github.global.ssl.fastly.net
140.82.114.4 gist.github.com
185.199.110.153 github.io
140.82.112.4 github.com
140.82.114.6 api.github.com
185.199.111.133 raw.githubusercontent.com
185.199.109.133 user-images.githubusercontent.com
185.199.109.133 favicons.githubusercontent.com
185.199.108.133 avatars5.githubusercontent.com
185.199.108.133 avatars4.githubusercontent.com
185.199.109.133 avatars3.githubusercontent.com
185.199.111.133 avatars2.githubusercontent.com
185.199.111.133 avatars1.githubusercontent.com
185.199.111.133 avatars0.githubusercontent.com
185.199.110.133 avatars.githubusercontent.com
140.82.112.9 codeload.github.com
52.216.109.139 github-cloud.s3.amazonaws.com
52.217.47.60 github-com.s3.amazonaws.com
52.217.33.252 github-production-release-asset-2e65be.s3.amazonaws.com
54.231.131.17 github-production-user-asset-6210df.s3.amazonaws.com
54.231.135.201 github-production-repository-file-5c1aeb.s3.amazonaws.com
185.199.111.153 githubstatus.com
140.82.113.18 github.community
185.199.109.133 media.githubusercontent.com
185.199.111.133 objects.githubusercontent.com
185.199.110.133 raw.github.com
20.80.64.28 copilot-proxy.githubusercontent.com
```
</details>
## raw/avatars.githubusercontent.com 无法解析
除了host外还可以配置国内知名的dns进行解析因为1.1.1.1不一定好使,所以就用国内的。
* 百度DNS180.76.76.76
* 阿里DNS223.5.5.5、223.6.6.6
* 腾讯DNS119.29.29.29、182.254.116.116
### NET::ERR_CERT_AUTHORITY_INVALID
浏览器会额外提示:攻击者可能试图从 xxx.github.io 窃取你的信息,此服务器无法证明它是 xxx.github.io你的计算机的操作系统不信任它的安全证书。这可能是由配置错误或者有攻击者截获你的连接而导致的。当继续访问时又会403。
解招更改为如上提供的百度、阿里、腾讯DNS再用`ipconfig/flushdns` 刷新缓存。原因简述ISP提供的DNS发送错误的根证书换成能向访问网站提供正确证书的第三方DNS。
<!--
**说在前面这些问题都可以使用VPN直接解决但由于红朝特殊环境找到合适性价比的VPN又是一件比较困难的事更不用说免费的了而且免费的基本都赶尽杀绝了...**
-->
## Github 下载过慢处理releases
关于releases它可以是压缩包如zip、7z等格式也可以是软体程式比方说exe、msi
1. 打开[www.ipaddress.com](https://www.ipaddress.com/)查询以下链接的DNS解析地址
```
github.com
assets-cdn.github.com
github.global.ssl.fastly.net
# 下载链接 raw.githubusercontent.com 的实际地址
codeload.github.com
```
2. 记录下查询到的IP地址并添加进入`C:\Windows\System32\drivers\etc\Hosts`文件
3. 添加 aws host
```
219.76.4.4 s3.amazonaws.com
219.76.4.4 github-cloud.s3.amazonaws.com
```
4. 运行`cmd`输入`ipconfig /flushdns` 指令刷新系统DNS
### tip
chrome 扩展 [GitHub加速](https://chrome.google.com/webstore/detail/github%E5%8A%A0%E9%80%9F/mfnkflidjnladnkldfonnaicljppahpg/related?hl=zh-CN) + IDM/FDM 🤣
我们也可利用[jsDelivr](https://www.jsdelivr.com) CDN加速进行下载文件也可借此搭建访问速度加快的图床还有站点加速下载也可试试
* https://toolwa.com/github/
* http://g.widyun.com/
* https://shrill-pond-3e81.hunsh.workers.dev/
* http://www.toolzl.com/tools/githubjiasu.html
## Git Clone 克隆过慢改进
### 浅克隆
git clone 默认会下载项目的完整历史版本,若只关心最新的代码,而不关心之前的历史,可以使用浅复制功能:
```
$ git clone --depth=1 https://github.com/你的用户名/你的repo.git
```
`--depth=1` 表示只下载最近一次的版本,使用浅复制可以大大减少下载的数据量,这样即使在红色网络环境下,也可以快速的获得代码;若之后想获取完整历史信息,可以使用指令 `$ git fetch --unshallow`
git ssh方面: https://github.zhlh6.cn/ 加快速度。
### 代理方案
***git***
```
# 代理设置
git config --global http.proxy 'socks5://127.0.0.1:1080'
git config --global https.proxy 'socks5://127.0.0.1:1080'
# 取消代理
git config --global --unset https.proxy 'socks5://127.0.0.1:1080'
git config --global --unset http.proxy 'socks5://127.0.0.1:1080'
```
***mac***
```
# mac 终端
export http_proxy="socks5://127.0.0.1:1080"
export https_proxy="socks5://127.0.0.1:1080"
## 在 .bashrc 或 .zshrc 中设置
alias setproxy="export ALL_PROXY=socks5://127.0.0.1:1080"
alias unsetproxy="unset ALL_PROXY"
```
***openssh***
```
# github ssh 配置
## https://help.github.com/articles/using-ssh-over-the-https-port/
# HTTP 代理
ProxyCommand socat - PROXY:127.0.0.1:%h:%p,proxyport=8848
# socks5 代理
ProxyCommand nc -v -x 127.0.0.1:1080 %h %p
```
反向代理加速 —— Static CDN用来加载图片、内容等
* raw.githubusercontent.com 替换raw.staticdn.net
## sum
现在 gfw 都有自己应对机制。SNI干扰间歇性的部分地区封一部分另一地区放一部分。阻断是完全不能访问了。周期性的先减少用户使用再慢慢关停。
长期使用GitHub的人自然会折腾不常用的自然不去理会。
下载无非三个问题:
* 镜像源
* 代理&VPN以及hosts
* 包、库文件的互相对应的版本
### python 下载加速
由于部分项目需用到python因附pip下载加速`pip install 想要安装文件 -i 镜像源地址` 指令格式,以镜像源安装。
安装jupyter `pip install jupyter - i http://mirrors.aliyun.com/pypi/simple/`
国内常用pip源
* 清华大学 https://pypi.tuna.tsinghua.edu.cn/simple/
* 中国科学技术大学 http://pypi.mirrors.ustc.edu.cn/simple/
* 阿里云 http://mirrors.aliyun.com/pypi/simple/
* 中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/
* 豆瓣 http://pypi.douban.com/simple/
设定默认值,一劳永逸
```
pip install pip -U
pip config set global.index-url https://pypi.douban.com/simple/
```