mirror of
https://github.com/WJQSERVER-STUDIO/ghproxy.git
synced 2026-02-03 00:01:10 +08:00
25w46c
This commit is contained in:
parent
bd8412f157
commit
41395b1d72
5 changed files with 29 additions and 12 deletions
|
|
@ -1,5 +1,10 @@
|
||||||
# 更新日志
|
# 更新日志
|
||||||
|
|
||||||
|
25w46c - 2025-06-14
|
||||||
|
---
|
||||||
|
- PRE-RELEASE: 此版本是v3.5.4预发布版本,请勿在生产环境中使用;
|
||||||
|
- CHANGE: 移植来自于[GHProxy-Touka](https://github.com/WJQSERVER-STUDIO/ghproxy-touka)的blob处理逻辑与302处理逻辑
|
||||||
|
|
||||||
25w46b - 2025-06-14
|
25w46b - 2025-06-14
|
||||||
---
|
---
|
||||||
- PRE-RELEASE: 此版本是v3.5.4预发布版本,请勿在生产环境中使用;
|
- PRE-RELEASE: 此版本是v3.5.4预发布版本,请勿在生产环境中使用;
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
25w46b
|
25w46c
|
||||||
|
|
@ -57,6 +57,20 @@ func ChunkedProxyRequest(ctx context.Context, c *app.RequestContext, u string, c
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 处理302情况
|
||||||
|
if resp.StatusCode == 302 {
|
||||||
|
finalURL := resp.Header.Get("Location")
|
||||||
|
if finalURL != "" {
|
||||||
|
err = resp.Body.Close()
|
||||||
|
if err != nil {
|
||||||
|
logError("Failed to close response body: %v", err)
|
||||||
|
}
|
||||||
|
c.Request.Header.Del("Referer")
|
||||||
|
logInfo("Internal Redirecting to %s", finalURL)
|
||||||
|
ChunkedProxyRequest(ctx, c, finalURL, cfg, matcher)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
bodySize int
|
bodySize int
|
||||||
contentLength string
|
contentLength string
|
||||||
|
|
@ -111,15 +125,6 @@ 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 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
|
||||||
var compress string
|
var compress string
|
||||||
|
|
|
||||||
|
|
@ -68,7 +68,10 @@ func NoRouteHandler(cfg *config.Config, limiter *rate.RateLimiter, iplimiter *ra
|
||||||
|
|
||||||
// 处理blob/raw路径
|
// 处理blob/raw路径
|
||||||
if matcher == "blob" {
|
if matcher == "blob" {
|
||||||
rawPath = strings.Replace(rawPath, "/blob/", "/raw/", 1)
|
rawPath = rawPath[10:]
|
||||||
|
rawPath = "raw.githubusercontent.com" + rawPath
|
||||||
|
rawPath = strings.Replace(rawPath, "/blob/", "/", 1)
|
||||||
|
matcher = "raw"
|
||||||
}
|
}
|
||||||
|
|
||||||
logDebug("Matched: %v", matcher)
|
logDebug("Matched: %v", matcher)
|
||||||
|
|
|
||||||
|
|
@ -48,9 +48,13 @@ func RoutingHandler(cfg *config.Config, limiter *rate.RateLimiter, iplimiter *ra
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 处理blob/raw路径
|
||||||
// 处理blob/raw路径
|
// 处理blob/raw路径
|
||||||
if matcher == "blob" {
|
if matcher == "blob" {
|
||||||
rawPath = strings.Replace(rawPath, "/blob/", "/raw/", 1)
|
rawPath = rawPath[10:]
|
||||||
|
rawPath = "raw.githubusercontent.com" + rawPath
|
||||||
|
rawPath = strings.Replace(rawPath, "/blob/", "/", 1)
|
||||||
|
matcher = "raw"
|
||||||
}
|
}
|
||||||
|
|
||||||
// 为rawpath加入https:// 头
|
// 为rawpath加入https:// 头
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue