diff --git a/.github/demo/deepwiki.svg b/.github/demo/deepwiki.svg new file mode 100644 index 0000000..34aa7b6 --- /dev/null +++ b/.github/demo/deepwiki.svg @@ -0,0 +1,5 @@ + + DeepWiki + + DeepWiki + diff --git a/.github/demo/demo1.jpg b/.github/demo/demo1.jpg new file mode 100644 index 0000000..563b0fe Binary files /dev/null and b/.github/demo/demo1.jpg differ diff --git a/.github/demo/demo2.jpg b/.github/demo/demo2.jpg new file mode 100644 index 0000000..8c5a85c Binary files /dev/null and b/.github/demo/demo2.jpg differ diff --git a/.github/demo/demo3.jpg b/.github/demo/demo3.jpg new file mode 100644 index 0000000..9f4c811 Binary files /dev/null and b/.github/demo/demo3.jpg differ diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 32e80c8..73931ec 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -23,7 +23,8 @@ jobs: - name: 设置Go环境 uses: actions/setup-go@v5 with: - go-version: '1.25' + go-version-file: "src/go.mod" + cache-dependency-path: "src/go.sum" - name: 获取版本号 id: version @@ -53,15 +54,24 @@ jobs: run: | mkdir -p build/hubproxy + - name: 安装 UPX + uses: crazy-max/ghaction-upx@v3 + with: + install-only: true + - name: 编译二进制文件 run: | cd src # Linux AMD64 - GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -o ../build/hubproxy/hubproxy-linux-amd64 . + CGO_ENABLED=0 GOOS=linux GOARCH=amd64 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 . + CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -ldflags="-s -w" -o ../build/hubproxy/hubproxy-linux-arm64 . + + # 压缩二进制文件 + upx -9 ../build/hubproxy/hubproxy-linux-amd64 + upx -9 ../build/hubproxy/hubproxy-linux-arm64 - name: 复制配置文件 run: | @@ -125,4 +135,4 @@ jobs: build/checksums.txt draft: false prerelease: false - token: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file + token: ${{ secrets.GITHUB_TOKEN }} diff --git a/Dockerfile b/Dockerfile index ae7da99..e4f248e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,11 +4,11 @@ ARG TARGETARCH WORKDIR /app COPY src/go.mod src/go.sum ./ -RUN go mod download +RUN go mod download && apk add upx COPY src/ . -RUN CGO_ENABLED=0 GOOS=linux GOARCH=${TARGETARCH} go build -ldflags="-s -w" -trimpath -o hubproxy . +RUN CGO_ENABLED=0 GOOS=linux GOARCH=${TARGETARCH} go build -ldflags="-s -w" -trimpath -o hubproxy . && upx -9 hubproxy FROM alpine diff --git a/README.md b/README.md index 3450679..e85ccb6 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,15 @@ 🚀 **Docker 和 GitHub 加速代理服务器** +

+ + DeepWiki + +

+ 一个轻量级、高性能的多功能代理服务,提供 Docker 镜像加速、GitHub 文件加速、下载离线镜像、在线搜索 Docker 镜像等功能。 +

Visitors

@@ -42,7 +49,7 @@ docker run -d \ curl -fsSL https://raw.githubusercontent.com/sky22333/hubproxy/main/install.sh | sudo bash ``` -也可以直接下载二进制文件执行`./hubproxy`使用,无需配置文件即可启动,内置默认配置,支持所有功能。 +支持单个二进制文件直接启动,无需其他配置,内置默认配置,支持所有功能。 这个脚本会: - 🔍 自动检测系统架构(AMD64/ARM64) @@ -243,6 +250,15 @@ example.com { +## 界面预览 + +![1](./.github/demo/demo1.jpg) + +![2](./.github/demo/demo2.jpg) + +![3](./.github/demo/demo3.jpg) + + ## Star 趋势 [![Star 趋势](https://starchart.cc/sky22333/hubproxy.svg?variant=adaptive)](https://starchart.cc/sky22333/hubproxy) diff --git a/docker-compose.yml b/docker-compose.yml index 41aab58..681fe6a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,8 +1,14 @@ services: hubproxy: - build: . + image: ghcr.io/sky22333/hubproxy + container_name: hubproxy restart: always ports: - - '5000:5000' + - "5000:5000" volumes: - - ./src/config.toml:/root/config.toml \ No newline at end of file + - ./src/config.toml:/root/config.toml + logging: + driver: json-file + options: + max-size: "1g" + max-file: "2" diff --git a/src/config/config.go b/src/config/config.go index 05dd578..74e31ef 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/handlers/github.go b/src/handlers/github.go index 30b661e..f37ec33 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)?/([^/]+)/([^/]+)(?:/(.*))?`), @@ -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..0208412 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.9\n") fmt.Printf("项目地址: https://github.com/sky22333/hubproxy\n") // 创建HTTP2服务器 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离线镜像下载 - +