From 367038a4b540ee5dff9aaabfacbc24feaa669ed0 Mon Sep 17 00:00:00 2001 From: RedwindA Date: Fri, 1 Aug 2025 04:58:15 +0800 Subject: [PATCH 01/37] =?UTF-8?q?=E7=A7=BB=E9=99=A4InitGlobalLimiter?= =?UTF-8?q?=E4=B8=ADburstSize=E7=9A=84=E6=9C=80=E5=B0=8F=E5=80=BC=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE=E4=BB=A5=E6=AD=A3=E7=A1=AE=E5=AE=9E=E7=8E=B0=E4=BB=85?= =?UTF-8?q?=E7=99=BD=E5=90=8D=E5=8D=95=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/ratelimiter.go | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/utils/ratelimiter.go b/src/utils/ratelimiter.go index bc6f2f2..b0d960f 100644 --- a/src/utils/ratelimiter.go +++ b/src/utils/ratelimiter.go @@ -71,9 +71,6 @@ func InitGlobalLimiter() *IPRateLimiter { ratePerSecond := rate.Limit(float64(cfg.RateLimit.RequestLimit) / (cfg.RateLimit.PeriodHours * 3600)) burstSize := cfg.RateLimit.RequestLimit - if burstSize < 1 { - burstSize = 1 - } limiter := &IPRateLimiter{ ips: make(map[string]*rateLimiterEntry), -- 2.49.1 From 431702254588f307b4e459aedcb955e46923c703 Mon Sep 17 00:00:00 2001 From: Taozhi Date: Fri, 1 Aug 2025 09:29:41 +0800 Subject: [PATCH 02/37] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=8B=89=E5=8F=96?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 在原有镜像搜索拉取镜像命令下方新增使用代理拉取镜像并tag回源镜像再untag代理镜像 --- src/public/search.html | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/public/search.html b/src/public/search.html index 957f792..da5fc98 100644 --- a/src/public/search.html +++ b/src/public/search.html @@ -1353,6 +1353,7 @@ } function renderTagsBatch(tags, fullRepoName, container, replaceContent = false) { + const proxyDomain = window.location.host; const tagsHtml = tags.map(tag => { const vulnIndicators = Object.entries(tag.vulnerabilities || {}) .map(([level, count]) => count > 0 ? `` : '') @@ -1364,6 +1365,8 @@ const size = formatUtils.formatSize(img.size); return `
${arch}
`; }).join(''); + + const proxyCommand = `docker pull ${proxyDomain}/${fullRepoName}:${tag.name} && docker tag ${proxyDomain}/${fullRepoName}:${tag.name} ${fullRepoName}:${tag.name} && docker rmi ${proxyDomain}/${fullRepoName}:${tag.name}`; return `
@@ -1380,6 +1383,10 @@ docker pull ${fullRepoName}:${tag.name}
+
+ ${proxyCommand} + +
${architectures ? `
${architectures}
` : ''} `; @@ -1488,4 +1495,4 @@ - \ No newline at end of file + -- 2.49.1 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 03/37] =?UTF-8?q?=E4=BC=98=E5=8C=96github=E4=B8=8A?= =?UTF-8?q?=E6=B8=B8=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 != "" { -- 2.49.1 From bb2f7bcda655125ea85a94ab2a3d4383abe1addf Mon Sep 17 00:00:00 2001 From: starry <115192496+sky22333@users.noreply.github.com> Date: Fri, 1 Aug 2025 13:23:52 +0800 Subject: [PATCH 04/37] =?UTF-8?q?=E5=90=AF=E5=8A=A8=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E7=89=88=E6=9C=AC=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main.go b/src/main.go index e1bf45c..78dd6ec 100644 --- a/src/main.go +++ b/src/main.go @@ -116,16 +116,17 @@ func main() { router.NoRoute(handlers.GitHubProxyHandler) cfg := config.GetConfig() - fmt.Printf("🚀 HubProxy 启动成功\n") - fmt.Printf("📡 监听地址: %s:%d\n", cfg.Server.Host, cfg.Server.Port) - fmt.Printf("⚡ 限流配置: %d请求/%g小时\n", cfg.RateLimit.RequestLimit, cfg.RateLimit.PeriodHours) + fmt.Printf("HubProxy 启动成功\n") + fmt.Printf("监听地址: %s:%d\n", cfg.Server.Host, cfg.Server.Port) + fmt.Printf("限流配置: %d请求/%g小时\n", cfg.RateLimit.RequestLimit, cfg.RateLimit.PeriodHours) // 显示HTTP/2支持状态 if cfg.Server.EnableH2C { fmt.Printf("H2c: 已启用\n") } - fmt.Printf("🔗 项目地址: https://github.com/sky22333/hubproxy\n") + fmt.Printf("版本号: v1.1.6\n") + fmt.Printf("项目地址: https://github.com/sky22333/hubproxy\n") // 创建HTTP2服务器 server := &http.Server{ -- 2.49.1 From 6193a078376525d6c3c1a8a7373acde2e32cc5e4 Mon Sep 17 00:00:00 2001 From: starry <115192496+sky22333@users.noreply.github.com> Date: Fri, 1 Aug 2025 14:43:04 +0800 Subject: [PATCH 05/37] Update .gitattributes --- .gitattributes | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitattributes b/.gitattributes index 94f480d..5b32132 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1 +1,2 @@ -* text=auto eol=lf \ No newline at end of file +* text=auto eol=lf +*.html linguist-vendored -- 2.49.1 From e2413fc30d965930329234f9e889aa9c0ce3c621 Mon Sep 17 00:00:00 2001 From: starry <115192496+sky22333@users.noreply.github.com> Date: Fri, 15 Aug 2025 21:52:00 +0800 Subject: [PATCH 06/37] =?UTF-8?q?=E5=86=99=E5=93=8D=E5=BA=94=E7=9A=84?= =?UTF-8?q?=E6=9C=80=E5=A4=A7=E5=85=81=E8=AE=B8=E6=97=B6=E9=97=B4=E6=94=B9?= =?UTF-8?q?=E4=B8=BA30=E5=88=86=E9=92=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit h2写响应的最大允许时间从5分钟增加至30分钟,兼容大文件下载 --- src/main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.go b/src/main.go index 78dd6ec..509e66b 100644 --- a/src/main.go +++ b/src/main.go @@ -132,7 +132,7 @@ func main() { server := &http.Server{ Addr: fmt.Sprintf("%s:%d", cfg.Server.Host, cfg.Server.Port), ReadTimeout: 60 * time.Second, - WriteTimeout: 300 * time.Second, + WriteTimeout: 30 * time.Minute, IdleTimeout: 120 * time.Second, } -- 2.49.1 From 9d5d3012a58a2da8bb77279ba601a2bf11198785 Mon Sep 17 00:00:00 2001 From: user123456 Date: Fri, 29 Aug 2025 22:12:00 +0800 Subject: [PATCH 07/37] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E4=BE=9D=E8=B5=96?= =?UTF-8?q?=EF=BC=8C=E5=BC=80=E5=90=AFGreen=20Tea=20GC=E6=96=B0=E7=89=B9?= =?UTF-8?q?=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/docker-ghcr.yml | 10 +++--- .github/workflows/release.yml | 16 ++++----- Dockerfile | 9 +++-- src/go.mod | 25 ++++++-------- src/go.sum | 56 ++++++++++++------------------- src/handlers/docker.go | 1 + src/main.go | 2 +- 7 files changed, 53 insertions(+), 66 deletions(-) diff --git a/.github/workflows/docker-ghcr.yml b/.github/workflows/docker-ghcr.yml index e0265f0..fc1808e 100644 --- a/.github/workflows/docker-ghcr.yml +++ b/.github/workflows/docker-ghcr.yml @@ -15,13 +15,13 @@ jobs: packages: write steps: - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 + uses: docker/setup-buildx-action@v3 - name: Cache Docker layers - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: /tmp/.buildx-cache key: ${{ runner.os }}-buildx-${{ github.sha }} @@ -29,7 +29,7 @@ jobs: ${{ runner.os }}-buildx- - name: Log in to GitHub Docker Registry - uses: docker/login-action@v2 + uses: docker/login-action@v3 with: registry: ghcr.io username: ${{ github.actor }} @@ -47,7 +47,7 @@ jobs: - name: Build and push Docker image run: | docker buildx build --push \ - --platform linux/amd64,linux/arm64/v8 \ + --platform linux/amd64,linux/arm64 \ --tag ghcr.io/${{ env.REPO_LOWER }}:${{ env.VERSION }} \ --tag ghcr.io/${{ env.REPO_LOWER }}:latest \ --build-arg VERSION=${{ env.VERSION }} \ diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8238827..f88af0d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -21,9 +21,9 @@ jobs: fetch-depth: 0 # 获取完整历史,用于生成变更日志 - name: 设置Go环境 - uses: actions/setup-go@v4 + uses: actions/setup-go@v5 with: - go-version: '1.24' + go-version: '1.25' - name: 获取版本号 id: version @@ -57,11 +57,11 @@ jobs: run: | cd src - # Linux AMD64 - GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -o ../build/hubproxy/hubproxy-linux-amd64 . + # Linux AMD64 (启用Green Tea GC) + GOOS=linux GOARCH=amd64 GOEXPERIMENT=greenteagc go build -ldflags="-s -w" -o ../build/hubproxy/hubproxy-linux-amd64 . - # Linux ARM64 - GOOS=linux GOARCH=arm64 go build -ldflags="-s -w" -o ../build/hubproxy/hubproxy-linux-arm64 . + # Linux ARM64 (启用Green Tea GC) + GOOS=linux GOARCH=arm64 GOEXPERIMENT=greenteagc go build -ldflags="-s -w" -o ../build/hubproxy/hubproxy-linux-arm64 . - name: 复制配置文件 run: | @@ -107,7 +107,7 @@ jobs: cat checksums.txt - name: 创建或更新Release - uses: softprops/action-gh-release@v1 + uses: softprops/action-gh-release@v2 with: tag_name: ${{ steps.version.outputs.version }} name: "HubProxy ${{ steps.version.outputs.version }}" @@ -125,4 +125,4 @@ jobs: build/checksums.txt draft: false prerelease: false - token: ${{ secrets.GITHUB_TOKEN }} + token: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 4ba3410..2a88c35 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,11 +1,14 @@ -FROM golang:1.24-alpine AS builder +FROM golang:1.25-alpine AS builder + +ARG TARGETARCH WORKDIR /app COPY src/go.mod src/go.sum ./ RUN go mod download COPY src/ . -RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w" -trimpath -o hubproxy . + +RUN CGO_ENABLED=0 GOOS=linux GOARCH=${TARGETARCH} GOEXPERIMENT=greenteagc go build -ldflags="-s -w" -trimpath -o hubproxy . FROM alpine @@ -14,4 +17,4 @@ WORKDIR /root/ COPY --from=builder /app/hubproxy . COPY --from=builder /app/config.toml . -CMD ["./hubproxy"] +CMD ["./hubproxy"] \ No newline at end of file diff --git a/src/go.mod b/src/go.mod index 6e8a2f8..0d84ce4 100644 --- a/src/go.mod +++ b/src/go.mod @@ -1,13 +1,13 @@ module hubproxy -go 1.24.0 +go 1.25 require ( - github.com/gin-gonic/gin v1.10.0 - github.com/google/go-containerregistry v0.20.5 - github.com/pelletier/go-toml/v2 v2.2.3 - golang.org/x/net v0.33.0 - golang.org/x/time v0.11.0 + github.com/gin-gonic/gin v1.10.1 + github.com/google/go-containerregistry v0.20.6 + github.com/pelletier/go-toml/v2 v2.2.4 + golang.org/x/net v0.43.0 + golang.org/x/time v0.12.0 ) require ( @@ -16,7 +16,7 @@ require ( github.com/cloudwego/base64x v0.1.4 // indirect github.com/cloudwego/iasm v0.2.0 // indirect github.com/containerd/stargz-snapshotter/estargz v0.16.3 // indirect - github.com/docker/cli v28.1.1+incompatible // indirect + github.com/docker/cli v28.2.2+incompatible // indirect github.com/docker/distribution v2.8.3+incompatible // indirect github.com/docker/docker-credential-helpers v0.9.3 // indirect github.com/gabriel-vasile/mimetype v1.4.3 // indirect @@ -28,7 +28,6 @@ require ( github.com/json-iterator/go v1.1.12 // indirect github.com/klauspost/compress v1.18.0 // indirect github.com/klauspost/cpuid/v2 v2.2.7 // indirect - github.com/kr/pretty v0.3.0 // indirect github.com/leodido/go-urn v1.4.0 // indirect github.com/mattn/go-isatty v0.0.20 // indirect github.com/mitchellh/go-homedir v1.1.0 // indirect @@ -37,17 +36,15 @@ require ( github.com/opencontainers/go-digest v1.0.0 // indirect github.com/opencontainers/image-spec v1.1.1 // indirect github.com/pkg/errors v0.9.1 // indirect - github.com/rogpeppe/go-internal v1.9.0 // indirect github.com/sirupsen/logrus v1.9.3 // indirect github.com/twitchyliquid64/golang-asm v0.15.1 // indirect github.com/ugorji/go/codec v1.2.12 // indirect github.com/vbatts/tar-split v0.12.1 // indirect golang.org/x/arch v0.8.0 // indirect - golang.org/x/crypto v0.32.0 // indirect - golang.org/x/sync v0.14.0 // indirect - golang.org/x/sys v0.33.0 // indirect - golang.org/x/text v0.21.0 // indirect + golang.org/x/crypto v0.41.0 // indirect + golang.org/x/sync v0.16.0 // indirect + golang.org/x/sys v0.35.0 // indirect + golang.org/x/text v0.28.0 // indirect google.golang.org/protobuf v1.36.3 // indirect - gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/src/go.sum b/src/go.sum index d70c944..a4a5258 100644 --- a/src/go.sum +++ b/src/go.sum @@ -8,12 +8,11 @@ github.com/cloudwego/iasm v0.2.0 h1:1KNIy1I1H9hNNFEEH3DVnI4UujN+1zjpuk6gwHLTssg= github.com/cloudwego/iasm v0.2.0/go.mod h1:8rXZaNYT2n95jn+zTI1sDr+IgcD2GVs0nlbbQPiEFhY= github.com/containerd/stargz-snapshotter/estargz v0.16.3 h1:7evrXtoh1mSbGj/pfRccTampEyKpjpOnS3CyiV1Ebr8= github.com/containerd/stargz-snapshotter/estargz v0.16.3/go.mod h1:uyr4BfYfOj3G9WBVE8cOlQmXAbPN9VEQpBBeJIuOipU= -github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/docker/cli v28.1.1+incompatible h1:eyUemzeI45DY7eDPuwUcmDyDj1pM98oD5MdSpiItp8k= -github.com/docker/cli v28.1.1+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8= +github.com/docker/cli v28.2.2+incompatible h1:qzx5BNUDFqlvyq4AHzdNB7gSyVTmU4cgsyN9SdInc1A= +github.com/docker/cli v28.2.2+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8= github.com/docker/distribution v2.8.3+incompatible h1:AtKxIZ36LoNK51+Z6RpzLpddBirtxJnzDrHLEKxTAYk= github.com/docker/distribution v2.8.3+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= github.com/docker/docker-credential-helpers v0.9.3 h1:gAm/VtF9wgqJMoxzT3Gj5p4AqIjCBS4wrsOh9yRqcz8= @@ -22,8 +21,8 @@ github.com/gabriel-vasile/mimetype v1.4.3 h1:in2uUcidCuFcDKtdcBxlR0rJ1+fsokWf+uq github.com/gabriel-vasile/mimetype v1.4.3/go.mod h1:d8uq/6HKRL6CGdk+aubisF/M5GcPfT7nKyLpA0lbSSk= github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= -github.com/gin-gonic/gin v1.10.0 h1:nTuyha1TYqgedzytsKYqna+DfLos46nTv2ygFy86HFU= -github.com/gin-gonic/gin v1.10.0/go.mod h1:4PMNQiOhvDRa013RKVbsiNwoyezlm2rm0uX/T7kzp5Y= +github.com/gin-gonic/gin v1.10.1 h1:T0ujvqyCSqRopADpgPgiTT63DUQVSfojyME59Ei63pQ= +github.com/gin-gonic/gin v1.10.1/go.mod h1:4PMNQiOhvDRa013RKVbsiNwoyezlm2rm0uX/T7kzp5Y= github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s= github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA= @@ -36,8 +35,8 @@ github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU= github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= -github.com/google/go-containerregistry v0.20.5 h1:4RnlYcDs5hoA++CeFjlbZ/U9Yp1EuWr+UhhTyYQjOP0= -github.com/google/go-containerregistry v0.20.5/go.mod h1:Q14vdOOzug02bwnhMkZKD4e30pDaD9W65qzXpyzF49E= +github.com/google/go-containerregistry v0.20.6 h1:cvWX87UxxLgaH76b4hIvya6Dzz9qHB31qAwjAohdSTU= +github.com/google/go-containerregistry v0.20.6/go.mod h1:T0x8MuoAoKX/873bkeSfLD2FAkwCDf9/HZgsFJ02E2Y= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= @@ -47,13 +46,6 @@ github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa02 github.com/klauspost/cpuid/v2 v2.2.7 h1:ZWSB3igEs+d0qvnxR/ZBzXVmxkgt8DdzP6m9pfuVLDM= github.com/klauspost/cpuid/v2 v2.2.7/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws= github.com/knz/go-libedit v1.10.1/go.mod h1:MZTVkCWyz0oBc7JOWP3wNAzd002ZbM/5hgShxwh4x8M= -github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= -github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0= -github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk= -github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= -github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= -github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= -github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ= github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI= github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= @@ -69,15 +61,12 @@ github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8 github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= github.com/opencontainers/image-spec v1.1.1 h1:y0fUlFfIZhPF1W537XOLg0/fcx6zcHCJwooC2xJA040= github.com/opencontainers/image-spec v1.1.1/go.mod h1:qpqAh3Dmcf36wStyyWU+kCeDgrGnAve2nCC8+7h8Q0M= -github.com/pelletier/go-toml/v2 v2.2.3 h1:YmeHyLY8mFWbdkNWwpr+qIL2bEqT0o95WSdkNHvL12M= -github.com/pelletier/go-toml/v2 v2.2.3/go.mod h1:MfCQTFTvCcUyyvvwm1+G6H/jORL20Xlb6rzQu9GuUkc= +github.com/pelletier/go-toml/v2 v2.2.4 h1:mye9XuhQ6gvn5h28+VilKrrPoQVanw5PMw/TB0t5Ec4= +github.com/pelletier/go-toml/v2 v2.2.4/go.mod h1:2gIqNv+qfxSVS7cM2xJQKtLSTLUE9V8t9Stt+h56mCY= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= -github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8= -github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ= github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= @@ -99,28 +88,25 @@ github.com/vbatts/tar-split v0.12.1/go.mod h1:eF6B6i6ftWQcDqEn3/iGFRFRo8cBIMSJVO golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8= golang.org/x/arch v0.8.0 h1:3wRIsP3pM4yUptoR96otTUOXI367OS0+c9eeRi9doIc= golang.org/x/arch v0.8.0/go.mod h1:FEVrYAQjsQXMVJ1nsMoVVXPZg6p2JE2mx8psSWTDQys= -golang.org/x/crypto v0.32.0 h1:euUpcYgM8WcP71gNpTqQCn6rC2t6ULUPiOzfWaXVVfc= -golang.org/x/crypto v0.32.0/go.mod h1:ZnnJkOaASj8g0AjIduWNlq2NRxL0PlBrbKVyZ6V/Ugc= -golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I= -golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4= -golang.org/x/sync v0.14.0 h1:woo0S4Yywslg6hp4eUFjTVOyKt0RookbpAHG4c1HmhQ= -golang.org/x/sync v0.14.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA= +golang.org/x/crypto v0.41.0 h1:WKYxWedPGCTVVl5+WHSSrOBT0O8lx32+zxmHxijgXp4= +golang.org/x/crypto v0.41.0/go.mod h1:pO5AFd7FA68rFak7rOAGVuygIISepHftHnr8dr6+sUc= +golang.org/x/net v0.43.0 h1:lat02VYK2j4aLzMzecihNvTlJNQUq316m2Mr9rnM6YE= +golang.org/x/net v0.43.0/go.mod h1:vhO1fvI4dGsIjh73sWfUVjj3N7CA9WkKJNQm2svM6Jg= +golang.org/x/sync v0.16.0 h1:ycBJEhp9p4vXvUZNszeOq0kGTPghopOL8q0fq3vstxw= +golang.org/x/sync v0.16.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA= golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.33.0 h1:q3i8TbbEz+JRD9ywIRlyRAQbM0qF7hu24q3teo2hbuw= -golang.org/x/sys v0.33.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= -golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo= -golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ= -golang.org/x/time v0.11.0 h1:/bpjEDfN9tkoN/ryeYHnv5hcMlc8ncjMcM4XBk5NWV0= -golang.org/x/time v0.11.0/go.mod h1:CDIdPxbZBQxdj6cxyCIdrNogrJKMJ7pr37NYpMcMDSg= +golang.org/x/sys v0.35.0 h1:vz1N37gP5bs89s7He8XuIYXpyY0+QlsKmzipCbUtyxI= +golang.org/x/sys v0.35.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= +golang.org/x/text v0.28.0 h1:rhazDwis8INMIwQ4tpjLDzUhx6RlXqZNPEM0huQojng= +golang.org/x/text v0.28.0/go.mod h1:U8nCwOR8jO/marOQ0QbDiOngZVEBB7MAiitBuMjXiNU= +golang.org/x/time v0.12.0 h1:ScB/8o8olJvc+CQPWrK3fPZNfh7qgwCrY0zJmoEQLSE= +golang.org/x/time v0.12.0/go.mod h1:CDIdPxbZBQxdj6cxyCIdrNogrJKMJ7pr37NYpMcMDSg= google.golang.org/protobuf v1.36.3 h1:82DV7MYdb8anAVi3qge1wSnMDrnKK7ebr+I0hHRN1BU= google.golang.org/protobuf v1.36.3/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= -gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/src/handlers/docker.go b/src/handlers/docker.go index ffccc73..63a740b 100644 --- a/src/handlers/docker.go +++ b/src/handlers/docker.go @@ -598,6 +598,7 @@ func createUpstreamOptions(mapping config.RegistryMapping) []remote.Option { remote.WithTransport(utils.GetGlobalHTTPClient().Transport), } + // 预留将来不同Registry的差异化认证逻辑扩展点 switch mapping.AuthType { case "github": case "google": diff --git a/src/main.go b/src/main.go index 509e66b..4c98731 100644 --- a/src/main.go +++ b/src/main.go @@ -125,7 +125,7 @@ func main() { fmt.Printf("H2c: 已启用\n") } - fmt.Printf("版本号: v1.1.6\n") + fmt.Printf("版本号: v1.1.7\n") fmt.Printf("项目地址: https://github.com/sky22333/hubproxy\n") // 创建HTTP2服务器 -- 2.49.1 From eee0a3220c96cf232b0d2fc3bc59101974646096 Mon Sep 17 00:00:00 2001 From: starry <115192496+sky22333@users.noreply.github.com> Date: Fri, 29 Aug 2025 22:27:50 +0800 Subject: [PATCH 08/37] Update README.md --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 73626df..bbd4da3 100644 --- a/README.md +++ b/README.md @@ -40,9 +40,9 @@ docker run -d \ curl -fsSL https://raw.githubusercontent.com/sky22333/hubproxy/main/install.sh | sudo bash ``` -也可以直接下载二进制文件执行`./hubproxy`使用,无需配置文件即可启动,内置默认配置,支持所有功能。初始内存占用约18M,二进制文件大小约12M +也可以直接下载二进制文件执行`./hubproxy`使用,无需配置文件即可启动,内置默认配置,支持所有功能。 -这个命令会: +这个脚本会: - 🔍 自动检测系统架构(AMD64/ARM64) - 📥 从 GitHub Releases 下载最新版本 - ⚙️ 自动配置系统服务 @@ -79,8 +79,7 @@ docker pull yourdomain.com/ghcr.io/sky22333/hubproxy } ``` -若已设置其他加速地址,直接并列添加后保存, -再执行 `sudo systemctl restart docker` 重启docker服务让配置生效。 +若已设置其他加速地址,直接并列添加后保存,再执行 `sudo systemctl restart docker` 重启docker服务让配置生效。 ### GitHub 文件加速 @@ -100,7 +99,7 @@ git clone https://yourdomain.com/https://github.com/sky22333/hubproxy.git
config.toml 配置说明 -*此配置是默认配置,已经内置在程序中了,可以不用添加。* +*此配置是默认配置,已经内置在程序中了* ``` [server] @@ -224,6 +223,7 @@ example.com { } ``` +> 对于使用nginx反代的用户,Github加速提示`无效输入`的问题可以参见[issues/62](https://github.com/sky22333/hubproxy/issues/62#issuecomment-3219572440) ## ⚠️ 免责声明 -- 2.49.1 From 737a522afccbcf5126ad2864ec0801ae21d3221f Mon Sep 17 00:00:00 2001 From: starry <115192496+sky22333@users.noreply.github.com> Date: Mon, 1 Sep 2025 01:50:10 +0800 Subject: [PATCH 09/37] Update README.md --- README.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index bbd4da3..3450679 100644 --- a/README.md +++ b/README.md @@ -10,15 +10,17 @@ ## ✨ 特性 -- 🐳 **Docker 镜像加速** - 单域名实现 Docker Hub、GHCR、Quay 等多个镜像仓库加速,流式传输优化拉取速度。 +- 🐳 **Docker 镜像加速** - 支持 Docker Hub、GHCR、Quay 等多个镜像仓库加速,流式传输优化拉取速度。 - 🐳 **离线镜像包** - 支持下载离线镜像包,流式传输加防抖设计。 - 📁 **GitHub 文件加速** - 加速 GitHub Release、Raw 文件下载,支持`api.github.com`,脚本嵌套加速等等 - 🤖 **AI 模型库支持** - 支持 Hugging Face 模型下载加速 - 🛡️ **智能限流** - IP 限流保护,防止滥用 - 🚫 **仓库审计** - 强大的自定义黑名单,白名单,同时审计镜像仓库,和GitHub仓库 - 🔍 **镜像搜索** - 在线搜索 Docker 镜像 -- ⚡ **轻量高效** - 基于 Go 语言,单二进制文件运行,资源占用低,优雅的内存清理机制。 -- 🔧 **统一配置** - 统一配置管理 +- ⚡ **轻量高效** - 基于 Go 语言,单二进制文件运行,资源占用低。 +- 🔧 **统一配置** - 统一配置管理,便于维护。 +- 🛡️ **完全自托管** - 避免依赖免费第三方服务的不稳定性,例如`cloudflare`等等。 +- 🚀 **多服务统一加速** - 单个程序即可统一加速 Docker、GitHub、Hugging Face 等多种服务,简化部署与管理。 ## 🚀 快速开始 -- 2.49.1 From 30bc88ed9336ebb821b62c08842a2dd3ab55fa52 Mon Sep 17 00:00:00 2001 From: starry <115192496+sky22333@users.noreply.github.com> Date: Mon, 1 Sep 2025 02:22:07 +0800 Subject: [PATCH 10/37] =?UTF-8?q?=E5=8E=BB=E6=8E=89greenteagc?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/release.yml | 8 ++++---- Dockerfile | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f88af0d..32e80c8 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -57,11 +57,11 @@ jobs: run: | cd src - # Linux AMD64 (启用Green Tea GC) - GOOS=linux GOARCH=amd64 GOEXPERIMENT=greenteagc go build -ldflags="-s -w" -o ../build/hubproxy/hubproxy-linux-amd64 . + # Linux AMD64 + GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -o ../build/hubproxy/hubproxy-linux-amd64 . - # Linux ARM64 (启用Green Tea GC) - GOOS=linux GOARCH=arm64 GOEXPERIMENT=greenteagc go build -ldflags="-s -w" -o ../build/hubproxy/hubproxy-linux-arm64 . + # Linux ARM64 + GOOS=linux GOARCH=arm64 go build -ldflags="-s -w" -o ../build/hubproxy/hubproxy-linux-arm64 . - name: 复制配置文件 run: | diff --git a/Dockerfile b/Dockerfile index 2a88c35..ae7da99 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,7 +8,7 @@ RUN go mod download COPY src/ . -RUN CGO_ENABLED=0 GOOS=linux GOARCH=${TARGETARCH} GOEXPERIMENT=greenteagc go build -ldflags="-s -w" -trimpath -o hubproxy . +RUN CGO_ENABLED=0 GOOS=linux GOARCH=${TARGETARCH} go build -ldflags="-s -w" -trimpath -o hubproxy . FROM alpine -- 2.49.1 From 40f5b597ab9ad181faa43b4b03ac7b2dc1db8ddc Mon Sep 17 00:00:00 2001 From: starry <115192496+sky22333@users.noreply.github.com> Date: Mon, 1 Sep 2025 12:05:16 +0800 Subject: [PATCH 11/37] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=A3=80=E6=9F=A5?= =?UTF-8?q?=E6=98=AF=E5=90=A6=E4=B8=BA=E7=BD=91=E9=A1=B5=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/handlers/github.go | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/src/handlers/github.go b/src/handlers/github.go index 8cbe79e..70919c8 100644 --- a/src/handlers/github.go +++ b/src/handlers/github.go @@ -29,6 +29,14 @@ var ( } ) +// 全局变量:被阻止的内容类型 +var blockedContentTypes = map[string]bool{ + "text/html": true, + "application/xhtml+xml": true, + "text/xml": true, + "application/xml": true, +} + // GitHubProxyHandler GitHub代理处理器 func GitHubProxyHandler(c *gin.Context) { rawPath := strings.TrimPrefix(c.Request.URL.RequestURI(), "/") @@ -121,12 +129,23 @@ func proxyGitHubWithRedirect(c *gin.Context, u string, redirectCount int) { fmt.Printf("关闭响应体失败: %v\n", err) } }() - - // 如果Github上游404,则返回错误信息 - if resp.StatusCode == http.StatusNotFound { - c.String(http.StatusForbidden, "无效的GitHub地址") - return + + // 检查并处理被阻止的内容类型 + if c.Request.Method == "GET" { + 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": "检测到网页内容,本服务不支持加速网页,仅支持加速资源下载。", + }) + return + } } + + // 如果Github上游404,则返回错误信息。这样处理是否会更好点?暂时先用检查内容类型的方式吧,防止返回网页内容。欢迎大佬们提供更好的方案。 + // if resp.StatusCode == http.StatusNotFound { + // c.String(http.StatusForbidden, "无效的GitHub地址") + // return + // } // 检查文件大小限制 cfg := config.GetConfig() -- 2.49.1 From 0cd5a7334d6e6231e69a8672348fa20e04126822 Mon Sep 17 00:00:00 2001 From: starry <115192496+sky22333@users.noreply.github.com> Date: Mon, 1 Sep 2025 12:16:42 +0800 Subject: [PATCH 12/37] =?UTF-8?q?=E5=A2=9E=E5=8A=A0.ps1=E8=84=9A=E6=9C=AC?= =?UTF-8?q?=E7=9A=84=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/handlers/github.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/handlers/github.go b/src/handlers/github.go index 70919c8..30b661e 100644 --- a/src/handlers/github.go +++ b/src/handlers/github.go @@ -171,8 +171,8 @@ func proxyGitHubWithRedirect(c *gin.Context, u string, redirectCount int) { realHost = "https://" + realHost } - // 处理.sh文件的智能处理 - if strings.HasSuffix(strings.ToLower(u), ".sh") { + // 处理.sh和.ps1文件的智能处理 + if strings.HasSuffix(strings.ToLower(u), ".sh") || strings.HasSuffix(strings.ToLower(u), ".ps1") { isGzipCompressed := resp.Header.Get("Content-Encoding") == "gzip" processedBody, processedSize, err := utils.ProcessSmart(resp.Body, isGzipCompressed, realHost) -- 2.49.1 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 13/37] =?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) } } -- 2.49.1 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 14/37] =?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)?/([^/]+)/([^/]+)(?:/(.*))?`), -- 2.49.1 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 15/37] =?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服务器 -- 2.49.1 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 16/37] 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离线镜像下载 - +