update gh-proxy

This commit is contained in:
Stille 2022-02-17 21:55:45 +08:00
parent e43f0a3dcc
commit 497e3936af
1 changed files with 2 additions and 6 deletions

View File

@ -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)