mirror of
https://github.com/WJQSERVER-STUDIO/ghproxy.git
synced 2026-02-03 00:01:10 +08:00
25w28b
This commit is contained in:
parent
ab77c5c7da
commit
bed6c486dc
6 changed files with 16 additions and 3 deletions
|
|
@ -1,5 +1,11 @@
|
||||||
# 更新日志
|
# 更新日志
|
||||||
|
|
||||||
|
25w28b - 2025-04-15
|
||||||
|
---
|
||||||
|
- PRE-RELEASE: 此版本是v3.0.2预发布版本,请勿在生产环境中使用;
|
||||||
|
- CHANGE: 改进resp关闭
|
||||||
|
- CHANGE: 避免重复的re编译操作
|
||||||
|
|
||||||
25w28a - 2025-04-14
|
25w28a - 2025-04-14
|
||||||
---
|
---
|
||||||
- PRE-RELEASE: 此版本是预发布版本,请勿在生产环境中使用;
|
- PRE-RELEASE: 此版本是预发布版本,请勿在生产环境中使用;
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
25w28a
|
25w28b
|
||||||
1
main.go
1
main.go
|
|
@ -241,7 +241,6 @@ func setupPages(cfg *config.Config, r *server.Hertz) {
|
||||||
r.StaticFile("/style.css", stylesheetsPath)
|
r.StaticFile("/style.css", stylesheetsPath)
|
||||||
r.StaticFile("/bootstrap.min.css", bootstrapPath)
|
r.StaticFile("/bootstrap.min.css", bootstrapPath)
|
||||||
r.StaticFile("/bootstrap.bundle.min.js", bootstrapBundlePath)
|
r.StaticFile("/bootstrap.bundle.min.js", bootstrapBundlePath)
|
||||||
//router.StaticFile("/bootstrap.min.css", bootstrapPath)
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
// 处理无效的Pages Mode
|
// 处理无效的Pages Mode
|
||||||
|
|
|
||||||
|
|
@ -56,6 +56,10 @@ func ChunkedProxyRequest(ctx context.Context, c *app.RequestContext, u string, c
|
||||||
}
|
}
|
||||||
if err == nil && bodySize > sizelimit {
|
if err == nil && bodySize > sizelimit {
|
||||||
finalURL := resp.Request.URL.String()
|
finalURL := resp.Request.URL.String()
|
||||||
|
err := resp.Body.Close()
|
||||||
|
if err != nil {
|
||||||
|
logError("Failed to close response body: %v", err)
|
||||||
|
}
|
||||||
c.Redirect(http.StatusMovedPermanently, []byte(finalURL))
|
c.Redirect(http.StatusMovedPermanently, []byte(finalURL))
|
||||||
logWarning("%s %s %s %s %s Final-URL: %s Size-Limit-Exceeded: %d", c.ClientIP(), c.Method(), c.Path(), c.UserAgent(), c.Request.Header.GetProtocol(), finalURL, bodySize)
|
logWarning("%s %s %s %s %s Final-URL: %s Size-Limit-Exceeded: %d", c.ClientIP(), c.Method(), c.Path(), c.UserAgent(), c.Request.Header.GetProtocol(), finalURL, bodySize)
|
||||||
return
|
return
|
||||||
|
|
|
||||||
|
|
@ -243,6 +243,8 @@ func extractParts(rawURL string) (string, string, string, url.Values, error) {
|
||||||
return repoOwner, repoName, remainingPath, queryParams, nil
|
return repoOwner, repoName, remainingPath, queryParams, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var urlPattern = regexp.MustCompile(`https?://[^\s'"]+`)
|
||||||
|
|
||||||
// processLinks 处理链接,返回包含处理后数据的 io.Reader
|
// processLinks 处理链接,返回包含处理后数据的 io.Reader
|
||||||
func processLinks(input io.Reader, compress string, host string, cfg *config.Config) (readerOut io.Reader, written int64, err error) {
|
func processLinks(input io.Reader, compress string, host string, cfg *config.Config) (readerOut io.Reader, written int64, err error) {
|
||||||
pipeReader, pipeWriter := io.Pipe() // 创建 io.Pipe
|
pipeReader, pipeWriter := io.Pipe() // 创建 io.Pipe
|
||||||
|
|
@ -315,7 +317,6 @@ func processLinks(input io.Reader, compress string, host string, cfg *config.Con
|
||||||
}()
|
}()
|
||||||
|
|
||||||
// 使用正则表达式匹配 http 和 https 链接
|
// 使用正则表达式匹配 http 和 https 链接
|
||||||
urlPattern := regexp.MustCompile(`https?://[^\s'"]+`)
|
|
||||||
for {
|
for {
|
||||||
line, readErr := bufReader.ReadString('\n')
|
line, readErr := bufReader.ReadString('\n')
|
||||||
if readErr != nil {
|
if readErr != nil {
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,9 @@ func setRequestHeaders(c *app.RequestContext, req *http.Request) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// removeWSHeader removes the "Upgrade" and "Connection" headers from the given
|
||||||
|
// Request, which are added by the client when it wants to upgrade the
|
||||||
|
// connection to a WebSocket connection.
|
||||||
func removeWSHeader(req *http.Request) {
|
func removeWSHeader(req *http.Request) {
|
||||||
req.Header.Del("Upgrade")
|
req.Header.Del("Upgrade")
|
||||||
req.Header.Del("Connection")
|
req.Header.Del("Connection")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue