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/398] 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/398] 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/398] 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/398] 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/398] 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/398] 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/398] 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 0c1eb34e49bf87c92b4ad7220ed9ffb1d5173d1a Mon Sep 17 00:00:00 2001 From: WJQSERVER Date: Thu, 24 Oct 2024 01:59:45 +0800 Subject: [PATCH 008/398] 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 009/398] 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 010/398] 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 @@