From 5258046faae30499822a0867bc4b8885163aae0a Mon Sep 17 00:00:00 2001 From: WJQSERVER Date: Sun, 12 Jan 2025 17:07:34 +0800 Subject: [PATCH] 25w03a --- CHANGELOG.md | 6 ++++++ DEV-VERSION | 2 +- main.go | 5 ++++- proxy/proxy.go | 2 +- 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6309fb1..ff997b2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # 更新日志 +25w03a +--- +- PRE-RELEASE: 此版本是v1.8.2的候选预发布版本,请勿在生产环境中使用 +- FIX: 修复部分日志表述错误 +- CHANGE: 关闭`gin`框架的`fmt`日志打印, 在高并发场景下提升一定性能(go 打印终端日志性能较差,可能造成性能瓶颈) + 1.8.1 --- - RELEASE: v1.8.1正式版发布; 此版本发布较为仓促, 用于修复caddy2.9.0导致的问题 diff --git a/DEV-VERSION b/DEV-VERSION index 0f82b5e..bc0d284 100644 --- a/DEV-VERSION +++ b/DEV-VERSION @@ -1 +1 @@ -25w02a \ No newline at end of file +25w03a \ No newline at end of file diff --git a/main.go b/main.go index 4a9abf2..ddeac03 100644 --- a/main.go +++ b/main.go @@ -4,6 +4,7 @@ import ( "embed" "flag" "fmt" + "io" "io/fs" "log" "net/http" @@ -110,7 +111,9 @@ func init() { runMode = "release" } - router = gin.Default() + gin.LoggerWithWriter(io.Discard) + router := gin.New() + router.Use(gin.Recovery()) //H2C默认值为true,而后遵循cfg.Server.EnableH2C的设置 if cfg.Server.EnableH2C == "on" { router.UseH2C = true diff --git a/proxy/proxy.go b/proxy/proxy.go index 8b1a230..2500d7e 100644 --- a/proxy/proxy.go +++ b/proxy/proxy.go @@ -92,7 +92,7 @@ func NoRouteHandler(cfg *config.Config, limiter *rate.RateLimiter, iplimiter *ra if cfg.Blacklist.Enabled { blacklist := auth.CheckBlacklist(repouser, username, repo) if blacklist { - logErrMsg := fmt.Sprintf("%s %s %s %s %s Whitelist Blocked repo: %s", c.ClientIP(), c.Request.Method, rawPath, c.Request.Header.Get("User-Agent"), c.Request.Proto, repouser) + logErrMsg := fmt.Sprintf("%s %s %s %s %s Blacklist Blocked repo: %s", c.ClientIP(), c.Request.Method, rawPath, c.Request.Header.Get("User-Agent"), c.Request.Proto, repouser) errMsg := fmt.Sprintf("Blacklist Blocked repo: %s", repouser) c.JSON(http.StatusForbidden, gin.H{"error": errMsg}) logWarning(logErrMsg)