mirror of
https://github.com/WJQSERVER-STUDIO/ghproxy.git
synced 2026-02-03 08:11:11 +08:00
25w46a
This commit is contained in:
parent
a5bf7686bd
commit
d2a0177015
6 changed files with 32 additions and 14 deletions
10
CHANGELOG.md
10
CHANGELOG.md
|
|
@ -1,5 +1,15 @@
|
||||||
# 更新日志
|
# 更新日志
|
||||||
|
|
||||||
|
25w46b - 2025-06-14
|
||||||
|
---
|
||||||
|
- PRE-RELEASE: 此版本是v3.5.4预发布版本,请勿在生产环境中使用;
|
||||||
|
- CHANGE: 修改关闭行为以测试问题
|
||||||
|
|
||||||
|
25w46a - 2025-06-14
|
||||||
|
---
|
||||||
|
- PRE-RELEASE: 此版本是v3.5.4预发布版本,请勿在生产环境中使用;
|
||||||
|
- CHANGE: 修改payload行为以测试问题
|
||||||
|
|
||||||
3.5.3 - 2025-06-13
|
3.5.3 - 2025-06-13
|
||||||
---
|
---
|
||||||
- CHANGE: 显式配置`WithStreamBody(true)`
|
- CHANGE: 显式配置`WithStreamBody(true)`
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
25w45a
|
25w46a
|
||||||
|
|
@ -109,7 +109,7 @@ wget -O install-dev.sh https://raw.githubusercontent.com/WJQSERVER-STUDIO/ghprox
|
||||||
|
|
||||||
## LICENSE
|
## LICENSE
|
||||||
|
|
||||||
v3.5.2开始, 本项目使用 [WJQserver Studio License 2.0](https://wjqserver-studio.github.io/LICENSE/LICENSE.html) 和 [Mozilla Public License Version 2.0](https://mozilla.org/MPL/2.0/) 双重许可, 您可从中选择一个使用
|
v3.5.2开始, 本项目使用 [WJQserver Studio License 2.1](https://wjqserver-studio.github.io/LICENSE/LICENSE.html) 和 [Mozilla Public License Version 2.0](https://mozilla.org/MPL/2.0/) 双重许可, 您可从中选择一个使用
|
||||||
|
|
||||||
前端位于单独仓库中, 且各个主题均存在各自的许可证, 本项目许可证并不包括前端
|
前端位于单独仓库中, 且各个主题均存在各自的许可证, 本项目许可证并不包括前端
|
||||||
|
|
||||||
|
|
|
||||||
2
main.go
2
main.go
|
|
@ -507,7 +507,7 @@ func main() {
|
||||||
proxy.NoRouteHandler(cfg, limiter, iplimiter)(ctx, c)
|
proxy.NoRouteHandler(cfg, limiter, iplimiter)(ctx, c)
|
||||||
})
|
})
|
||||||
|
|
||||||
r.GET("/api.github.com/repos/:user/:repo/*filepath", func(ctx context.Context, c *app.RequestContext) {
|
r.Any("/api.github.com/repos/:user/:repo/*filepath", func(ctx context.Context, c *app.RequestContext) {
|
||||||
c.Set("matcher", "api")
|
c.Set("matcher", "api")
|
||||||
proxy.RoutingHandler(cfg, limiter, iplimiter)(ctx, c)
|
proxy.RoutingHandler(cfg, limiter, iplimiter)(ctx, c)
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package proxy
|
package proxy
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"ghproxy/config"
|
"ghproxy/config"
|
||||||
|
|
@ -23,16 +24,17 @@ func ChunkedProxyRequest(ctx context.Context, c *app.RequestContext, u string, c
|
||||||
go func() {
|
go func() {
|
||||||
<-ctx.Done()
|
<-ctx.Done()
|
||||||
if resp != nil && resp.Body != nil {
|
if resp != nil && resp.Body != nil {
|
||||||
resp.Body.Close()
|
err := resp.Body.Close()
|
||||||
}
|
if err != nil {
|
||||||
if req != nil {
|
logError("Failed to close response body: %v", err)
|
||||||
req.Body.Close()
|
}
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
rb := client.NewRequestBuilder(string(c.Request.Method()), u)
|
rb := client.NewRequestBuilder(string(c.Request.Method()), u)
|
||||||
rb.NoDefaultHeaders()
|
rb.NoDefaultHeaders()
|
||||||
rb.SetBody(c.Request.BodyStream())
|
rb.SetBody(bytes.NewBuffer(c.Request.Body()))
|
||||||
|
//rb.SetBody(c.RequestBodyStream())
|
||||||
rb.WithContext(ctx)
|
rb.WithContext(ctx)
|
||||||
|
|
||||||
req, err = rb.Build()
|
req, err = rb.Build()
|
||||||
|
|
@ -110,7 +112,12 @@ func ChunkedProxyRequest(ctx context.Context, c *app.RequestContext, u string, c
|
||||||
bodyReader = limitreader.NewRateLimitedReader(bodyReader, bandwidthLimit, int(bandwidthBurst), ctx)
|
bodyReader = limitreader.NewRateLimitedReader(bodyReader, bandwidthLimit, int(bandwidthBurst), ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
defer bodyReader.Close()
|
defer func() {
|
||||||
|
err := bodyReader.Close()
|
||||||
|
if err != nil {
|
||||||
|
logError("Failed to close response body: %v", err)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
if MatcherShell(u) && matchString(matcher) && cfg.Shell.Editor {
|
if MatcherShell(u) && matchString(matcher) && cfg.Shell.Editor {
|
||||||
// 判断body是不是gzip
|
// 判断body是不是gzip
|
||||||
|
|
|
||||||
|
|
@ -17,15 +17,16 @@ func GitReq(ctx context.Context, c *app.RequestContext, u string, cfg *config.Co
|
||||||
var (
|
var (
|
||||||
req *http.Request
|
req *http.Request
|
||||||
resp *http.Response
|
resp *http.Response
|
||||||
|
err error
|
||||||
)
|
)
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
<-ctx.Done()
|
<-ctx.Done()
|
||||||
if resp != nil && resp.Body != nil {
|
if resp != nil && resp.Body != nil {
|
||||||
resp.Body.Close()
|
err = resp.Body.Close()
|
||||||
}
|
if err != nil {
|
||||||
if req != nil {
|
logError("Failed to close response body: %v", err)
|
||||||
req.Body.Close()
|
}
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
|
@ -51,7 +52,7 @@ func GitReq(ctx context.Context, c *app.RequestContext, u string, cfg *config.Co
|
||||||
rb.SetBody(reqBodyReader)
|
rb.SetBody(reqBodyReader)
|
||||||
rb.WithContext(ctx)
|
rb.WithContext(ctx)
|
||||||
|
|
||||||
req, err := rb.Build()
|
req, err = rb.Build()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
HandleError(c, fmt.Sprintf("Failed to create request: %v", err))
|
HandleError(c, fmt.Sprintf("Failed to create request: %v", err))
|
||||||
return
|
return
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue