mirror of
https://github.com/WJQSERVER-STUDIO/ghproxy.git
synced 2026-02-03 00:01:10 +08:00
commit
078e556584
11 changed files with 68 additions and 31 deletions
6
.github/workflows/build-dev.yml
vendored
6
.github/workflows/build-dev.yml
vendored
|
|
@ -68,6 +68,12 @@ jobs:
|
||||||
uses: actions/setup-go@v3
|
uses: actions/setup-go@v3
|
||||||
with:
|
with:
|
||||||
go-version: ${{ env.GO_VERSION }}
|
go-version: ${{ env.GO_VERSION }}
|
||||||
|
- name: 测试
|
||||||
|
env:
|
||||||
|
GOOS: ${{ matrix.goos }}
|
||||||
|
GOARCH: ${{ matrix.goarch }}
|
||||||
|
run: |
|
||||||
|
go test ./..
|
||||||
- name: 编译
|
- name: 编译
|
||||||
env:
|
env:
|
||||||
GOOS: ${{ matrix.goos }}
|
GOOS: ${{ matrix.goos }}
|
||||||
|
|
|
||||||
6
.github/workflows/build.yml
vendored
6
.github/workflows/build.yml
vendored
|
|
@ -69,6 +69,12 @@ jobs:
|
||||||
uses: actions/setup-go@v3
|
uses: actions/setup-go@v3
|
||||||
with:
|
with:
|
||||||
go-version: ${{ env.GO_VERSION }}
|
go-version: ${{ env.GO_VERSION }}
|
||||||
|
- name: 测试
|
||||||
|
env:
|
||||||
|
GOOS: ${{ matrix.goos }}
|
||||||
|
GOARCH: ${{ matrix.goarch }}
|
||||||
|
run: |
|
||||||
|
go test ./..
|
||||||
- name: 编译
|
- name: 编译
|
||||||
env:
|
env:
|
||||||
GOOS: ${{ matrix.goos }}
|
GOOS: ${{ matrix.goos }}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,14 @@
|
||||||
# 更新日志
|
# 更新日志
|
||||||
|
|
||||||
|
4.2.4 - 2025-07-29
|
||||||
|
---
|
||||||
|
- CHANGE: 改进匹配器, 防止匹配不应匹配的内容
|
||||||
|
|
||||||
|
4.2.4-rc.0 - 2025-07-29
|
||||||
|
---
|
||||||
|
- PRE-RELEASE: v4.2.4-rc.0是v4.2.4预发布版本,请勿在生产环境中使用;
|
||||||
|
- CHANGE: 改进匹配器, 防止匹配不应匹配的内容
|
||||||
|
|
||||||
4.2.3 - 2025-07-27
|
4.2.3 - 2025-07-27
|
||||||
---
|
---
|
||||||
- CHANGE: 改进错误页面加载器, 避免在选择`external`模式时错误页面渲染回退到json输出
|
- CHANGE: 改进错误页面加载器, 避免在选择`external`模式时错误页面渲染回退到json输出
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
4.2.3-rc.0
|
4.2.4-rc.0
|
||||||
2
VERSION
2
VERSION
|
|
@ -1 +1 @@
|
||||||
4.2.3
|
4.2.4
|
||||||
15
go.mod
15
go.mod
|
|
@ -4,7 +4,7 @@ go 1.24.5
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/BurntSushi/toml v1.5.0
|
github.com/BurntSushi/toml v1.5.0
|
||||||
github.com/WJQSERVER-STUDIO/httpc v0.8.1
|
github.com/WJQSERVER-STUDIO/httpc v0.8.2
|
||||||
golang.org/x/net v0.42.0
|
golang.org/x/net v0.42.0
|
||||||
golang.org/x/time v0.12.0
|
golang.org/x/time v0.12.0
|
||||||
)
|
)
|
||||||
|
|
@ -15,15 +15,12 @@ require (
|
||||||
github.com/fenthope/bauth v0.0.1
|
github.com/fenthope/bauth v0.0.1
|
||||||
github.com/fenthope/ikumi v0.0.2
|
github.com/fenthope/ikumi v0.0.2
|
||||||
github.com/fenthope/ipfilter v0.0.1
|
github.com/fenthope/ipfilter v0.0.1
|
||||||
github.com/fenthope/reco v0.0.3
|
github.com/fenthope/reco v0.0.4
|
||||||
github.com/fenthope/record v0.0.3
|
github.com/fenthope/record v0.0.4
|
||||||
github.com/go-json-experiment/json v0.0.0-20250714165856-be8212f5270d
|
github.com/go-json-experiment/json v0.0.0-20250725192818-e39067aee2d2
|
||||||
github.com/hashicorp/golang-lru/v2 v2.0.7
|
github.com/hashicorp/golang-lru/v2 v2.0.7
|
||||||
github.com/infinite-iroha/touka v0.3.3
|
github.com/infinite-iroha/touka v0.3.4
|
||||||
github.com/wjqserver/modembed v0.0.1
|
github.com/wjqserver/modembed v0.0.1
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require github.com/valyala/bytebufferpool v1.0.0 // indirect
|
||||||
github.com/WJQSERVER-STUDIO/go-utils/copyb v0.0.6 // indirect
|
|
||||||
github.com/valyala/bytebufferpool v1.0.0 // indirect
|
|
||||||
)
|
|
||||||
|
|
|
||||||
22
go.sum
22
go.sum
|
|
@ -1,29 +1,27 @@
|
||||||
github.com/BurntSushi/toml v1.5.0 h1:W5quZX/G/csjUnuI8SUYlsHs9M38FC7znL0lIO+DvMg=
|
github.com/BurntSushi/toml v1.5.0 h1:W5quZX/G/csjUnuI8SUYlsHs9M38FC7znL0lIO+DvMg=
|
||||||
github.com/BurntSushi/toml v1.5.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho=
|
github.com/BurntSushi/toml v1.5.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho=
|
||||||
github.com/WJQSERVER-STUDIO/go-utils/copyb v0.0.6 h1:/50VJYXd6jcu+p5BnEBDyiX0nAyGxas1W3DCnrYMxMY=
|
|
||||||
github.com/WJQSERVER-STUDIO/go-utils/copyb v0.0.6/go.mod h1:FZ6XE+4TKy4MOfX1xWKe6Rwsg0ucYFCdNh1KLvyKTfc=
|
|
||||||
github.com/WJQSERVER-STUDIO/go-utils/iox v0.0.2 h1:AiIHXP21LpK7pFfqUlUstgQEWzjbekZgxOuvVwiMfyM=
|
github.com/WJQSERVER-STUDIO/go-utils/iox v0.0.2 h1:AiIHXP21LpK7pFfqUlUstgQEWzjbekZgxOuvVwiMfyM=
|
||||||
github.com/WJQSERVER-STUDIO/go-utils/iox v0.0.2/go.mod h1:mCLqYU32bTmEE6dpj37MKKiZgz70Jh/xyK9vVbq6pok=
|
github.com/WJQSERVER-STUDIO/go-utils/iox v0.0.2/go.mod h1:mCLqYU32bTmEE6dpj37MKKiZgz70Jh/xyK9vVbq6pok=
|
||||||
github.com/WJQSERVER-STUDIO/go-utils/limitreader v0.0.2 h1:8bBkKk6E2Zr+I5szL7gyc5f0DK8N9agIJCpM1Cqw2NE=
|
github.com/WJQSERVER-STUDIO/go-utils/limitreader v0.0.2 h1:8bBkKk6E2Zr+I5szL7gyc5f0DK8N9agIJCpM1Cqw2NE=
|
||||||
github.com/WJQSERVER-STUDIO/go-utils/limitreader v0.0.2/go.mod h1:yPX8xuZH+py7eLJwOYj3VVI/4/Yuy5+x8Mhq8qezcPg=
|
github.com/WJQSERVER-STUDIO/go-utils/limitreader v0.0.2/go.mod h1:yPX8xuZH+py7eLJwOYj3VVI/4/Yuy5+x8Mhq8qezcPg=
|
||||||
github.com/WJQSERVER-STUDIO/httpc v0.8.1 h1:/eG8aYKL3WfQILIRbG+cbzQjPkNHEPTqfGUdQS5rtI4=
|
github.com/WJQSERVER-STUDIO/httpc v0.8.2 h1:PFPLodV0QAfGEP6915J57vIqoKu9cGuuiXG/7C9TNUk=
|
||||||
github.com/WJQSERVER-STUDIO/httpc v0.8.1/go.mod h1:mxXBf2hqbQGNHkVy/7wfU7Xi2s09MyZpbY2hyR+4uD4=
|
github.com/WJQSERVER-STUDIO/httpc v0.8.2/go.mod h1:8WhHVRO+olDFBSvL5PC/bdMkb6U3vRdPJ4p4pnguV5Y=
|
||||||
github.com/fenthope/bauth v0.0.1 h1:+4UIQshGx3mYD4L3f2S4MLZOi5PWU7fU5GK3wsZvwzE=
|
github.com/fenthope/bauth v0.0.1 h1:+4UIQshGx3mYD4L3f2S4MLZOi5PWU7fU5GK3wsZvwzE=
|
||||||
github.com/fenthope/bauth v0.0.1/go.mod h1:1fveTpgfR1p+WXQ8MXm9BfBCeNYi55j23jxCOGOvBSA=
|
github.com/fenthope/bauth v0.0.1/go.mod h1:1fveTpgfR1p+WXQ8MXm9BfBCeNYi55j23jxCOGOvBSA=
|
||||||
github.com/fenthope/ikumi v0.0.2 h1:5oaSTf/Msp7M2O3o/X20omKWEQbFhX4KV0CVF21oCdk=
|
github.com/fenthope/ikumi v0.0.2 h1:5oaSTf/Msp7M2O3o/X20omKWEQbFhX4KV0CVF21oCdk=
|
||||||
github.com/fenthope/ikumi v0.0.2/go.mod h1:IYbxzOGndZv/yRrbVMyV6dxh06X2wXCbfxrTRM1IruU=
|
github.com/fenthope/ikumi v0.0.2/go.mod h1:IYbxzOGndZv/yRrbVMyV6dxh06X2wXCbfxrTRM1IruU=
|
||||||
github.com/fenthope/ipfilter v0.0.1 h1:HrYAyixCMvsDAz36GRyFfyCNtrgYwzrhMcY0XV7fGcM=
|
github.com/fenthope/ipfilter v0.0.1 h1:HrYAyixCMvsDAz36GRyFfyCNtrgYwzrhMcY0XV7fGcM=
|
||||||
github.com/fenthope/ipfilter v0.0.1/go.mod h1:QfY0GrpG0D82HROgdH4c9eog4js42ghLIfl/iM4MvvY=
|
github.com/fenthope/ipfilter v0.0.1/go.mod h1:QfY0GrpG0D82HROgdH4c9eog4js42ghLIfl/iM4MvvY=
|
||||||
github.com/fenthope/reco v0.0.3 h1:RmnQ0D9a8PWtwOODawitTe4BztTnS9wYwrDbipISNq4=
|
github.com/fenthope/reco v0.0.4 h1:yo2g3aWwdoMpaZWZX4SdZOW7mCK82RQIU/YI8ZUQThM=
|
||||||
github.com/fenthope/reco v0.0.3/go.mod h1:mDkGLHte5udWTIcjQTxrABRcf56SSdxBOCLgrRDwI/Y=
|
github.com/fenthope/reco v0.0.4/go.mod h1:eMyS8HpdMVdJ/2WJt6Cvt8P1EH9Igzj5lSJrgc+0jeg=
|
||||||
github.com/fenthope/record v0.0.3 h1:v5urgs5LAkLMlljAT/MjW8fWuRHXPnAraTem5ui7rm4=
|
github.com/fenthope/record v0.0.4 h1:/1JHNCxiXGLL/qCh4LEGaAvhj4CcKsb6siTxjLmjdO4=
|
||||||
github.com/fenthope/record v0.0.3/go.mod h1:KFEkSc4TDZ3QIhP/wglD32uYVA6X1OUcripiao1DEE4=
|
github.com/fenthope/record v0.0.4/go.mod h1:G0a6KCiCDyX2SsC3nfzSN651fJKxH482AyJvzlnvAJU=
|
||||||
github.com/go-json-experiment/json v0.0.0-20250714165856-be8212f5270d h1:+d6m5Bjvv0/RJct1VcOw2P5bvBOGjENmxORJYnSYDow=
|
github.com/go-json-experiment/json v0.0.0-20250725192818-e39067aee2d2 h1:iizUGZ9pEquQS5jTGkh4AqeeHCMbfbjeb0zMt0aEFzs=
|
||||||
github.com/go-json-experiment/json v0.0.0-20250714165856-be8212f5270d/go.mod h1:TiCD2a1pcmjd7YnhGH0f/zKNcCD06B029pHhzV23c2M=
|
github.com/go-json-experiment/json v0.0.0-20250725192818-e39067aee2d2/go.mod h1:TiCD2a1pcmjd7YnhGH0f/zKNcCD06B029pHhzV23c2M=
|
||||||
github.com/hashicorp/golang-lru/v2 v2.0.7 h1:a+bsQ5rvGLjzHuww6tVxozPZFVghXaHOwFs4luLUK2k=
|
github.com/hashicorp/golang-lru/v2 v2.0.7 h1:a+bsQ5rvGLjzHuww6tVxozPZFVghXaHOwFs4luLUK2k=
|
||||||
github.com/hashicorp/golang-lru/v2 v2.0.7/go.mod h1:QeFd9opnmA6QUJc5vARoKUSoFhyfM2/ZepoAG6RGpeM=
|
github.com/hashicorp/golang-lru/v2 v2.0.7/go.mod h1:QeFd9opnmA6QUJc5vARoKUSoFhyfM2/ZepoAG6RGpeM=
|
||||||
github.com/infinite-iroha/touka v0.3.3 h1:6Vy36bYjtbGKaBNiZBRcTne9Lcx8QTE6rpHqyMb3oiA=
|
github.com/infinite-iroha/touka v0.3.4 h1:vYDjfXTkjpTe7tasSVbPeVAPSXzd/wS1T2tkiMx/Wwk=
|
||||||
github.com/infinite-iroha/touka v0.3.3/go.mod h1:9Y/MWlvlBL/8cqA+2ZUsnBr4h3f7yo3nOxsegIcBduw=
|
github.com/infinite-iroha/touka v0.3.4/go.mod h1:xOKkEKTWYLHIBW6qbL2O6nSAO0RyDLsVXPtJxFYg/YM=
|
||||||
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
|
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
|
||||||
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
|
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
|
||||||
github.com/wjqserver/modembed v0.0.1 h1:8ZDz7t9M5DLrUFlYgBUUmrMzxWsZPmHvOazkr/T2jEs=
|
github.com/wjqserver/modembed v0.0.1 h1:8ZDz7t9M5DLrUFlYgBUUmrMzxWsZPmHvOazkr/T2jEs=
|
||||||
|
|
|
||||||
2
main.go
2
main.go
|
|
@ -394,7 +394,7 @@ func main() {
|
||||||
setupPages(cfg, r)
|
setupPages(cfg, r)
|
||||||
r.SetRedirectTrailingSlash(false)
|
r.SetRedirectTrailingSlash(false)
|
||||||
|
|
||||||
r.GET("/github.com/:user/:repo/releases/*filepath", func(c *touka.Context) {
|
r.GET("/github.com/:user/:repo/releases/download/*filepath", func(c *touka.Context) {
|
||||||
c.Set("matcher", "releases")
|
c.Set("matcher", "releases")
|
||||||
proxy.RoutingHandler(cfg)(c)
|
proxy.RoutingHandler(cfg)(c)
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,6 @@ func HandleError(c *touka.Context, message string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func UnifiedToukaErrorHandler(c *touka.Context, code int, err error) {
|
func UnifiedToukaErrorHandler(c *touka.Context, code int, err error) {
|
||||||
|
|
||||||
errMsg := ""
|
errMsg := ""
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errMsg = err.Error()
|
errMsg = err.Error()
|
||||||
|
|
|
||||||
|
|
@ -10,11 +10,6 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
githubPrefix = "https://github.com/"
|
|
||||||
rawPrefix = "https://raw.githubusercontent.com/"
|
|
||||||
gistPrefix = "https://gist.github.com/"
|
|
||||||
gistContentPrefix = "https://gist.githubusercontent.com/"
|
|
||||||
apiPrefix = "https://api.github.com/"
|
|
||||||
githubPrefixLen int
|
githubPrefixLen int
|
||||||
rawPrefixLen int
|
rawPrefixLen int
|
||||||
gistPrefixLen int
|
gistPrefixLen int
|
||||||
|
|
@ -22,6 +17,15 @@ var (
|
||||||
apiPrefixLen int
|
apiPrefixLen int
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
githubPrefix = "https://github.com/"
|
||||||
|
rawPrefix = "https://raw.githubusercontent.com/"
|
||||||
|
gistPrefix = "https://gist.github.com/"
|
||||||
|
gistContentPrefix = "https://gist.githubusercontent.com/"
|
||||||
|
apiPrefix = "https://api.github.com/"
|
||||||
|
releasesDownloadSnippet = "releases/download/"
|
||||||
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
githubPrefixLen = len(githubPrefix)
|
githubPrefixLen = len(githubPrefix)
|
||||||
rawPrefixLen = len(rawPrefix)
|
rawPrefixLen = len(rawPrefix)
|
||||||
|
|
@ -61,7 +65,13 @@ func Matcher(rawPath string, cfg *config.Config) (string, string, string, *GHPro
|
||||||
}
|
}
|
||||||
var matcher string
|
var matcher string
|
||||||
switch action {
|
switch action {
|
||||||
case "releases", "archive":
|
case "releases":
|
||||||
|
if strings.HasPrefix(remaining, releasesDownloadSnippet) {
|
||||||
|
matcher = "releases"
|
||||||
|
} else {
|
||||||
|
return "", "", "", NewErrorWithStatusLookup(400, "malformed github path: not a releases download url")
|
||||||
|
}
|
||||||
|
case "archive":
|
||||||
matcher = "releases"
|
matcher = "releases"
|
||||||
case "blob":
|
case "blob":
|
||||||
matcher = "blob"
|
matcher = "blob"
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,18 @@ func TestMatcher_Compatibility(t *testing.T) {
|
||||||
config: cfgWithAuth,
|
config: cfgWithAuth,
|
||||||
expectedUser: "owner", expectedRepo: "repo", expectedMatcher: "releases",
|
expectedUser: "owner", expectedRepo: "repo", expectedMatcher: "releases",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "GH Releases Path Page",
|
||||||
|
rawPath: "https://github.com/owner/repo/releases",
|
||||||
|
config: cfgWithAuth,
|
||||||
|
expectError: true, expectedErrCode: 400,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "GH Releases Path Tag Page",
|
||||||
|
rawPath: "https://github.com/owner/repo/releases/tag/v0.0.1",
|
||||||
|
config: cfgWithAuth,
|
||||||
|
expectError: true, expectedErrCode: 400,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: "GH Archive Path",
|
name: "GH Archive Path",
|
||||||
rawPath: "https://github.com/owner/repo.git/archive/main.zip",
|
rawPath: "https://github.com/owner/repo.git/archive/main.zip",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue