mirror of https://github.com/hunshcn/gh-proxy
Update README.md
parent
774d23d86c
commit
ea1ac15efc
236
README.md
236
README.md
|
@ -1,118 +1,148 @@
|
|||
# gh-proxy
|
||||
|
||||
## 简介
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-Hans">
|
||||
<style>
|
||||
html, body {
|
||||
width: 100%;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
github release、archive以及项目文件的加速项目,支持clone,有Cloudflare Workers无服务器版本以及Python版本
|
||||
html {
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
## 演示
|
||||
body {
|
||||
min-height: 100%;
|
||||
padding: 20px;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
[https://gh.api.99988866.xyz/](https://gh.api.99988866.xyz/)
|
||||
p {
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
演示站为公共服务,如有大规模使用需求请自行部署,演示站有点不堪重负
|
||||
@media (max-width: 500px) {
|
||||
h1 {
|
||||
margin-top: 80px;
|
||||
}
|
||||
}
|
||||
|
||||

|
||||
.flex {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
当然也欢迎[捐赠](#捐赠)以支持作者
|
||||
.block {
|
||||
display: block;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
## python版本和cf worker版本差异
|
||||
.url {
|
||||
font-size: 18px;
|
||||
padding: 10px 10px 10px 5px;
|
||||
position: relative;
|
||||
width: 300px;
|
||||
border: none;
|
||||
border-bottom: 1px solid #bfbfbf;
|
||||
}
|
||||
|
||||
- python版本支持进行文件大小限制,超过设定返回原地址 [issue #8](https://github.com/hunshcn/gh-proxy/issues/8)
|
||||
input:focus {
|
||||
outline: none;
|
||||
}
|
||||
|
||||
- python版本支持特定user/repo 封禁/白名单 以及passby [issue #41](https://github.com/hunshcn/gh-proxy/issues/41)
|
||||
.bar {
|
||||
content: '';
|
||||
height: 2px;
|
||||
width: 100%;
|
||||
bottom: 0;
|
||||
position: absolute;
|
||||
background: #00bfb3;
|
||||
transition: 0.2s ease transform;
|
||||
-moz-transition: 0.2s ease transform;
|
||||
-webkit-transition: 0.2s ease transform;
|
||||
transform: scaleX(0);
|
||||
}
|
||||
|
||||
## 使用
|
||||
.url:focus ~ .bar {
|
||||
transform: scaleX(1);
|
||||
}
|
||||
|
||||
直接在copy出来的url前加`https://gh.api.99988866.xyz/`即可
|
||||
.btn {
|
||||
line-height: 38px;
|
||||
background-color: #00bfb3;
|
||||
color: #fff;
|
||||
white-space: nowrap;
|
||||
text-align: center;
|
||||
font-size: 14px;
|
||||
border: none;
|
||||
border-radius: 2px;
|
||||
cursor: pointer;
|
||||
padding: 5px;
|
||||
width: 160px;
|
||||
margin: 30px 0;
|
||||
}
|
||||
|
||||
也可以直接访问,在input输入
|
||||
.tips, .example {
|
||||
color: #7b7b7b;
|
||||
position: relative;
|
||||
align-self: flex-start;
|
||||
margin-left: 7.5em;
|
||||
}
|
||||
|
||||
***大量使用请自行部署,以上域名仅为演示使用。***
|
||||
.tips > p:first-child::before {
|
||||
position: absolute;
|
||||
left: -3em;
|
||||
content: 'PS:';
|
||||
color: #7b7b7b
|
||||
}
|
||||
|
||||
访问私有仓库可以通过
|
||||
|
||||
`git clone https://user:TOKEN@ghproxy.com/https://github.com/xxxx/xxxx` [#71](https://github.com/hunshcn/gh-proxy/issues/71)
|
||||
|
||||
以下都是合法输入(仅示例,文件不存在):
|
||||
|
||||
- 分支源码:https://github.com/hunshcn/project/archive/master.zip
|
||||
|
||||
- release源码:https://github.com/hunshcn/project/archive/v0.1.0.tar.gz
|
||||
|
||||
- release文件:https://github.com/hunshcn/project/releases/download/v0.1.0/example.zip
|
||||
|
||||
- 分支文件:https://github.com/hunshcn/project/blob/master/filename
|
||||
|
||||
- commit文件:https://github.com/hunshcn/project/blob/1111111111111111111111111111/filename
|
||||
|
||||
- gist:https://gist.githubusercontent.com/cielpy/351557e6e465c12986419ac5a4dd2568/raw/cmd.py
|
||||
|
||||
## cf worker版本部署
|
||||
|
||||
首页:https://workers.cloudflare.com
|
||||
|
||||
注册,登陆,`Start building`,取一个子域名,`Create a Worker`。
|
||||
|
||||
复制 [index.js](https://cdn.jsdelivr.net/gh/hunshcn/gh-proxy@master/index.js) 到左侧代码框,`Save and deploy`。如果正常,右侧应显示首页。
|
||||
|
||||
`ASSET_URL`是静态资源的url(实际上就是现在显示出来的那个输入框单页面)
|
||||
|
||||
`PREFIX`是前缀,默认(根路径情况为"/"),如果自定义路由为example.com/gh/*,请将PREFIX改为 '/gh/',注意,少一个杠都会错!
|
||||
|
||||
## Python版本部署
|
||||
|
||||
### Docker部署
|
||||
|
||||
```
|
||||
docker run -d --name="gh-proxy-py" \
|
||||
-p 0.0.0.0:80:80 \
|
||||
--restart=always \
|
||||
hunsh/gh-proxy-py:latest
|
||||
```
|
||||
|
||||
第一个80是你要暴露出去的端口
|
||||
|
||||
### 直接部署
|
||||
|
||||
安装依赖(请使用python3)
|
||||
|
||||
```pip install flask requests```
|
||||
|
||||
按需求修改`app/main.py`的前几项配置
|
||||
|
||||
*注意:* 可能需要在`return Response`前加两行
|
||||
```python3
|
||||
if 'Transfer-Encoding' in headers:
|
||||
headers.pop('Transfer-Encoding')
|
||||
```
|
||||
|
||||
### 注意
|
||||
|
||||
python版本的机器如果无法正常访问github.io会启动报错,请自行修改静态文件url
|
||||
|
||||
python版本默认走服务器(2021.3.27更新)
|
||||
|
||||
## Cloudflare Workers计费
|
||||
|
||||
到 `overview` 页面可参看使用情况。免费版每天有 10 万次免费请求,并且有每分钟1000次请求的限制。
|
||||
|
||||
如果不够用,可升级到 $5 的高级版本,每月可用 1000 万次请求(超出部分 $0.5/百万次请求)。
|
||||
|
||||
## Changelog
|
||||
|
||||
* 2020.04.10 增加对`raw.githubusercontent.com`文件的支持
|
||||
* 2020.04.09 增加Python版本(使用Flask)
|
||||
* 2020.03.23 新增了clone的支持
|
||||
* 2020.03.22 初始版本
|
||||
|
||||
## 链接
|
||||
|
||||
[我的博客](https://hunsh.net)
|
||||
|
||||
## 参考
|
||||
|
||||
[jsproxy](https://github.com/EtherDream/jsproxy/)
|
||||
|
||||
## 捐赠
|
||||
|
||||

|
||||

|
||||
.example > p:first-child::before {
|
||||
position: absolute;
|
||||
left: -7.5em;
|
||||
content: '合法输入示例:';
|
||||
color: #7b7b7b
|
||||
}
|
||||
</style>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1.0">
|
||||
<script>
|
||||
function toSubmit(e) {
|
||||
e.preventDefault()
|
||||
window.open(location.href.substr(0, location.href.lastIndexOf('/') + 1) + document.getElementsByName('q')[0].value);
|
||||
return false
|
||||
}
|
||||
</script>
|
||||
<title>GitHub 文件加速</title>
|
||||
</head>
|
||||
<body class="flex">
|
||||
<a style="position: absolute;top: 0;right: 0;" href="https://github.com/hunshcn/gh-proxy"><img width="149" height="149" referrerPolicy="no-referrer"
|
||||
src="https://inews.gtimg.com/newsapp_ls/0/12025455907/0"
|
||||
alt="Fork me on GitHub"
|
||||
data-recalc-dims="1"></a>
|
||||
<h1 style="margin-bottom: 50px">GitHub 文件加速</h1>
|
||||
<form action="./" method="get" style="padding-bottom: 40px" target="_blank" class="flex" onsubmit="toSubmit(event)">
|
||||
<label class="block" style="width: fit-content">
|
||||
<input class="block url" name="q" type="text" placeholder="键入Github文件链接"
|
||||
pattern="^((https|http):\/\/)?(github\.com\/.+?\/.+?\/(?:releases|archive|blob|raw|suites)|((?:raw|gist)\.(?:githubusercontent|github)\.com))\/.+$" required>
|
||||
<div class="bar"></div>
|
||||
</label>
|
||||
<input class="block btn" type="submit" value="下载">
|
||||
<div class="tips"><p>GitHub文件链接带不带协议头都可以,支持release、archive以及文件,右键复制出来的链接都是符合标准的,更多用法、clone加速请参考<a href="https://hunsh.net/archives/23/">这篇文章</a>。</p>
|
||||
<p>release、archive使用cf加速,文件会跳转至JsDelivr</p>
|
||||
<p>注意,不支持项目文件夹</p></div>
|
||||
<div class="example">
|
||||
<p>分支源码:https://github.com/hunshcn/project/archive/master.zip</p>
|
||||
<p>release源码:https://github.com/hunshcn/project/archive/v0.1.0.tar.gz</p>
|
||||
<p>release文件:https://github.com/hunshcn/project/releases/download/v0.1.0/example.zip</p>
|
||||
<p>分支文件:https://github.com/hunshcn/project/blob/master/filename</p>
|
||||
</div>
|
||||
</form>
|
||||
<p style="position: sticky;top: calc(100% - 2.5em);">项目基于Cloudflare Workers,开源于GitHub <a style="color: #3294ea"
|
||||
href="https://github.com/hunshcn/gh-proxy">hunshcn/gh-proxy</a>
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
||||
|
|
Loading…
Reference in New Issue