Compare commits

..

4 commits
4.3.3 ... main

Author SHA1 Message Date
wjqserver
32baca85db remove 2025-10-12 15:46:36 +08:00
WJQSERVER
0135fd2ce0
Merge pull request #169 from WJQSERVER-STUDIO/dev
Some checks failed
Build / prepare (push) Has been cancelled
Build / build (amd64, darwin) (push) Has been cancelled
Build / build (amd64, freebsd) (push) Has been cancelled
Build / build (amd64, linux) (push) Has been cancelled
Build / build (arm64, darwin) (push) Has been cancelled
Build / build (arm64, freebsd) (push) Has been cancelled
Build / build (arm64, linux) (push) Has been cancelled
Build / docker (push) Has been cancelled
4.3.4
2025-09-14 07:44:58 +08:00
wjqserver
ba33d5743f 4.3.4 2025-09-14 07:44:46 +08:00
wjqserver
bd9f590b0a 4.3.4 2025-09-14 07:31:41 +08:00
6 changed files with 13 additions and 45 deletions

View file

@ -1,5 +1,9 @@
# 更新日志
4.3.4 - 2025-09-14
---
- CHANGE: 改进嵌套加速实现, 增强稳定性
4.3.3 - 2025-09-10
---
- CHANGE: 增强对[wanf](https://github.com/WJQSERVER/wanf)的支持

View file

@ -36,8 +36,6 @@
[相关文章](https://blog.wjqserver.com/categories/my-program/)
代理相关推广: [Thordata](https://www.thordata.com/?ls=github&lk=WJQserver)市面上最具性价比的代理服务商便宜好用来自全球195个国家城市的6000万IP轮换住宅/原生ISP/无限量仅从$0.65/GB 起,新用户$1=5GB .联系客户可获得免费测试.
### 使用示例
```bash

View file

@ -1 +1 @@
4.3.3
4.3.4

View file

@ -127,18 +127,14 @@ func ChunkedProxyRequest(ctx context.Context, c *touka.Context, u string, cfg *c
defer bodyReader.Close()
if MatcherShell(u) && matchString(matcher) && cfg.Shell.Editor {
// 判断body是不是gzip
var compress string
if resp.Header.Get("Content-Encoding") == "gzip" {
compress = "gzip"
}
c.Debugf("Use Shell Editor: %s %s %s %s %s", c.ClientIP(), c.Request.Method, u, c.UserAgent(), c.Request.Proto)
c.Header("Content-Length", "")
c.DelHeader("Content-Length")
c.DelHeader("Content-Encoding")
var reader io.Reader
reader, _, err = processLinks(bodyReader, compress, c.Request.Host, cfg, c)
reader, _, err = processLinks(bodyReader, c.Request.Host, cfg, c)
c.WriteStream(reader)
if err != nil {
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)
@ -146,7 +142,6 @@ func ChunkedProxyRequest(ctx context.Context, c *touka.Context, u string, cfg *c
return
}
} else {
if contentLength != "" {
c.SetHeader("Content-Length", contentLength)
c.WriteStream(bodyReader)

View file

@ -2,7 +2,6 @@ package proxy
import (
"bufio"
"compress/gzip"
"fmt"
"ghproxy/config"
"io"
@ -66,7 +65,7 @@ func modifyURL(url string, host string, cfg *config.Config) string {
}
// processLinks 处理链接,返回包含处理后数据的 io.Reader
func processLinks(input io.ReadCloser, compress string, host string, cfg *config.Config, c *touka.Context) (readerOut io.Reader, written int64, err error) {
func processLinks(input io.ReadCloser, host string, cfg *config.Config, c *touka.Context) (readerOut io.Reader, written int64, err error) {
pipeReader, pipeWriter := io.Pipe() // 创建 io.Pipe
readerOut = pipeReader
@ -97,43 +96,14 @@ func processLinks(input io.ReadCloser, compress string, host string, cfg *config
var bufReader *bufio.Reader
if compress == "gzip" {
// 解压gzip
gzipReader, gzipErr := gzip.NewReader(input)
if gzipErr != nil {
err = fmt.Errorf("gzip解压错误: %v", gzipErr)
return // Goroutine 中使用 return 返回错误
}
defer gzipReader.Close()
bufReader = bufio.NewReader(gzipReader)
} else {
bufReader = bufio.NewReader(input)
}
bufReader = bufio.NewReader(input)
var bufWriter *bufio.Writer
var gzipWriter *gzip.Writer
// 根据是否gzip确定 writer 的创建
if compress == "gzip" {
gzipWriter = gzip.NewWriter(pipeWriter) // 使用 pipeWriter
bufWriter = bufio.NewWriterSize(gzipWriter, 4096) //设置缓冲区大小
} else {
bufWriter = bufio.NewWriterSize(pipeWriter, 4096) // 使用 pipeWriter
}
bufWriter = bufio.NewWriterSize(pipeWriter, 4096) // 使用 pipeWriter
//确保writer关闭
defer func() {
var closeErr error // 局部变量用于保存defer中可能发生的错误
if gzipWriter != nil {
if closeErr = gzipWriter.Close(); closeErr != nil {
c.Errorf("gzipWriter close failed %v", closeErr)
// 如果已经存在错误,则保留。否则,记录此错误。
if err == nil {
err = closeErr
}
}
}
if flushErr := bufWriter.Flush(); flushErr != nil {
c.Errorf("writer flush failed %v", flushErr)
// 如果已经存在错误,则保留。否则,记录此错误。

View file

@ -27,6 +27,7 @@ var (
"CDN-Loop": {},
"Upgrade": {},
"Connection": {},
"Accept-Encoding": {},
}
cloneHeadersToRemove = map[string]struct{}{
@ -43,7 +44,7 @@ var (
var (
defaultHeaders = map[string]string{
"Accept": "*/*",
"Accept-Encoding": "gzip",
"Accept-Encoding": "",
"Transfer-Encoding": "chunked",
"User-Agent": "GHProxy/1.0",
}