From d05c13fdd67a411298e6bf97db4c56522b33ff21 Mon Sep 17 00:00:00 2001 From: xueweihan <595666367@qq.com> Date: Sat, 29 Jun 2024 12:17:05 +0800 Subject: [PATCH] add url --- README_template.md | 28 ++++++++++++++++++++++++++-- fetch_ips.py | 2 +- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/README_template.md b/README_template.md index 12608a9e9..efe2cf65a 100644 --- a/README_template.md +++ b/README_template.md @@ -5,7 +5,7 @@ 😘 让你“爱”上 GitHub,解决访问时图裂、加载慢的问题。

-> 服务器已续费到 2024.12 共花了:1500+💰 [点击扫码赞助](https://cdn.jsdelivr.net/gh/521xueweihan/img_logo@main/logo/receiving_code.png),感谢🙏 +> 服务器已续费到 2024.12 共花了:1500+💰 [点击扫码赞助](https://raw.hellogithub.com/code.png),感谢🙏 ## 一、介绍 对 GitHub 说"爱"太难了:访问慢、图片加载不出来。 @@ -86,7 +86,31 @@ hosts 文件在每个系统的位置不一,详情如下: 这样每次 hosts 有更新都能及时进行更新,免去手动更新。 -### 2.3 一行命令 (适用于类 Unix 系统) +### 2.3 一行命令 + +#### windows + +使用命令需要安装[git bash](https://gitforwindows.org/) +复制以下命令保存到本地命名为**fetch_github_hosts** + +```shell +_hosts=$(mktemp /tmp/hostsXXX) +hosts=/c/Windows/System32/drivers/etc/hosts +remote=https://raw.hellogithub.com/hosts +reg='/# GitHub520 Host Start/,/# Github520 Host End/d' + +sed "$reg" $hosts > "$_hosts" +curl "$remote" >> "$_hosts" +cat "$_hosts" > "$hosts" + +rm "$_hosts" +``` + +在**CMD**中执行以下命令,执行前需要替换**git-bash.exe**和**fetch_github_hosts**为你本地的路径,注意前者为windows路径格式后者为shell路径格式 + +`"C:\Program Files\Git\git-bash.exe" -c "/c/Users/XXX/fetch_github_hosts"` + +可以将上述命令添加到windows的task schedular(任务计划程序)中以定时执行 #### GNU(Ubuntu/CentOS/Fedora) diff --git a/fetch_ips.py b/fetch_ips.py index c4d01795d..65c0f8f7e 100644 --- a/fetch_ips.py +++ b/fetch_ips.py @@ -34,7 +34,7 @@ GITHUB_URLS = [ 'githubstatus.com', 'live.github.com', 'media.githubusercontent.com', 'objects.githubusercontent.com', 'pipelines.actions.githubusercontent.com', 'raw.githubusercontent.com', 'user-images.githubusercontent.com', - 'vscode.dev', 'education.github.com' + 'vscode.dev', 'education.github.com', 'private-user-images.githubusercontent.com' ] HOSTS_TEMPLATE = """# GitHub520 Host Start