Compare commits

...

6 Commits
4.0.0 ... 4.1.0

Author SHA1 Message Date
WJQSERVER
3812b029cf Merge pull request #131 from WJQSERVER-STUDIO/dev
4.1.0
2025-06-17 17:05:42 +08:00
wjqserver
e629b5db47 4.1.0 2025-06-17 17:04:34 +08:00
wjqserver
e5bc171f25 4.1.0-rc.0 2025-06-17 16:43:51 +08:00
wjqserver
6eae638256 remove dev codes 2025-06-17 15:07:31 +08:00
wjqserver
3e03f47ef7 update deps rebuild 4.1.0-beta.0 2025-06-17 14:47:23 +08:00
wjqserver
eb113b4191 add docker login basic auth support 2025-06-17 14:45:14 +08:00
8 changed files with 44 additions and 9 deletions

View File

@@ -1,5 +1,19 @@
# 更新日志
4.1.0 - 2025-06-17
---
- ADD: 加入基于`basic auth`的docker鉴权支持
4.1.0-rc.0 - 2025-06-17
---
- PRE-RELEASE: 此版本是v4.1.0预发布版本,请勿在生产环境中使用;
- ADD: 加入基于`basic auth`的docker鉴权支持
4.1.0-beta.0 - 2025-06-17
---
- BETA-TEST: 此版本是v4.1.0的测试版本,请勿在生产环境中使用;
- ADD: 加入基于`basic auth`的docker鉴权支持
4.0.0 - 2025-06-16
---
- CHANGE: 移交到Touka框架

View File

@@ -1 +1 @@
4.0.0-rc.0
4.1.0-rc.0

View File

@@ -1 +1 @@
4.0.0
4.1.0

View File

@@ -169,10 +169,16 @@ type OutboundConfig struct {
[docker]
enabled = false
target = "ghcr" # ghcr/dockerhub
auth = false
[docker.credentials]
user1 = "testpass"
test = "test123"
*/
type DockerConfig struct {
Enabled bool `toml:"enabled"`
Target string `toml:"target"`
Enabled bool `toml:"enabled"`
Target string `toml:"target"`
Auth bool `toml:"auth"`
Credentials map[string]string `toml:"credentials"`
}
// LoadConfig 从 TOML 配置文件加载配置

View File

@@ -67,4 +67,8 @@ url = "socks5://127.0.0.1:1080" # "http://127.0.0.1:7890"
[docker]
enabled = false
target = "dockerhub" # ghcr/dockerhub/ custom
target = "dockerhub" # ghcr/dockerhub/ custom
auth = false
[docker.credentials]
user1 = "testpass"
test = "test123"

3
go.mod
View File

@@ -11,11 +11,12 @@ require (
require (
github.com/WJQSERVER-STUDIO/go-utils/limitreader v0.0.2
github.com/fenthope/bauth v0.0.1
github.com/fenthope/ikumi v0.0.2
github.com/fenthope/reco v0.0.3
github.com/fenthope/record v0.0.3
github.com/hashicorp/golang-lru/v2 v2.0.7
github.com/infinite-iroha/touka v0.2.4
github.com/infinite-iroha/touka v0.2.5
github.com/wjqserver/modembed v0.0.1
)

6
go.sum
View File

@@ -6,6 +6,8 @@ github.com/WJQSERVER-STUDIO/go-utils/limitreader v0.0.2 h1:8bBkKk6E2Zr+I5szL7gyc
github.com/WJQSERVER-STUDIO/go-utils/limitreader v0.0.2/go.mod h1:yPX8xuZH+py7eLJwOYj3VVI/4/Yuy5+x8Mhq8qezcPg=
github.com/WJQSERVER-STUDIO/httpc v0.7.0 h1:iHhqlxppJBjlmvsIjvLZKRbWXqSdbeSGGofjHGmqGJc=
github.com/WJQSERVER-STUDIO/httpc v0.7.0/go.mod h1:M7KNUZjjhCkzzcg9lBPs9YfkImI+7vqjAyjdA19+joE=
github.com/fenthope/bauth v0.0.1 h1:+4UIQshGx3mYD4L3f2S4MLZOi5PWU7fU5GK3wsZvwzE=
github.com/fenthope/bauth v0.0.1/go.mod h1:1fveTpgfR1p+WXQ8MXm9BfBCeNYi55j23jxCOGOvBSA=
github.com/fenthope/ikumi v0.0.2 h1:5oaSTf/Msp7M2O3o/X20omKWEQbFhX4KV0CVF21oCdk=
github.com/fenthope/ikumi v0.0.2/go.mod h1:IYbxzOGndZv/yRrbVMyV6dxh06X2wXCbfxrTRM1IruU=
github.com/fenthope/reco v0.0.3 h1:RmnQ0D9a8PWtwOODawitTe4BztTnS9wYwrDbipISNq4=
@@ -16,8 +18,8 @@ github.com/go-json-experiment/json v0.0.0-20250517221953-25912455fbc8 h1:o8UqXPI
github.com/go-json-experiment/json v0.0.0-20250517221953-25912455fbc8/go.mod h1:TiCD2a1pcmjd7YnhGH0f/zKNcCD06B029pHhzV23c2M=
github.com/hashicorp/golang-lru/v2 v2.0.7 h1:a+bsQ5rvGLjzHuww6tVxozPZFVghXaHOwFs4luLUK2k=
github.com/hashicorp/golang-lru/v2 v2.0.7/go.mod h1:QeFd9opnmA6QUJc5vARoKUSoFhyfM2/ZepoAG6RGpeM=
github.com/infinite-iroha/touka v0.2.4 h1:P1nmQYv4VEiTIahCw356VcFvpTFB9i11c31LeLh6WbM=
github.com/infinite-iroha/touka v0.2.4/go.mod h1:2MBPtsM+5ClIZ/E1mPEKx1Rb+KIndTwZlIa2CwRPV7A=
github.com/infinite-iroha/touka v0.2.5 h1:x7lcKk0MIHGrPb9TMmgC+nG57G4SeFGflwrta2Lz3jo=
github.com/infinite-iroha/touka v0.2.5/go.mod h1:2MBPtsM+5ClIZ/E1mPEKx1Rb+KIndTwZlIa2CwRPV7A=
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
github.com/wjqserver/modembed v0.0.1 h1:8ZDz7t9M5DLrUFlYgBUUmrMzxWsZPmHvOazkr/T2jEs=

10
main.go
View File

@@ -15,6 +15,8 @@ import (
"ghproxy/config"
"ghproxy/proxy"
"github.com/fenthope/bauth"
"ghproxy/weakcache"
"github.com/fenthope/ikumi"
@@ -362,6 +364,7 @@ func main() {
}
setupApi(cfg, r, version)
setupPages(cfg, r)
r.RedirectTrailingSlash = false
r.GET("/github.com/:user/:repo/releases/*filepath", func(c *touka.Context) {
c.Set("matcher", "releases")
@@ -411,7 +414,7 @@ func main() {
proxy.RoutingHandler(cfg)(c)
})
r.GET("/v2/", func(c *touka.Context) {
r.GET("/v2/", r.UseIf(cfg.Docker.Auth, bauth.BasicAuthForStatic(cfg.Docker.Credentials, "GHProxy Docker Proxy")), func(c *touka.Context) {
emptyJSON := "{}"
c.Header("Content-Type", "application/json")
c.Header("Content-Length", fmt.Sprint(len(emptyJSON)))
@@ -422,6 +425,11 @@ func main() {
c.Writer.Write([]byte(emptyJSON))
})
r.GET("/v2", func(c *touka.Context) {
// 重定向到 /v2/
c.Redirect(http.StatusMovedPermanently, "/v2/")
})
r.ANY("/v2/:target/:user/:repo/*filepath", func(c *touka.Context) {
proxy.GhcrWithImageRouting(cfg)(c)
})