From b83c2424160a6a0f03254c6f256f3d03f97e79b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=87=8C=E8=A6=8B=20=E7=81=AF=E8=8A=B1?= <172008506+satomitoka@users.noreply.github.com> Date: Thu, 10 Oct 2024 20:06:08 +0800 Subject: [PATCH 001/401] Update go.mod --- go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go.mod b/go.mod index bbfa29e..93e23f4 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module ghproxy +module github.com/satomitoka/ghproxy go 1.23.2 From 1fd1e3bc2a0bb26111eb6ae3e0ccf4391030efa4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=87=8C=E8=A6=8B=20=E7=81=AF=E8=8A=B1?= <172008506+satomitoka@users.noreply.github.com> Date: Thu, 10 Oct 2024 20:07:44 +0800 Subject: [PATCH 002/401] Update main.go --- main.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/main.go b/main.go index 38bc5c6..074c44c 100644 --- a/main.go +++ b/main.go @@ -6,10 +6,10 @@ import ( "log" "net/http" - "ghproxy/auth" - "ghproxy/config" - "ghproxy/logger" - "ghproxy/proxy" + "github.com/satomitoka/ghproxy/auth" + "github.com/satomitoka/ghproxy/config" + "github.com/satomitoka/ghproxy/logger" + "github.com/satomitoka/ghproxy/proxy" "github.com/gin-gonic/gin" ) From 00538f3d91b310916a7a51251caa9b89f36650d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=87=8C=E8=A6=8B=20=E7=81=AF=E8=8A=B1?= <172008506+satomitoka@users.noreply.github.com> Date: Thu, 10 Oct 2024 20:08:02 +0800 Subject: [PATCH 003/401] Update auth.go --- auth/auth.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/auth/auth.go b/auth/auth.go index 4a8a7b0..f92eab7 100644 --- a/auth/auth.go +++ b/auth/auth.go @@ -1,8 +1,8 @@ package auth import ( - "ghproxy/config" - "ghproxy/logger" + "github.com/satomitoka/ghproxy/config" + "github.com/satomitoka/ghproxy/logger" "github.com/gin-gonic/gin" ) From 4155b9cf4f6c2c71fe3a7a5060e094d9ccd62527 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=87=8C=E8=A6=8B=20=E7=81=AF=E8=8A=B1?= <172008506+satomitoka@users.noreply.github.com> Date: Thu, 10 Oct 2024 20:08:21 +0800 Subject: [PATCH 004/401] Update blacklist.go --- auth/blacklist.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/auth/blacklist.go b/auth/blacklist.go index 830537f..88de8eb 100644 --- a/auth/blacklist.go +++ b/auth/blacklist.go @@ -2,7 +2,7 @@ package auth import ( "encoding/json" - "ghproxy/config" + "github.com/satomitoka/ghproxy/config" "os" ) From f4cb77a72ea6f7fa808212bc229ad67b0fa8217c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=87=8C=E8=A6=8B=20=E7=81=AF=E8=8A=B1?= <172008506+satomitoka@users.noreply.github.com> Date: Thu, 10 Oct 2024 20:08:33 +0800 Subject: [PATCH 005/401] Update whitelist.go --- auth/whitelist.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/auth/whitelist.go b/auth/whitelist.go index 326b3aa..1193bfe 100644 --- a/auth/whitelist.go +++ b/auth/whitelist.go @@ -2,7 +2,7 @@ package auth import ( "encoding/json" - "ghproxy/config" + "github.com/satomitoka/ghproxy/config" "os" ) From dd9a0c8adb25cf03908a4bdd07589689da1a623a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=87=8C=E8=A6=8B=20=E7=81=AF=E8=8A=B1?= <172008506+satomitoka@users.noreply.github.com> Date: Thu, 10 Oct 2024 20:09:16 +0800 Subject: [PATCH 006/401] Update proxy.go --- proxy/proxy.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/proxy/proxy.go b/proxy/proxy.go index d830103..00e7be5 100644 --- a/proxy/proxy.go +++ b/proxy/proxy.go @@ -9,9 +9,9 @@ import ( "strconv" "strings" - "ghproxy/auth" - "ghproxy/config" - "ghproxy/logger" + "github.com/satomitoka/ghproxy/auth" + "github.com/satomitoka/ghproxy/config" + "github.com/satomitoka/ghproxy/logger" "github.com/gin-gonic/gin" "github.com/imroc/req/v3" From 1b5b34d2656eee7a699c14445d5402255e109bb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=87=8C=E8=A6=8B=20=E7=81=AF=E8=8A=B1?= <172008506+satomitoka@users.noreply.github.com> Date: Fri, 11 Oct 2024 00:14:39 +0800 Subject: [PATCH 007/401] Update build-dev.yml --- .github/workflows/build-dev.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/build-dev.yml b/.github/workflows/build-dev.yml index 8f8de42..0dac3d8 100644 --- a/.github/workflows/build-dev.yml +++ b/.github/workflows/build-dev.yml @@ -17,7 +17,6 @@ jobs: goarch: [amd64, arm64] env: OUTPUT_BINARY: ghproxy - #OUTPUT_ARCHIVE: ghproxy.tar.gz GO_VERSION: 1.23.2 steps: @@ -35,7 +34,7 @@ jobs: go-version: ${{ env.GO_VERSION }} - name: Build run: | - CGO_ENABLED=0 go build -o ${{ env.OUTPUT_BINARY }}-${{matrix.goos}}-${{matrix.goarch}} ./main.go + CGO_ENABLED=0 go build -ldflags="-s -w" -o ${{ env.OUTPUT_BINARY }}-${{matrix.goos}}-${{matrix.goarch}} ./main.go - name: Package run: | tar -czvf ${{ env.OUTPUT_BINARY }}-${{matrix.goos}}-${{matrix.goarch}}.tar.gz ./${{ env.OUTPUT_BINARY }}-${{matrix.goos}}-${{matrix.goarch}} From c0af779642274cbd177a2e53162a7c9c0940fdb1 Mon Sep 17 00:00:00 2001 From: WJQSERVER Date: Thu, 24 Oct 2024 01:17:57 +0800 Subject: [PATCH 008/401] 24w19a --- CHANGELOG.md | 7 +++++++ DEV-VERSION | 2 +- config/config.toml | 2 +- deploy/config.toml | 2 +- go.mod | 2 +- go.sum | 2 ++ logger/logger.go | 2 +- main.go | 10 ++++++---- proxy/proxy.go | 28 +++++++++++++++++----------- 9 files changed, 37 insertions(+), 20 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ce6a9dd..aa70dbf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # 更新日志 +24w19a +--- +- PRE-RELEASE: 此版本是v1.6.1的预发布版本,请勿在生产环境中使用 +- CHANGE: 根据社区建议,将`sizeLimit`由过去的以`byte`为单位,改为以`MB`为单位,以便于直观理解 +- CHANGE: 更新相关依赖 +- CHANGE: 对`Proxy`模块的核心函数进行模块化,为后续修改和扩展提供空间 + v1.6.0 --- - CHANGE: 优化代码结构,提升性能 diff --git a/DEV-VERSION b/DEV-VERSION index 430b82d..2e85c10 100644 --- a/DEV-VERSION +++ b/DEV-VERSION @@ -1 +1 @@ -24w18f \ No newline at end of file +24w19a \ No newline at end of file diff --git a/config/config.toml b/config/config.toml index ea5c9cf..7dc645b 100644 --- a/config/config.toml +++ b/config/config.toml @@ -1,7 +1,7 @@ [server] host = "127.0.0.1" port = 8080 -sizeLimit = 131072000 # 125MB +sizeLimit = 125 # MB [pages] enabled = false diff --git a/deploy/config.toml b/deploy/config.toml index 4ffbd54..65b2fca 100644 --- a/deploy/config.toml +++ b/deploy/config.toml @@ -1,7 +1,7 @@ [server] host = "127.0.0.1" port = 8080 -sizeLimit = 131072000 # 125MB +sizeLimit = 125 # MB [pages] enabled = true diff --git a/go.mod b/go.mod index 1e85761..a69e010 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,7 @@ require ( require ( github.com/andybalholm/brotli v1.1.1 // indirect github.com/bytedance/sonic v1.12.3 // indirect - github.com/bytedance/sonic/loader v0.2.0 // indirect + github.com/bytedance/sonic/loader v0.2.1 // indirect github.com/cloudflare/circl v1.5.0 // indirect github.com/cloudwego/base64x v0.1.4 // indirect github.com/cloudwego/iasm v0.2.0 // indirect diff --git a/go.sum b/go.sum index 27c3095..38f6b03 100644 --- a/go.sum +++ b/go.sum @@ -7,6 +7,8 @@ github.com/bytedance/sonic v1.12.3/go.mod h1:B8Gt/XvtZ3Fqj+iSKMypzymZxw/FVwgIGKz github.com/bytedance/sonic/loader v0.1.1/go.mod h1:ncP89zfokxS5LZrJxl5z0UJcsk4M4yY2JpfqGeCtNLU= github.com/bytedance/sonic/loader v0.2.0 h1:zNprn+lsIP06C/IqCHs3gPQIvnvpKbbxyXQP1iU4kWM= github.com/bytedance/sonic/loader v0.2.0/go.mod h1:ncP89zfokxS5LZrJxl5z0UJcsk4M4yY2JpfqGeCtNLU= +github.com/bytedance/sonic/loader v0.2.1 h1:1GgorWTqf12TA8mma4DDSbaQigE2wOgQo7iCjjJv3+E= +github.com/bytedance/sonic/loader v0.2.1/go.mod h1:ncP89zfokxS5LZrJxl5z0UJcsk4M4yY2JpfqGeCtNLU= github.com/cloudflare/circl v1.5.0 h1:hxIWksrX6XN5a1L2TI/h53AGPhNHoUBo+TD1ms9+pys= github.com/cloudflare/circl v1.5.0/go.mod h1:uddAzsPgqdMAYatqJ0lsjX1oECcQLIlRpzZh3pJrofs= github.com/cloudwego/base64x v0.1.4 h1:jwCgWpFanWmN8xoIUHa2rtzmkd5J2plF/dnLS6Xd/0Y= diff --git a/logger/logger.go b/logger/logger.go index e5e5b75..81aa5a3 100644 --- a/logger/logger.go +++ b/logger/logger.go @@ -96,7 +96,7 @@ func Close() { } func monitorLogSize(logFilePath string, maxLogsize int) { - var maxLogsizeBytes int64 = int64(maxLogsize) * 1024 * 1024 // 最大日志文件大小,单位为MB + var maxLogsizeBytes int64 = int64(maxLogsize) * 1024 * 1024 for { time.Sleep(120 * time.Minute) // 每120分钟检查一次日志文件大小 logFileMutex.Lock() diff --git a/main.go b/main.go index 47f63c1..20e081d 100644 --- a/main.go +++ b/main.go @@ -5,6 +5,7 @@ import ( "fmt" "log" "net/http" + "time" "ghproxy/api" "ghproxy/auth" @@ -12,6 +13,7 @@ import ( "ghproxy/logger" "ghproxy/proxy" + "github.com/gin-contrib/ratelimit" "github.com/gin-gonic/gin" ) @@ -76,19 +78,20 @@ func init() { router = gin.Default() router.UseH2C = true + router.Use(ratelimit.New( + ratelimit.WithTotolLimit(10), + ratelimit.WithDuration(1*time.Minute), + )) setupApi(cfg, router) if cfg.Pages.Enabled { indexPagePath := fmt.Sprintf("%s/index.html", cfg.Pages.StaticDir) faviconPath := fmt.Sprintf("%s/favicon.ico", cfg.Pages.StaticDir) - // 静态index页 - //router.StaticFile("/", indexPagePath) router.GET("/", func(c *gin.Context) { c.File(indexPagePath) logInfo("IP:%s UA:%s METHOD:%s HTTPv:%s", c.ClientIP(), c.Request.UserAgent(), c.Request.Method, c.Request.Proto) }) - // 静态favicon.ico router.StaticFile("/favicon.ico", faviconPath) } else if !cfg.Pages.Enabled { router.GET("/", func(c *gin.Context) { @@ -97,7 +100,6 @@ func init() { }) } - // 未匹配路由处理 router.NoRoute(func(c *gin.Context) { proxy.NoRouteHandler(cfg)(c) }) diff --git a/proxy/proxy.go b/proxy/proxy.go index 4479af3..3f467c0 100644 --- a/proxy/proxy.go +++ b/proxy/proxy.go @@ -47,17 +47,8 @@ func NoRouteHandler(cfg *config.Config) gin.HandlerFunc { rawPath = "https://" + matches[2] - // 提取用户名和仓库名,格式为 handle///* - pathmatches := regexp.MustCompile(`^([^/]+)/([^/]+)/([^/]+)/.*`) - pathParts := pathmatches.FindStringSubmatch(matches[2]) - if len(pathParts) < 4 { - logWarning("Invalid path: %s", rawPath) - c.String(http.StatusForbidden, "Invalid path; expected username/repo.") - return - } + username, repo := MatchUserRepo(rawPath, cfg, c, matches) - username := pathParts[2] - repo := pathParts[3] logWarning("Blacklist Check > Username: %s, Repo: %s", username, repo) fullrepo := fmt.Sprintf("%s/%s", username, repo) @@ -115,6 +106,20 @@ func NoRouteHandler(cfg *config.Config) gin.HandlerFunc { } } +func MatchUserRepo(rawPath string, cfg *config.Config, c *gin.Context, matches []string) (string, string) { + // 提取用户名和仓库名,格式为 handle///* + pathmatches := regexp.MustCompile(`^([^/]+)/([^/]+)/([^/]+)/.*`) + pathParts := pathmatches.FindStringSubmatch(matches[2]) + + if len(pathParts) < 4 { + logWarning("Invalid path: %s", rawPath) + c.String(http.StatusForbidden, "Invalid path; expected username/repo.") + return "", "" + } else { + return pathParts[2], pathParts[3] + } +} + func ProxyRequest(c *gin.Context, u string, cfg *config.Config, mode string) { method := c.Request.Method // 记录日志 IP 地址、请求方法、请求 URL、请求头 User-Agent 、HTTP版本 @@ -206,9 +211,10 @@ func SendRequest(req *req.Request, method, url string) (*req.Response, error) { func HandleResponseSize(resp *req.Response, cfg *config.Config, c *gin.Context) error { contentLength := resp.Header.Get("Content-Length") + sizelimit := cfg.Server.SizeLimit * 1024 * 1024 if contentLength != "" { size, err := strconv.Atoi(contentLength) - if err == nil && size > cfg.Server.SizeLimit { + if err == nil && size > sizelimit { finalURL := resp.Request.URL.String() c.Redirect(http.StatusMovedPermanently, finalURL) logWarning("Size limit exceeded: %s, Size: %d", finalURL, size) From a8af0fb687337c22326d52efbacca60bc848c483 Mon Sep 17 00:00:00 2001 From: WJQSERVER Date: Thu, 24 Oct 2024 01:23:01 +0800 Subject: [PATCH 009/401] 24w19a --- main.go | 6 ------ 1 file changed, 6 deletions(-) diff --git a/main.go b/main.go index 20e081d..3363c6b 100644 --- a/main.go +++ b/main.go @@ -5,7 +5,6 @@ import ( "fmt" "log" "net/http" - "time" "ghproxy/api" "ghproxy/auth" @@ -13,7 +12,6 @@ import ( "ghproxy/logger" "ghproxy/proxy" - "github.com/gin-contrib/ratelimit" "github.com/gin-gonic/gin" ) @@ -78,10 +76,6 @@ func init() { router = gin.Default() router.UseH2C = true - router.Use(ratelimit.New( - ratelimit.WithTotolLimit(10), - ratelimit.WithDuration(1*time.Minute), - )) setupApi(cfg, router) From 3489e6d744ffae66d70f8579ae5af5587068e593 Mon Sep 17 00:00:00 2001 From: WJQSERVER Date: Thu, 24 Oct 2024 01:46:03 +0800 Subject: [PATCH 010/401] 24w19b --- CHANGELOG.md | 6 ++++++ DEV-VERSION | 2 +- api/api.go | 2 +- proxy/proxy.go | 9 ++++++++- 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index aa70dbf..edcb8ad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # 更新日志 +24w19b +--- +- PRE-RELEASE: 此版本是v1.6.1的预发布版本,请勿在生产环境中使用 +- FIX: 修复`sizeLimit`单位更改导致API返回值错误的问题 +- FIX: 尝试修正Gist匹配 + 24w19a --- - PRE-RELEASE: 此版本是v1.6.1的预发布版本,请勿在生产环境中使用 diff --git a/DEV-VERSION b/DEV-VERSION index 2e85c10..247e25b 100644 --- a/DEV-VERSION +++ b/DEV-VERSION @@ -1 +1 @@ -24w19a \ No newline at end of file +24w19b \ No newline at end of file diff --git a/api/api.go b/api/api.go index 7dd56a0..3214d92 100644 --- a/api/api.go +++ b/api/api.go @@ -45,7 +45,7 @@ func InitHandleRouter(cfg *config.Config, router *gin.Engine) { } func SizeLimitHandler(cfg *config.Config, c *gin.Context) { - sizeLimit := cfg.Server.SizeLimit / 1024 / 1024 + sizeLimit := cfg.Server.SizeLimit c.Writer.Header().Set("Content-Type", "application/json") json.NewEncoder(c.Writer).Encode(map[string]interface{}{ "MaxResponseBodySize": sizeLimit, diff --git a/proxy/proxy.go b/proxy/proxy.go index 3f467c0..958f501 100644 --- a/proxy/proxy.go +++ b/proxy/proxy.go @@ -106,8 +106,15 @@ func NoRouteHandler(cfg *config.Config) gin.HandlerFunc { } } +// 提取用户名和仓库名,格式为 handle///* func MatchUserRepo(rawPath string, cfg *config.Config, c *gin.Context, matches []string) (string, string) { - // 提取用户名和仓库名,格式为 handle///* + var gistregex = regexp.MustCompile(`^(?:https?://)?gist\.github\.com/([^/]+)/([^/]+)/.*`) + var gistmatches []string + if gistregex.MatchString(rawPath) { + gistmatches = gistregex.FindStringSubmatch(rawPath) + logInfo("Gist Matched > Username: %s, URL: %s", gistmatches[2], rawPath) + return gistmatches[2], "" + } pathmatches := regexp.MustCompile(`^([^/]+)/([^/]+)/([^/]+)/.*`) pathParts := pathmatches.FindStringSubmatch(matches[2]) From 0c1eb34e49bf87c92b4ad7220ed9ffb1d5173d1a Mon Sep 17 00:00:00 2001 From: WJQSERVER Date: Thu, 24 Oct 2024 01:59:45 +0800 Subject: [PATCH 011/401] 24w19b --- proxy/proxy.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/proxy/proxy.go b/proxy/proxy.go index 958f501..12b157c 100644 --- a/proxy/proxy.go +++ b/proxy/proxy.go @@ -30,7 +30,7 @@ var exps = []*regexp.Regexp{ regexp.MustCompile(`^(?:https?://)?github\.com/([^/]+)/([^/]+)/(?:blob|raw)/.*`), regexp.MustCompile(`^(?:https?://)?github\.com/([^/]+)/([^/]+)/(?:info|git-).*`), regexp.MustCompile(`^(?:https?://)?raw\.github(?:usercontent|)\.com/([^/]+)/([^/]+)/.+?/.+`), - regexp.MustCompile(`^(?:https?://)?gist\.github\.com/([^/]+)/.+?/.+`), + regexp.MustCompile(`^(?:https?://)?gist\.github(?:usercontent|)\.com/([^/]+)/.+?/.+`), } func NoRouteHandler(cfg *config.Config) gin.HandlerFunc { @@ -108,12 +108,12 @@ func NoRouteHandler(cfg *config.Config) gin.HandlerFunc { // 提取用户名和仓库名,格式为 handle///* func MatchUserRepo(rawPath string, cfg *config.Config, c *gin.Context, matches []string) (string, string) { - var gistregex = regexp.MustCompile(`^(?:https?://)?gist\.github\.com/([^/]+)/([^/]+)/.*`) + var gistregex = regexp.MustCompile(`^(?:https?://)?gist\.github(?:usercontent|)\.com/([^/]+)/([^/]+)/.*`) var gistmatches []string if gistregex.MatchString(rawPath) { gistmatches = gistregex.FindStringSubmatch(rawPath) - logInfo("Gist Matched > Username: %s, URL: %s", gistmatches[2], rawPath) - return gistmatches[2], "" + logInfo("Gist Matched > Username: %s, URL: %s", gistmatches[1], rawPath) + return gistmatches[1], "" } pathmatches := regexp.MustCompile(`^([^/]+)/([^/]+)/([^/]+)/.*`) pathParts := pathmatches.FindStringSubmatch(matches[2]) From 052827bca7c405c90cc350865af1ab3a0ab74ecb Mon Sep 17 00:00:00 2001 From: WJQSERVER <114663932+WJQSERVER@users.noreply.github.com> Date: Thu, 24 Oct 2024 02:15:10 +0800 Subject: [PATCH 012/401] Update issue templates --- .github/ISSUE_TEMPLATE/bug_report.md | 40 ++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/bug_report.md diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 0000000..87fe7c0 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,40 @@ +--- +name: Bug report +about: 报告问题与漏洞 +title: "[BUG]" +labels: bug +assignees: '' + +--- + +### 问题描述 + +请简要描述发现的问题是什么,以及如何重现。 + +### 复现步骤 + +1. 打开... +2. 点击... +3. 观察到... + +### 预期行为 + +请描述在正常情况下应该发生什么。 + +### 实际行为 + +请描述实际发生了什么。 + +### 截图 + +如果适用,请添加截图以帮助解释您的问题。 + +### 环境信息 + +- 发行版: [例如 Debian12, Alpine-Edge ] +- 部署方式: [可执行文件/Docker ] +- GHProxy版本: [例如 1.0.0] + +### 附加信息 + +请提供任何其他可能有助于我们解决问题的信息。 From b633bec69b2dca57ff237d1931dedfca06d3acf3 Mon Sep 17 00:00:00 2001 From: WJQSERVER Date: Thu, 24 Oct 2024 14:44:38 +0800 Subject: [PATCH 013/401] 24w19c --- CHANGELOG.md | 9 ++++++++- DEV-VERSION | 2 +- go.mod | 4 ++-- go.sum | 4 ++++ pages/index.html | 10 +++++++--- 5 files changed, 22 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index edcb8ad..d3e2e96 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,10 +1,17 @@ # 更新日志 +24w19c +--- +- PRE-RELEASE: 此版本是v1.6.1的预发布版本,请勿在生产环境中使用 +- FIX & ADD: 修复前端对gist的匹配问题,添加对`gist.githubusercontent.com`的前端转换支持 +- CHANGE: 改变部分前端匹配逻辑 +- CHANGE: 更新相关依赖库 + 24w19b --- - PRE-RELEASE: 此版本是v1.6.1的预发布版本,请勿在生产环境中使用 - FIX: 修复`sizeLimit`单位更改导致API返回值错误的问题 -- FIX: 尝试修正Gist匹配 +- FIX: 修正Gist匹配 24w19a --- diff --git a/DEV-VERSION b/DEV-VERSION index 247e25b..f90e6c0 100644 --- a/DEV-VERSION +++ b/DEV-VERSION @@ -1 +1 @@ -24w19b \ No newline at end of file +24w19c \ No newline at end of file diff --git a/go.mod b/go.mod index a69e010..57c4eaa 100644 --- a/go.mod +++ b/go.mod @@ -22,7 +22,7 @@ require ( github.com/go-playground/validator/v10 v10.22.1 // indirect github.com/go-task/slim-sprig/v3 v3.0.0 // indirect github.com/goccy/go-json v0.10.3 // indirect - github.com/google/pprof v0.0.0-20241017200806-017d972448fc // indirect + github.com/google/pprof v0.0.0-20241023014458-598669927662 // indirect github.com/hashicorp/errwrap v1.1.0 // indirect github.com/hashicorp/go-multierror v1.1.1 // indirect github.com/json-iterator/go v1.1.12 // indirect @@ -35,7 +35,7 @@ require ( github.com/onsi/ginkgo/v2 v2.20.2 // indirect github.com/pelletier/go-toml/v2 v2.2.3 // indirect github.com/quic-go/qpack v0.5.1 // indirect - github.com/quic-go/quic-go v0.48.0 // indirect + github.com/quic-go/quic-go v0.48.1 // indirect github.com/refraction-networking/utls v1.6.7 // indirect github.com/twitchyliquid64/golang-asm v0.15.1 // indirect github.com/ugorji/go/codec v1.2.12 // indirect diff --git a/go.sum b/go.sum index 38f6b03..adb96fd 100644 --- a/go.sum +++ b/go.sum @@ -48,6 +48,8 @@ github.com/google/pprof v0.0.0-20241009165004-a3522334989c h1:NDovD0SMpBYXlE1zJm github.com/google/pprof v0.0.0-20241009165004-a3522334989c/go.mod h1:vavhavw2zAxS5dIdcRluK6cSGGPlZynqzFM8NdvU144= github.com/google/pprof v0.0.0-20241017200806-017d972448fc h1:NGyrhhFhwvRAZg02jnYVg3GBQy0qGBKmFQJwaPmpmxs= github.com/google/pprof v0.0.0-20241017200806-017d972448fc/go.mod h1:vavhavw2zAxS5dIdcRluK6cSGGPlZynqzFM8NdvU144= +github.com/google/pprof v0.0.0-20241023014458-598669927662 h1:SKMkD83p7FwUqKmBsPdLHF5dNyxq3jOWwu9w9UyH5vA= +github.com/google/pprof v0.0.0-20241023014458-598669927662/go.mod h1:vavhavw2zAxS5dIdcRluK6cSGGPlZynqzFM8NdvU144= github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY2I= github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= @@ -86,6 +88,8 @@ github.com/quic-go/quic-go v0.47.0 h1:yXs3v7r2bm1wmPTYNLKAAJTHMYkPEsfYJmTazXrCZ7 github.com/quic-go/quic-go v0.47.0/go.mod h1:3bCapYsJvXGZcipOHuu7plYtaV6tnF+z7wIFsU0WK9E= github.com/quic-go/quic-go v0.48.0 h1:2TCyvBrMu1Z25rvIAlnp2dPT4lgh/uTqLqiXVpp5AeU= github.com/quic-go/quic-go v0.48.0/go.mod h1:yBgs3rWBOADpga7F+jJsb6Ybg1LSYiQvwWlLX+/6HMs= +github.com/quic-go/quic-go v0.48.1 h1:y/8xmfWI9qmGTc+lBr4jKRUWLGSlSigv847ULJ4hYXA= +github.com/quic-go/quic-go v0.48.1/go.mod h1:yBgs3rWBOADpga7F+jJsb6Ybg1LSYiQvwWlLX+/6HMs= github.com/refraction-networking/utls v1.6.7 h1:zVJ7sP1dJx/WtVuITug3qYUq034cDq9B2MR1K67ULZM= github.com/refraction-networking/utls v1.6.7/go.mod h1:BC3O4vQzye5hqpmDTWUqi4P5DDhzJfkV1tdqtawQIH0= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= diff --git a/pages/index.html b/pages/index.html index 3b69dd3..f6a7ad5 100644 --- a/pages/index.html +++ b/pages/index.html @@ -187,8 +187,11 @@ formattedLink = "https://" + currentHost + githubLinkInput.value.substring(githubLinkInput.value.indexOf("/", 7)); } else if (githubLinkInput.value.startsWith("raw.githubusercontent.com/")) { formattedLink = "https://" + currentHost + "/" + githubLinkInput.value; - } else if (!githubLinkInput.value.trim()) { - //alert('请输入有效的GitHub链接'); + } else if (githubLinkInput.value.startsWith("https://gist.githubusercontent.com/") || githubLinkInput.value.startsWith("http://gist.githubusercontent.com/")) { + formattedLink = "https://" + currentHost + "/gist.github.com" + githubLinkInput.value.substring(githubLinkInput.value.indexOf("/", 18)); + } else if (githubLinkInput.value.startsWith("gist.githubusercontent.com/")) { + formattedLink = "https://" + currentHost + "/" + githubLinkInput.value; + } else { showToast('请输入有效的GitHub链接'); } var formattedLinkOutput = document.getElementById('formattedLinkOutput'); @@ -276,7 +279,8 @@