Compare commits
17 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
31f62fde35 | ||
|
|
8d7619c7e4 | ||
|
|
a09db34787 | ||
|
|
31a3b67ab0 | ||
|
|
3590c7c073 | ||
|
|
3f614e8011 | ||
|
|
198a18508b | ||
|
|
780ac14a8f | ||
|
|
62b3cb6b70 | ||
|
|
714224bd29 | ||
|
|
7f6c46f0c8 | ||
|
|
fd9b0cf829 | ||
|
|
42ddfaab9d | ||
|
|
6144883a6e | ||
|
|
c704923b64 | ||
|
|
dcb502d3c8 | ||
|
|
a011d560c6 |
BIN
.github/demo/demo1.jpg
vendored
Normal file
BIN
.github/demo/demo1.jpg
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 79 KiB |
18
.github/workflows/release.yml
vendored
18
.github/workflows/release.yml
vendored
@@ -23,7 +23,8 @@ jobs:
|
|||||||
- name: 设置Go环境
|
- name: 设置Go环境
|
||||||
uses: actions/setup-go@v5
|
uses: actions/setup-go@v5
|
||||||
with:
|
with:
|
||||||
go-version: '1.25'
|
go-version-file: "src/go.mod"
|
||||||
|
cache-dependency-path: "src/go.sum"
|
||||||
|
|
||||||
- name: 获取版本号
|
- name: 获取版本号
|
||||||
id: version
|
id: version
|
||||||
@@ -53,15 +54,24 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
mkdir -p build/hubproxy
|
mkdir -p build/hubproxy
|
||||||
|
|
||||||
|
- name: 安装 UPX
|
||||||
|
uses: crazy-max/ghaction-upx@v3
|
||||||
|
with:
|
||||||
|
install-only: true
|
||||||
|
|
||||||
- name: 编译二进制文件
|
- name: 编译二进制文件
|
||||||
run: |
|
run: |
|
||||||
cd src
|
cd src
|
||||||
|
|
||||||
# Linux AMD64
|
# 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
|
# 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: 复制配置文件
|
- name: 复制配置文件
|
||||||
run: |
|
run: |
|
||||||
@@ -125,4 +135,4 @@ jobs:
|
|||||||
build/checksums.txt
|
build/checksums.txt
|
||||||
draft: false
|
draft: false
|
||||||
prerelease: false
|
prerelease: false
|
||||||
token: ${{ secrets.GITHUB_TOKEN }}
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|||||||
@@ -4,11 +4,11 @@ ARG TARGETARCH
|
|||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY src/go.mod src/go.sum ./
|
COPY src/go.mod src/go.sum ./
|
||||||
RUN go mod download
|
RUN go mod download && apk add upx
|
||||||
|
|
||||||
COPY src/ .
|
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
|
FROM alpine
|
||||||
|
|
||||||
|
|||||||
32
README.md
32
README.md
@@ -1,14 +1,15 @@
|
|||||||
# HubProxy
|
# HubProxy
|
||||||
|
|
||||||
🚀 **Docker 和 GitHub 加速代理服务器**
|
**Docker 和 GitHub 加速代理服务器**
|
||||||
|
|
||||||
一个轻量级、高性能的多功能代理服务,提供 Docker 镜像加速、GitHub 文件加速、下载离线镜像、在线搜索 Docker 镜像等功能。
|
一个轻量级、高性能的多功能代理服务,提供 Docker 镜像加速、GitHub 文件加速、下载离线镜像、在线搜索 Docker 镜像等功能。
|
||||||
|
|
||||||
|
|
||||||
<p align="center">
|
<p align="center">
|
||||||
<img src="https://count.getloli.com/get/@sky22333.hubproxy?theme=rule34" alt="Visitors">
|
<img src="https://count.getloli.com/get/@sky22333.hubproxy?theme=rule34" alt="Visitors">
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
## ✨ 特性
|
## 特性
|
||||||
|
|
||||||
- 🐳 **Docker 镜像加速** - 支持 Docker Hub、GHCR、Quay 等多个镜像仓库加速,流式传输优化拉取速度。
|
- 🐳 **Docker 镜像加速** - 支持 Docker Hub、GHCR、Quay 等多个镜像仓库加速,流式传输优化拉取速度。
|
||||||
- 🐳 **离线镜像包** - 支持下载离线镜像包,流式传输加防抖设计。
|
- 🐳 **离线镜像包** - 支持下载离线镜像包,流式传输加防抖设计。
|
||||||
@@ -22,8 +23,13 @@
|
|||||||
- 🛡️ **完全自托管** - 避免依赖免费第三方服务的不稳定性,例如`cloudflare`等等。
|
- 🛡️ **完全自托管** - 避免依赖免费第三方服务的不稳定性,例如`cloudflare`等等。
|
||||||
- 🚀 **多服务统一加速** - 单个程序即可统一加速 Docker、GitHub、Hugging Face 等多种服务,简化部署与管理。
|
- 🚀 **多服务统一加速** - 单个程序即可统一加速 Docker、GitHub、Hugging Face 等多种服务,简化部署与管理。
|
||||||
|
|
||||||
|
## 详细文档
|
||||||
|
|
||||||
## 🚀 快速开始
|
[中文文档](https://zread.ai/sky22333/hubproxy)
|
||||||
|
|
||||||
|
[English](https://deepwiki.com/sky22333/hubproxy)
|
||||||
|
|
||||||
|
## 快速开始
|
||||||
|
|
||||||
### Docker部署(推荐)
|
### Docker部署(推荐)
|
||||||
```
|
```
|
||||||
@@ -34,25 +40,21 @@ docker run -d \
|
|||||||
ghcr.io/sky22333/hubproxy
|
ghcr.io/sky22333/hubproxy
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### 一键脚本安装
|
### 一键脚本安装
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -fsSL https://raw.githubusercontent.com/sky22333/hubproxy/main/install.sh | sudo bash
|
curl -fsSL https://raw.githubusercontent.com/sky22333/hubproxy/main/install.sh | sudo bash
|
||||||
```
|
```
|
||||||
|
|
||||||
也可以直接下载二进制文件执行`./hubproxy`使用,无需配置文件即可启动,内置默认配置,支持所有功能。
|
支持单个二进制文件直接启动,无需其他配置,内置默认配置,支持所有功能。
|
||||||
|
|
||||||
这个脚本会:
|
这个脚本会:
|
||||||
- 🔍 自动检测系统架构(AMD64/ARM64)
|
- 自动检测系统架构(AMD64/ARM64)
|
||||||
- 📥 从 GitHub Releases 下载最新版本
|
- 从 GitHub Releases 下载最新版本
|
||||||
- ⚙️ 自动配置系统服务
|
- 自动配置系统服务
|
||||||
- 🔄 保留现有配置(升级时)
|
- 保留现有配置(升级时)
|
||||||
|
|
||||||
|
## 使用方法
|
||||||
|
|
||||||
## 📖 使用方法
|
|
||||||
|
|
||||||
### Docker 镜像加速
|
### Docker 镜像加速
|
||||||
|
|
||||||
@@ -96,7 +98,7 @@ https://yourdomain.com/https://github.com/user/repo/releases/download/v1.0.0/fil
|
|||||||
git clone https://yourdomain.com/https://github.com/sky22333/hubproxy.git
|
git clone https://yourdomain.com/https://github.com/sky22333/hubproxy.git
|
||||||
```
|
```
|
||||||
|
|
||||||
## ⚙️ 配置
|
## 配置
|
||||||
|
|
||||||
<details>
|
<details>
|
||||||
<summary>config.toml 配置说明</summary>
|
<summary>config.toml 配置说明</summary>
|
||||||
@@ -242,7 +244,9 @@ example.com {
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
## 界面预览
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
## Star 趋势
|
## Star 趋势
|
||||||
[](https://starchart.cc/sky22333/hubproxy)
|
[](https://starchart.cc/sky22333/hubproxy)
|
||||||
|
|||||||
@@ -1,8 +1,14 @@
|
|||||||
services:
|
services:
|
||||||
hubproxy:
|
hubproxy:
|
||||||
build: .
|
image: ghcr.io/sky22333/hubproxy
|
||||||
|
container_name: hubproxy
|
||||||
restart: always
|
restart: always
|
||||||
ports:
|
ports:
|
||||||
- '5000:5000'
|
- "5000:5000"
|
||||||
volumes:
|
volumes:
|
||||||
- ./src/config.toml:/root/config.toml
|
- ./src/config.toml:/root/config.toml
|
||||||
|
logging:
|
||||||
|
driver: json-file
|
||||||
|
options:
|
||||||
|
max-size: "1g"
|
||||||
|
max-file: "2"
|
||||||
|
|||||||
@@ -125,7 +125,7 @@ func main() {
|
|||||||
fmt.Printf("H2c: 已启用\n")
|
fmt.Printf("H2c: 已启用\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Printf("版本号: v1.1.8\n")
|
fmt.Printf("版本号: v1.2.0\n")
|
||||||
fmt.Printf("项目地址: https://github.com/sky22333/hubproxy\n")
|
fmt.Printf("项目地址: https://github.com/sky22333/hubproxy\n")
|
||||||
|
|
||||||
// 创建HTTP2服务器
|
// 创建HTTP2服务器
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// GitHub URL正则表达式
|
// GitHub URL正则表达式
|
||||||
var githubRegex = regexp.MustCompile(`https?://(?:github\.com|raw\.githubusercontent\.com|raw\.github\.com|gist\.githubusercontent\.com|gist\.github\.com|api\.github\.com)[^\s'"]+`)
|
var githubRegex = regexp.MustCompile(`(?:^|[\s'"(=,\[{;|&<>])https?://(?:github\.com|raw\.githubusercontent\.com|raw\.github\.com|gist\.githubusercontent\.com|gist\.github\.com|api\.github\.com)[^\s'")]*`)
|
||||||
|
|
||||||
// ProcessSmart Shell脚本智能处理函数
|
// ProcessSmart Shell脚本智能处理函数
|
||||||
func ProcessSmart(input io.ReadCloser, isCompressed bool, host string) (io.Reader, int64, error) {
|
func ProcessSmart(input io.ReadCloser, isCompressed bool, host string) (io.Reader, int64, error) {
|
||||||
@@ -70,8 +70,14 @@ func readShellContent(input io.ReadCloser, isCompressed bool) (string, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func processGitHubURLs(content, host string) string {
|
func processGitHubURLs(content, host string) string {
|
||||||
return githubRegex.ReplaceAllStringFunc(content, func(url string) string {
|
return githubRegex.ReplaceAllStringFunc(content, func(match string) string {
|
||||||
return transformURL(url, host)
|
// 如果匹配包含前缀分隔符,保留它,防止出现重复转换
|
||||||
|
if len(match) > 0 && match[0] != 'h' {
|
||||||
|
prefix := match[0:1]
|
||||||
|
url := match[1:]
|
||||||
|
return prefix + transformURL(url, host)
|
||||||
|
}
|
||||||
|
return transformURL(match, host)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -86,9 +92,12 @@ func transformURL(url, host string) string {
|
|||||||
} else if !strings.HasPrefix(url, "https://") && !strings.HasPrefix(url, "//") {
|
} else if !strings.HasPrefix(url, "https://") && !strings.HasPrefix(url, "//") {
|
||||||
url = "https://" + url
|
url = "https://" + url
|
||||||
}
|
}
|
||||||
cleanHost := strings.TrimPrefix(host, "https://")
|
|
||||||
cleanHost = strings.TrimPrefix(cleanHost, "http://")
|
|
||||||
cleanHost = strings.TrimSuffix(cleanHost, "/")
|
|
||||||
|
|
||||||
return cleanHost + "/" + url
|
// 确保 host 有协议头
|
||||||
}
|
if !strings.HasPrefix(host, "http://") && !strings.HasPrefix(host, "https://") {
|
||||||
|
host = "https://" + host
|
||||||
|
}
|
||||||
|
host = strings.TrimSuffix(host, "/")
|
||||||
|
|
||||||
|
return host + "/" + url
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user