Compare commits
14 Commits
v1.1.8
...
Rirmach/do
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4053481714 | ||
|
|
58097f865d | ||
|
|
3f614e8011 | ||
|
|
198a18508b | ||
|
|
780ac14a8f | ||
|
|
62b3cb6b70 | ||
|
|
714224bd29 | ||
|
|
7f6c46f0c8 | ||
|
|
fd9b0cf829 | ||
|
|
42ddfaab9d | ||
|
|
6144883a6e | ||
|
|
c704923b64 | ||
|
|
dcb502d3c8 | ||
|
|
a011d560c6 |
5
.github/demo/deepwiki.svg
vendored
Normal file
5
.github/demo/deepwiki.svg
vendored
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="90" height="28" role="img" aria-label="DeepWiki">
|
||||||
|
<title>DeepWiki</title>
|
||||||
|
<rect width="90" height="28" rx="4" fill="#0f766e"></rect>
|
||||||
|
<text x="45" y="19" fill="#fff" font-family="Arial, Helvetica, sans-serif" font-size="12" text-anchor="middle">DeepWiki</text>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 320 B |
BIN
.github/demo/demo1.jpg
vendored
Normal file
BIN
.github/demo/demo1.jpg
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 66 KiB |
BIN
.github/demo/demo2.jpg
vendored
Normal file
BIN
.github/demo/demo2.jpg
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 64 KiB |
BIN
.github/demo/demo3.jpg
vendored
Normal file
BIN
.github/demo/demo3.jpg
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 52 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
|
||||||
|
|
||||||
|
|||||||
18
README.md
18
README.md
@@ -2,8 +2,15 @@
|
|||||||
|
|
||||||
🚀 **Docker 和 GitHub 加速代理服务器**
|
🚀 **Docker 和 GitHub 加速代理服务器**
|
||||||
|
|
||||||
|
<p align="center">
|
||||||
|
<a href="https://deepwiki.com/sky22333/hubproxy">
|
||||||
|
<img src="./.github/demo/deepwiki.svg" alt="DeepWiki">
|
||||||
|
</a>
|
||||||
|
</p>
|
||||||
|
|
||||||
一个轻量级、高性能的多功能代理服务,提供 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>
|
||||||
@@ -42,7 +49,7 @@ docker run -d \
|
|||||||
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)
|
||||||
@@ -243,6 +250,15 @@ 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"
|
||||||
|
|||||||
@@ -46,19 +46,24 @@ blackList = [
|
|||||||
# 无认证: socks5://127.0.0.1:1080
|
# 无认证: socks5://127.0.0.1:1080
|
||||||
# 有认证: socks5://username:password@127.0.0.1:1080
|
# 有认证: socks5://username:password@127.0.0.1:1080
|
||||||
# 留空不使用代理
|
# 留空不使用代理
|
||||||
proxy = ""
|
proxy = ""
|
||||||
|
|
||||||
[download]
|
[download]
|
||||||
# 批量下载离线镜像数量限制
|
# 批量下载离线镜像数量限制
|
||||||
maxImages = 10
|
maxImages = 10
|
||||||
|
|
||||||
|
# Docker Hub 认证信息,留空则匿名拉取
|
||||||
|
[dockerHubAuth]
|
||||||
|
username = "" # e.g., user1
|
||||||
|
token = "" # e.g., dckr_pat_***
|
||||||
|
|
||||||
# Registry映射配置,支持多种镜像仓库上游
|
# Registry映射配置,支持多种镜像仓库上游
|
||||||
[registries]
|
[registries]
|
||||||
|
|
||||||
# GitHub Container Registry
|
# GitHub Container Registry
|
||||||
[registries."ghcr.io"]
|
[registries."ghcr.io"]
|
||||||
upstream = "ghcr.io"
|
upstream = "ghcr.io"
|
||||||
authHost = "ghcr.io/token"
|
authHost = "ghcr.io/token"
|
||||||
authType = "github"
|
authType = "github"
|
||||||
enabled = true
|
enabled = true
|
||||||
|
|
||||||
|
|||||||
@@ -48,6 +48,11 @@ type AppConfig struct {
|
|||||||
MaxImages int `toml:"maxImages"`
|
MaxImages int `toml:"maxImages"`
|
||||||
} `toml:"download"`
|
} `toml:"download"`
|
||||||
|
|
||||||
|
DockerHubAuth struct {
|
||||||
|
Username string `toml:"username"`
|
||||||
|
Token string `toml:"token"`
|
||||||
|
} `toml:"dockerHubAuth"`
|
||||||
|
|
||||||
Registries map[string]RegistryMapping `toml:"registries"`
|
Registries map[string]RegistryMapping `toml:"registries"`
|
||||||
|
|
||||||
TokenCache struct {
|
TokenCache struct {
|
||||||
@@ -108,6 +113,13 @@ func DefaultConfig() *AppConfig {
|
|||||||
}{
|
}{
|
||||||
MaxImages: 10,
|
MaxImages: 10,
|
||||||
},
|
},
|
||||||
|
DockerHubAuth: struct {
|
||||||
|
Username string `toml:"username"`
|
||||||
|
Token string `toml:"token"`
|
||||||
|
}{
|
||||||
|
Username: "",
|
||||||
|
Token: "",
|
||||||
|
},
|
||||||
Registries: map[string]RegistryMapping{
|
Registries: map[string]RegistryMapping{
|
||||||
"ghcr.io": {
|
"ghcr.io": {
|
||||||
Upstream: "ghcr.io",
|
Upstream: "ghcr.io",
|
||||||
|
|||||||
@@ -68,10 +68,18 @@ func InitDockerProxy() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
options := []remote.Option{
|
options := []remote.Option{
|
||||||
remote.WithAuth(authn.Anonymous),
|
|
||||||
remote.WithUserAgent("hubproxy/go-containerregistry"),
|
remote.WithUserAgent("hubproxy/go-containerregistry"),
|
||||||
remote.WithTransport(utils.GetGlobalHTTPClient().Transport),
|
remote.WithTransport(utils.GetGlobalHTTPClient().Transport),
|
||||||
}
|
}
|
||||||
|
dockerHubAuth := config.GetConfig().DockerHubAuth
|
||||||
|
if dockerHubAuth.Token != "" && dockerHubAuth.Username != "" {
|
||||||
|
options = append(options, remote.WithAuth(&authn.Basic{
|
||||||
|
Username: dockerHubAuth.Username,
|
||||||
|
Password: dockerHubAuth.Token,
|
||||||
|
}))
|
||||||
|
} else {
|
||||||
|
options = append(options, remote.WithAuth(authn.Anonymous))
|
||||||
|
}
|
||||||
|
|
||||||
dockerProxy = &DockerProxy{
|
dockerProxy = &DockerProxy{
|
||||||
registry: registry,
|
registry: registry,
|
||||||
|
|||||||
@@ -125,7 +125,7 @@ func main() {
|
|||||||
fmt.Printf("H2c: 已启用\n")
|
fmt.Printf("H2c: 已启用\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Printf("版本号: v1.1.8\n")
|
fmt.Printf("版本号: v1.1.9\n")
|
||||||
fmt.Printf("项目地址: https://github.com/sky22333/hubproxy\n")
|
fmt.Printf("项目地址: https://github.com/sky22333/hubproxy\n")
|
||||||
|
|
||||||
// 创建HTTP2服务器
|
// 创建HTTP2服务器
|
||||||
|
|||||||
@@ -77,18 +77,21 @@ func processGitHubURLs(content, host string) string {
|
|||||||
|
|
||||||
// transformURL URL转换函数
|
// transformURL URL转换函数
|
||||||
func transformURL(url, host string) string {
|
func transformURL(url, host string) string {
|
||||||
if strings.Contains(url, host) {
|
if strings.Contains(url, host) {
|
||||||
return url
|
return url
|
||||||
}
|
}
|
||||||
|
|
||||||
if strings.HasPrefix(url, "http://") {
|
if strings.HasPrefix(url, "http://") {
|
||||||
url = "https" + url[4:]
|
url = "https" + url[4:]
|
||||||
} 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