Skip to content

Commit 0135fd2

Browse files
authored
Merge pull request #169 from WJQSERVER-STUDIO/dev
4.3.4
2 parents 93cabc9 + ba33d57 commit 0135fd2

5 files changed

Lines changed: 14 additions & 44 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# 更新日志
22

3+
4.3.4 - 2025-09-14
4+
---
5+
- CHANGE: 改进嵌套加速实现, 增强稳定性
6+
37
4.3.3 - 2025-09-10
48
---
59
- CHANGE: 增强对[wanf](https://github.com/WJQSERVER/wanf)的支持

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
4.3.3
1+
4.3.4

proxy/chunkreq.go

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -127,26 +127,21 @@ func ChunkedProxyRequest(ctx context.Context, c *touka.Context, u string, cfg *c
127127
defer bodyReader.Close()
128128

129129
if MatcherShell(u) && matchString(matcher) && cfg.Shell.Editor {
130-
// 判断body是不是gzip
131-
var compress string
132-
if resp.Header.Get("Content-Encoding") == "gzip" {
133-
compress = "gzip"
134-
}
135130

136131
c.Debugf("Use Shell Editor: %s %s %s %s %s", c.ClientIP(), c.Request.Method, u, c.UserAgent(), c.Request.Proto)
137-
c.Header("Content-Length", "")
132+
c.DelHeader("Content-Length")
133+
c.DelHeader("Content-Encoding")
138134

139135
var reader io.Reader
140136

141-
reader, _, err = processLinks(bodyReader, compress, c.Request.Host, cfg, c)
137+
reader, _, err = processLinks(bodyReader, c.Request.Host, cfg, c)
142138
c.WriteStream(reader)
143139
if err != nil {
144140
c.Errorf("%s %s %s %s %s Failed to copy response body: %v", c.ClientIP(), c.Request.Method, u, c.UserAgent(), c.Request.Proto, err)
145141
ErrorPage(c, NewErrorWithStatusLookup(500, fmt.Sprintf("Failed to copy response body: %v", err)))
146142
return
147143
}
148144
} else {
149-
150145
if contentLength != "" {
151146
c.SetHeader("Content-Length", contentLength)
152147
c.WriteStream(bodyReader)

proxy/nest.go

Lines changed: 4 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package proxy
22

33
import (
44
"bufio"
5-
"compress/gzip"
65
"fmt"
76
"ghproxy/config"
87
"io"
@@ -66,7 +65,7 @@ func modifyURL(url string, host string, cfg *config.Config) string {
6665
}
6766

6867
// processLinks 处理链接,返回包含处理后数据的 io.Reader
69-
func processLinks(input io.ReadCloser, compress string, host string, cfg *config.Config, c *touka.Context) (readerOut io.Reader, written int64, err error) {
68+
func processLinks(input io.ReadCloser, host string, cfg *config.Config, c *touka.Context) (readerOut io.Reader, written int64, err error) {
7069
pipeReader, pipeWriter := io.Pipe() // 创建 io.Pipe
7170
readerOut = pipeReader
7271

@@ -97,43 +96,14 @@ func processLinks(input io.ReadCloser, compress string, host string, cfg *config
9796

9897
var bufReader *bufio.Reader
9998

100-
if compress == "gzip" {
101-
// 解压gzip
102-
gzipReader, gzipErr := gzip.NewReader(input)
103-
if gzipErr != nil {
104-
err = fmt.Errorf("gzip解压错误: %v", gzipErr)
105-
return // Goroutine 中使用 return 返回错误
106-
}
107-
defer gzipReader.Close()
108-
bufReader = bufio.NewReader(gzipReader)
109-
} else {
110-
bufReader = bufio.NewReader(input)
111-
}
99+
bufReader = bufio.NewReader(input)
112100

113101
var bufWriter *bufio.Writer
114-
var gzipWriter *gzip.Writer
115-
116-
// 根据是否gzip确定 writer 的创建
117-
if compress == "gzip" {
118-
gzipWriter = gzip.NewWriter(pipeWriter) // 使用 pipeWriter
119-
bufWriter = bufio.NewWriterSize(gzipWriter, 4096) //设置缓冲区大小
120-
} else {
121-
bufWriter = bufio.NewWriterSize(pipeWriter, 4096) // 使用 pipeWriter
122-
}
102+
103+
bufWriter = bufio.NewWriterSize(pipeWriter, 4096) // 使用 pipeWriter
123104

124105
//确保writer关闭
125106
defer func() {
126-
var closeErr error // 局部变量,用于保存defer中可能发生的错误
127-
128-
if gzipWriter != nil {
129-
if closeErr = gzipWriter.Close(); closeErr != nil {
130-
c.Errorf("gzipWriter close failed %v", closeErr)
131-
// 如果已经存在错误,则保留。否则,记录此错误。
132-
if err == nil {
133-
err = closeErr
134-
}
135-
}
136-
}
137107
if flushErr := bufWriter.Flush(); flushErr != nil {
138108
c.Errorf("writer flush failed %v", flushErr)
139109
// 如果已经存在错误,则保留。否则,记录此错误。

proxy/reqheader.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ var (
2727
"CDN-Loop": {},
2828
"Upgrade": {},
2929
"Connection": {},
30+
"Accept-Encoding": {},
3031
}
3132

3233
cloneHeadersToRemove = map[string]struct{}{
@@ -43,7 +44,7 @@ var (
4344
var (
4445
defaultHeaders = map[string]string{
4546
"Accept": "*/*",
46-
"Accept-Encoding": "gzip",
47+
"Accept-Encoding": "",
4748
"Transfer-Encoding": "chunked",
4849
"User-Agent": "GHProxy/1.0",
4950
}

0 commit comments

Comments
 (0)