From 4ec36da9b5de3bdad9c999c6871dc26bbde12d1c Mon Sep 17 00:00:00 2001 From: starry <115192496+sky22333@users.noreply.github.com> Date: Fri, 1 Aug 2025 13:19:47 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96github=E4=B8=8A=E6=B8=B8?= =?UTF-8?q?=E9=93=BE=E6=8E=A5404=E7=9A=84=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 3 ++- src/handlers/github.go | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index b9602e3..2177864 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ .idea .vscode .DS_Store -hubproxy* \ No newline at end of file +hubproxy* +!hubproxy.service \ No newline at end of file diff --git a/src/handlers/github.go b/src/handlers/github.go index 2fb6cbb..8cbe79e 100644 --- a/src/handlers/github.go +++ b/src/handlers/github.go @@ -122,6 +122,12 @@ func proxyGitHubWithRedirect(c *gin.Context, u string, redirectCount int) { } }() + // 如果Github上游404,则返回错误信息 + if resp.StatusCode == http.StatusNotFound { + c.String(http.StatusForbidden, "无效的GitHub地址") + return + } + // 检查文件大小限制 cfg := config.GetConfig() if contentLength := resp.Header.Get("Content-Length"); contentLength != "" {