mirror of
https://github.com/WJQSERVER-STUDIO/ghproxy.git
synced 2026-02-03 00:01:10 +08:00
25w39a
This commit is contained in:
parent
816b35654a
commit
d92424cb94
8 changed files with 70 additions and 19 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
|
@ -5,4 +5,5 @@ demo.toml
|
|||
list.json
|
||||
repos
|
||||
pages
|
||||
*_test
|
||||
*_test
|
||||
.*
|
||||
|
|
@ -1,5 +1,10 @@
|
|||
# 更新日志
|
||||
|
||||
25w39a - 2025-05-19
|
||||
---
|
||||
- PRE-RELEASE: 此版本是v3.3.3预发布版本,请勿在生产环境中使用;
|
||||
- CHANGE: 加入`senseClientDisconnection`与`async`配置项
|
||||
|
||||
3.3.2 - 2025-05-18
|
||||
---
|
||||
- CHANGE: 默认主题改为`design`
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
25w38a
|
||||
25w39a
|
||||
|
|
@ -34,14 +34,15 @@ debug = false
|
|||
*/
|
||||
|
||||
type ServerConfig struct {
|
||||
Port int `toml:"port"`
|
||||
Host string `toml:"host"`
|
||||
NetLib string `toml:"netlib"`
|
||||
SizeLimit int `toml:"sizeLimit"`
|
||||
MemLimit int64 `toml:"memLimit"`
|
||||
H2C bool `toml:"H2C"`
|
||||
Cors string `toml:"cors"`
|
||||
Debug bool `toml:"debug"`
|
||||
Port int `toml:"port"`
|
||||
Host string `toml:"host"`
|
||||
NetLib string `toml:"netlib"`
|
||||
SenseClientDisconnection bool `toml:"senseClientDisconnection"`
|
||||
SizeLimit int `toml:"sizeLimit"`
|
||||
MemLimit int64 `toml:"memLimit"`
|
||||
H2C bool `toml:"H2C"`
|
||||
Cors string `toml:"cors"`
|
||||
Debug bool `toml:"debug"`
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -98,6 +99,7 @@ type LogConfig struct {
|
|||
LogFilePath string `toml:"logFilePath"`
|
||||
MaxLogSize int `toml:"maxLogSize"`
|
||||
Level string `toml:"level"`
|
||||
Async bool `toml:"async"`
|
||||
HertZLogPath string `toml:"hertzLogPath"`
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
host = "0.0.0.0"
|
||||
port = 8080
|
||||
netlib = "netpoll" # "netpoll" / "std" "standard" "net/http" "net"
|
||||
senseClientDisconnection = false
|
||||
sizeLimit = 125 # MB
|
||||
memLimit = 0 # MB
|
||||
H2C = true
|
||||
|
|
@ -33,6 +34,7 @@ staticDir = "/data/www"
|
|||
logFilePath = "/data/ghproxy/log/ghproxy.log"
|
||||
maxLogSize = 5 # MB
|
||||
level = "info" # dump, debug, info, warn, error, none
|
||||
async = false
|
||||
hertzLogPath = "/data/ghproxy/log/hertz.log"
|
||||
|
||||
[auth]
|
||||
|
|
|
|||
5
go.mod
5
go.mod
|
|
@ -5,7 +5,7 @@ go 1.24.3
|
|||
require (
|
||||
github.com/BurntSushi/toml v1.5.0
|
||||
github.com/WJQSERVER-STUDIO/httpc v0.5.1
|
||||
github.com/WJQSERVER-STUDIO/logger v1.6.0
|
||||
github.com/WJQSERVER-STUDIO/logger v1.7.1
|
||||
github.com/cloudwego/hertz v0.10.0
|
||||
github.com/hertz-contrib/http2 v0.1.8
|
||||
golang.org/x/net v0.40.0
|
||||
|
|
@ -16,7 +16,7 @@ require github.com/WJQSERVER-STUDIO/go-utils/limitreader v0.0.2
|
|||
|
||||
require (
|
||||
github.com/WJQSERVER-STUDIO/go-utils/copyb v0.0.4 // indirect
|
||||
github.com/WJQSERVER-STUDIO/go-utils/log v0.0.2 // indirect
|
||||
github.com/WJQSERVER-STUDIO/go-utils/log v0.0.3 // indirect
|
||||
github.com/bytedance/gopkg v0.1.2 // indirect
|
||||
github.com/bytedance/sonic v1.13.2 // indirect
|
||||
github.com/bytedance/sonic/loader v0.2.4 // indirect
|
||||
|
|
@ -40,3 +40,4 @@ require (
|
|||
)
|
||||
|
||||
//replace github.com/WJQSERVER-STUDIO/httpc v0.5.1 => /data/github/WJQSERVER-STUDIO/httpc
|
||||
//replace github.com/WJQSERVER-STUDIO/logger v1.6.0 => /data/github/WJQSERVER-STUDIO/logger
|
||||
|
|
|
|||
8
go.sum
8
go.sum
|
|
@ -4,12 +4,12 @@ github.com/WJQSERVER-STUDIO/go-utils/copyb v0.0.4 h1:JLtFd00AdFg/TP+dtvIzLkdHwKU
|
|||
github.com/WJQSERVER-STUDIO/go-utils/copyb v0.0.4/go.mod h1:FZ6XE+4TKy4MOfX1xWKe6Rwsg0ucYFCdNh1KLvyKTfc=
|
||||
github.com/WJQSERVER-STUDIO/go-utils/limitreader v0.0.2 h1:8bBkKk6E2Zr+I5szL7gyc5f0DK8N9agIJCpM1Cqw2NE=
|
||||
github.com/WJQSERVER-STUDIO/go-utils/limitreader v0.0.2/go.mod h1:yPX8xuZH+py7eLJwOYj3VVI/4/Yuy5+x8Mhq8qezcPg=
|
||||
github.com/WJQSERVER-STUDIO/go-utils/log v0.0.2 h1:9CSf+V0ZQPl2ijC/g6v/ObemmhpKcikKVIodsaLExTA=
|
||||
github.com/WJQSERVER-STUDIO/go-utils/log v0.0.2/go.mod h1:j9Q+xnwpOfve7/uJnZ2izRQw6NNoXjvJHz7vUQAaLZE=
|
||||
github.com/WJQSERVER-STUDIO/go-utils/log v0.0.3 h1:t6nyLhmo9pSfVHm1Wu1WyLsTpXFSjSpQtVKqEDpiZ5Q=
|
||||
github.com/WJQSERVER-STUDIO/go-utils/log v0.0.3/go.mod h1:j9Q+xnwpOfve7/uJnZ2izRQw6NNoXjvJHz7vUQAaLZE=
|
||||
github.com/WJQSERVER-STUDIO/httpc v0.5.1 h1:+TKCPYBuj7PAHuiduGCGAqsHAa4QtsUfoVwRN777q64=
|
||||
github.com/WJQSERVER-STUDIO/httpc v0.5.1/go.mod h1:M7KNUZjjhCkzzcg9lBPs9YfkImI+7vqjAyjdA19+joE=
|
||||
github.com/WJQSERVER-STUDIO/logger v1.6.0 h1:xK2xV7hlkMXaWzvj4+cNoNWA+JfnJaHX6VU+RrPnr7Q=
|
||||
github.com/WJQSERVER-STUDIO/logger v1.6.0/go.mod h1:TICMsR7geROHBg6rxwkqUNGydo34XVsX93yeoxyfuyY=
|
||||
github.com/WJQSERVER-STUDIO/logger v1.7.1 h1:sAFsF3umimY0Vmue5WnGf1Qxvm/vlhK2srZakWVtlFU=
|
||||
github.com/WJQSERVER-STUDIO/logger v1.7.1/go.mod h1:cvP0XdFIMLtDWOZeKhklshzipkVU1zufsU4rKNfoM24=
|
||||
github.com/bytedance/gopkg v0.1.1/go.mod h1:576VvJ+eJgyCzdjS+c4+77QF3p7ubbtiKARP3TxducM=
|
||||
github.com/bytedance/gopkg v0.1.2 h1:8o2feYuxknDpN+O7kPwvSXfMEKfYvJYiA2K7aonoMEQ=
|
||||
github.com/bytedance/gopkg v0.1.2/go.mod h1:576VvJ+eJgyCzdjS+c4+77QF3p7ubbtiKARP3TxducM=
|
||||
|
|
|
|||
46
main.go
46
main.go
|
|
@ -121,6 +121,7 @@ func loadConfig() {
|
|||
|
||||
func setupLogger(cfg *config.Config) {
|
||||
var err error
|
||||
|
||||
err = logger.Init(cfg.Log.LogFilePath, cfg.Log.MaxLogSize)
|
||||
if err != nil {
|
||||
fmt.Printf("Failed to initialize logger: %v\n", err)
|
||||
|
|
@ -131,6 +132,8 @@ func setupLogger(cfg *config.Config) {
|
|||
fmt.Printf("Logger Level Error: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
logger.SetAsync(cfg.Log.Async)
|
||||
|
||||
fmt.Printf("Log Level: %s\n", cfg.Log.Level)
|
||||
logDebug("Config File Path: ", cfgfile)
|
||||
logDebug("Loaded config: %v\n", cfg)
|
||||
|
|
@ -401,13 +404,13 @@ func main() {
|
|||
r = server.New(
|
||||
server.WithH2C(true),
|
||||
server.WithHostPorts(addr),
|
||||
server.WithSenseClientDisconnection(true),
|
||||
server.WithSenseClientDisconnection(cfg.Server.SenseClientDisconnection),
|
||||
)
|
||||
r.AddProtocol("h2", factory.NewServerFactory())
|
||||
} else {
|
||||
r = server.New(
|
||||
server.WithHostPorts(addr),
|
||||
server.WithSenseClientDisconnection(true),
|
||||
server.WithSenseClientDisconnection(cfg.Server.SenseClientDisconnection),
|
||||
)
|
||||
}
|
||||
} else {
|
||||
|
|
@ -465,7 +468,44 @@ func main() {
|
|||
proxy.RoutingHandler(cfg, limiter, iplimiter)(ctx, c)
|
||||
})
|
||||
|
||||
r.Any("/v2/*filepath", func(ctx context.Context, c *app.RequestContext) {
|
||||
r.GET("/v2/", func(ctx context.Context, c *app.RequestContext) {
|
||||
proxy.GhcrRouting(cfg)(ctx, c)
|
||||
|
||||
/*
|
||||
//proxy.GhcrRouting(cfg)(ctx, c)
|
||||
// 返回200与空json
|
||||
//c.JSON(200, map[string]interface{}{})
|
||||
emptyJSON := "{}"
|
||||
//emptyJSON := `{"name":"disable-list-tags","tags":[]}`
|
||||
c.Header("Content-Type", "application/json")
|
||||
c.Header("Content-Length", fmt.Sprint(len(emptyJSON)))
|
||||
c.String(200, emptyJSON)
|
||||
*/
|
||||
/*
|
||||
emptyJSON := "{}"
|
||||
c.Header("Content-Type", "application/json")
|
||||
c.Header("Content-Length", fmt.Sprint(len(emptyJSON)))
|
||||
|
||||
c.Header("Docker-Distribution-API-Version", "registry/2.0")
|
||||
|
||||
c.Status(200)
|
||||
c.Write([]byte(emptyJSON))
|
||||
*/
|
||||
|
||||
/*
|
||||
w := adaptor.GetCompatResponseWriter(&c.Response)
|
||||
|
||||
const emptyJSON = "{}"
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.Header().Set("Content-Length", fmt.Sprint(len(emptyJSON)))
|
||||
w.Header().Del("Server")
|
||||
|
||||
fmt.Fprint(w, emptyJSON)
|
||||
*/
|
||||
|
||||
})
|
||||
|
||||
r.Any("/v2/:target/*filepath", func(ctx context.Context, c *app.RequestContext) {
|
||||
proxy.GhcrRouting(cfg)(ctx, c)
|
||||
})
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue