From 497e3936af8f762acba1f6ae4cc8796ba83fb0b9 Mon Sep 17 00:00:00 2001 From: Stille Date: Thu, 17 Feb 2022 21:55:45 +0800 Subject: [PATCH] update gh-proxy --- gh-proxy/app/main.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/gh-proxy/app/main.py b/gh-proxy/app/main.py index 808e030..e8a419d 100644 --- a/gh-proxy/app/main.py +++ b/gh-proxy/app/main.py @@ -12,13 +12,12 @@ from urllib3.exceptions import ( DecodeError, ReadTimeoutError, ProtocolError) # config -# git使用cnpmjs镜像、分支文件使用jsDelivr镜像的开关,0为关闭,默认关闭 +# 分支文件使用jsDelivr镜像的开关,0为关闭,默认关闭 jsdelivr = 0 -cnpmjs = 0 size_limit = 1024 * 1024 * 1024 * 999 # 允许的文件大小,默认999GB,相当于无限制了 https://github.com/hunshcn/gh-proxy/issues/8 """ - 先生效白名单再匹配黑名单,pass_list匹配到的会直接302到jsdelivr/cnpmjs而忽略设置 + 先生效白名单再匹配黑名单,pass_list匹配到的会直接302到jsdelivr而忽略设置 生效顺序 白->黑->pass,可以前往https://github.com/hunshcn/gh-proxy/issues/41 查看示例 每个规则一行,可以封禁某个用户的所有仓库,也可以封禁某个用户的特定仓库,下方用黑名单示例,白名单同理 user1 # 封禁user1的所有仓库 @@ -142,9 +141,6 @@ def handler(u): if (jsdelivr or pass_by) and exp2.match(u): u = u.replace('/blob/', '@', 1).replace('github.com', 'cdn.jsdelivr.net/gh', 1) return redirect(u) - elif (cnpmjs or pass_by) and exp3.match(u): - u = u.replace('github.com', 'github.com.cnpmjs.org', 1) + request.url.replace(request.base_url, '', 1) - return redirect(u) elif (jsdelivr or pass_by) and exp4.match(u): u = re.sub(r'(\.com/.*?/.+?)/(.+?/)', r'\1@\2', u, 1) _u = u.replace('raw.githubusercontent.com', 'cdn.jsdelivr.net/gh', 1)