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 != "" {