feat: add anonymous Zen support

This commit is contained in:
Jason Xu committed 2026-08-17 12:40:24 +08:00
1 parent fdae1902a0
commit 8e131dcf3b
10 files changed
+301 -51

No files matched your search

+3 -2
View File
@@ -19,6 +19,7 @@ type Config struct {
ServerKeys []string `json:"server_keys"`
ZenKeys []string `json:"zen_keys"`
GoKeys []string `json:"go_keys"`
Anonymous bool `json:"anonymous"`
Proxies []string `json:"proxies"`
ProxyFile string `json:"proxyfile"`
Upstream UpstreamConfig `json:"upstream"`
@@ -119,8 +120,8 @@ func NormalizeConfig(path string, cfg Config) (Config, error) {
if len(cfg.ServerKeys) == 0 {
return Config{}, errors.New("server_keys must contain at least one local key")
}
if len(cfg.ZenKeys) == 0 && len(cfg.GoKeys) == 0 {
return Config{}, errors.New("zen_keys or go_keys must contain at least one upstream key")
if !cfg.Anonymous && len(cfg.ZenKeys) == 0 && len(cfg.GoKeys) == 0 {
return Config{}, errors.New("zen_keys or go_keys must contain at least one upstream key unless anonymous is enabled")
}
if cfg.Retry.MaxAttempts < 1 {
return Config{}, errors.New("retry.max_attempts must be at least 1")