From 45b4acc31f56fa20bfc8f4c882390945115f4d6b Mon Sep 17 00:00:00 2001 From: starry <115192496+sky22333@users.noreply.github.com> Date: Tue, 2 Sep 2025 01:03:50 +0800 Subject: [PATCH 01/15] =?UTF-8?q?=E8=B0=83=E6=95=B4=E4=B8=80=E4=BA=9B?= =?UTF-8?q?=E9=BB=98=E8=AE=A4=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/config/config.go | 4 ++-- src/utils/ratelimiter.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/config/config.go b/src/config/config.go index 700b4c9..ceaf9de 100644 --- a/src/config/config.go +++ b/src/config/config.go @@ -84,8 +84,8 @@ func DefaultConfig() *AppConfig { RequestLimit int `toml:"requestLimit"` PeriodHours float64 `toml:"periodHours"` }{ - RequestLimit: 200, - PeriodHours: 1.0, + RequestLimit: 500, + PeriodHours: 3.0, }, Security: struct { WhiteList []string `toml:"whiteList"` diff --git a/src/utils/ratelimiter.go b/src/utils/ratelimiter.go index b0d960f..0658ff6 100644 --- a/src/utils/ratelimiter.go +++ b/src/utils/ratelimiter.go @@ -13,7 +13,7 @@ import ( ) const ( - CleanupInterval = 10 * time.Minute + CleanupInterval = 20 * time.Minute MaxIPCacheSize = 10000 ) @@ -98,7 +98,7 @@ func (i *IPRateLimiter) cleanupRoutine() { i.mu.RLock() for ip, entry := range i.ips { - if now.Sub(entry.lastAccess) > 1*time.Hour { + if now.Sub(entry.lastAccess) > 2*time.Hour { expired = append(expired, ip) } } From 75833b937bcc52f4cc21edde4c8946ddfda4d6c0 Mon Sep 17 00:00:00 2001 From: starry <115192496+sky22333@users.noreply.github.com> Date: Tue, 2 Sep 2025 10:06:32 +0800 Subject: [PATCH 02/15] =?UTF-8?q?=E6=94=BE=E5=AE=BDgist=E5=8C=B9=E9=85=8D?= =?UTF-8?q?=E9=99=90=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/handlers/github.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/handlers/github.go b/src/handlers/github.go index 30b661e..5ceb7b5 100644 --- a/src/handlers/github.go +++ b/src/handlers/github.go @@ -20,7 +20,7 @@ var ( 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\.(?:githubusercontent|github)\.com/(.+?)/(.+?)/.+\.[a-zA-Z0-9]+$`), + regexp.MustCompile(`^(?:https?://)?gist\.(?:githubusercontent|github)\.com/([^/]+)/([^/]+).*`), regexp.MustCompile(`^(?:https?://)?api\.github\.com/repos/([^/]+)/([^/]+)/.*`), regexp.MustCompile(`^(?:https?://)?huggingface\.co(?:/spaces)?/([^/]+)/(.+)`), regexp.MustCompile(`^(?:https?://)?cdn-lfs\.hf\.co(?:/spaces)?/([^/]+)/([^/]+)(?:/(.*))?`), From 68868388d3b25414131c2ce1f92f4eb7c0ea450a Mon Sep 17 00:00:00 2001 From: starry <115192496+sky22333@users.noreply.github.com> Date: Tue, 2 Sep 2025 10:33:41 +0800 Subject: [PATCH 03/15] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E4=B8=BAv1.1.8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/handlers/github.go | 8 +------- src/main.go | 2 +- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/src/handlers/github.go b/src/handlers/github.go index 5ceb7b5..f37ec33 100644 --- a/src/handlers/github.go +++ b/src/handlers/github.go @@ -135,17 +135,11 @@ func proxyGitHubWithRedirect(c *gin.Context, u string, redirectCount int) { if contentType := resp.Header.Get("Content-Type"); blockedContentTypes[strings.ToLower(strings.Split(contentType, ";")[0])] { c.JSON(http.StatusForbidden, map[string]string{ "error": "Content type not allowed", - "message": "检测到网页内容,本服务不支持加速网页,仅支持加速资源下载。", + "message": "检测到网页类型,本服务不支持加速网页,请检查您的链接是否正确。", }) return } } - - // 如果Github上游404,则返回错误信息。这样处理是否会更好点?暂时先用检查内容类型的方式吧,防止返回网页内容。欢迎大佬们提供更好的方案。 - // if resp.StatusCode == http.StatusNotFound { - // c.String(http.StatusForbidden, "无效的GitHub地址") - // return - // } // 检查文件大小限制 cfg := config.GetConfig() diff --git a/src/main.go b/src/main.go index 4c98731..c11e462 100644 --- a/src/main.go +++ b/src/main.go @@ -125,7 +125,7 @@ func main() { fmt.Printf("H2c: 已启用\n") } - fmt.Printf("版本号: v1.1.7\n") + fmt.Printf("版本号: v1.1.8\n") fmt.Printf("项目地址: https://github.com/sky22333/hubproxy\n") // 创建HTTP2服务器 From 53060d50db08be46457dc03b64a3c303b28f868b Mon Sep 17 00:00:00 2001 From: starry <115192496+sky22333@users.noreply.github.com> Date: Tue, 2 Sep 2025 12:34:42 +0800 Subject: [PATCH 04/15] update --- src/public/images.html | 8 ++++---- src/public/index.html | 15 +++++++-------- src/public/search.html | 6 +++--- 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/src/public/images.html b/src/public/images.html index 9036bf7..3810646 100644 --- a/src/public/images.html +++ b/src/public/images.html @@ -1,13 +1,13 @@ - + - - + + Docker离线镜像下载 - +