update gh-proxy
This commit is contained in:
parent
e43f0a3dcc
commit
497e3936af
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue