mirror of
https://github.com/WJQSERVER-STUDIO/ghproxy.git
synced 2026-02-03 08:11:11 +08:00
add customTarget
This commit is contained in:
parent
4ded2186d8
commit
052243b095
3 changed files with 17 additions and 9 deletions
|
|
@ -174,10 +174,12 @@ type OutboundConfig struct {
|
||||||
[docker]
|
[docker]
|
||||||
enabled = false
|
enabled = false
|
||||||
target = "ghcr" # ghcr/dockerhub
|
target = "ghcr" # ghcr/dockerhub
|
||||||
|
customTarget = "" # 自定义host(不带协议头)
|
||||||
*/
|
*/
|
||||||
type DockerConfig struct {
|
type DockerConfig struct {
|
||||||
Enabled bool `toml:"enabled"`
|
Enabled bool `toml:"enabled"`
|
||||||
Target string `toml:"target"`
|
Target string `toml:"target"`
|
||||||
|
CustomTarget string `toml:"customTarget"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// LoadConfig 从 TOML 配置文件加载配置
|
// LoadConfig 从 TOML 配置文件加载配置
|
||||||
|
|
|
||||||
|
|
@ -71,3 +71,4 @@ url = "socks5://127.0.0.1:1080" # "http://127.0.0.1:7890"
|
||||||
[docker]
|
[docker]
|
||||||
enabled = false
|
enabled = false
|
||||||
target = "ghcr" # ghcr/dockerhub
|
target = "ghcr" # ghcr/dockerhub
|
||||||
|
customTarget = "" # 自定义host(不带协议头)
|
||||||
|
|
@ -14,6 +14,7 @@ import (
|
||||||
func GhcrRouting(cfg *config.Config) app.HandlerFunc {
|
func GhcrRouting(cfg *config.Config) app.HandlerFunc {
|
||||||
return func(ctx context.Context, c *app.RequestContext) {
|
return func(ctx context.Context, c *app.RequestContext) {
|
||||||
if cfg.Docker.Enabled {
|
if cfg.Docker.Enabled {
|
||||||
|
if cfg.Docker.CustomTarget == "" {
|
||||||
if cfg.Docker.Target == "ghcr" {
|
if cfg.Docker.Target == "ghcr" {
|
||||||
GhcrRequest(ctx, c, "https://ghcr.io"+string(c.Request.RequestURI()), cfg, "ghcr")
|
GhcrRequest(ctx, c, "https://ghcr.io"+string(c.Request.RequestURI()), cfg, "ghcr")
|
||||||
} else if cfg.Docker.Target == "dockerhub" {
|
} else if cfg.Docker.Target == "dockerhub" {
|
||||||
|
|
@ -22,6 +23,10 @@ func GhcrRouting(cfg *config.Config) app.HandlerFunc {
|
||||||
ErrorPage(c, NewErrorWithStatusLookup(403, "Docker Target is not Allowed"))
|
ErrorPage(c, NewErrorWithStatusLookup(403, "Docker Target is not Allowed"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
GhcrRequest(ctx, c, "https://"+cfg.Docker.CustomTarget+string(c.Request.RequestURI()), cfg, "custom")
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
ErrorPage(c, NewErrorWithStatusLookup(403, "Docker is not Allowed"))
|
ErrorPage(c, NewErrorWithStatusLookup(403, "Docker is not Allowed"))
|
||||||
return
|
return
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue