feat(remote): 增加远端控制台与日志汇总导出

This commit is contained in:
yml
2026-11-21 20:07:40 +08:00
parent 79b503d1a6
commit d176c421a8
27 changed files with 3486 additions and 19 deletions
+28 -2
View File
@@ -65,8 +65,8 @@ func LoadSharedProxyConfig(path string) (types.SharedProxyConfig, error) {
shared.SchemaVersion, SharedProxyConfigSchemaVersion,
)
}
if !hasSharedProxySettings(shared.Proxy) {
return types.SharedProxyConfig{}, errors.New("共享代理配置中没有 proxy 设置")
if !hasSharedProxySettings(shared.Proxy) && !hasSharedRemoteSettings(shared.Remote) {
return types.SharedProxyConfig{}, errors.New("共享配置中没有 proxy 或 remote 设置")
}
return shared, nil
}
@@ -104,6 +104,19 @@ func ApplySharedProxyConfig(cfg *types.Config, shared types.SharedProxyConfig) {
if proxy.WhitelistSignKey != nil {
cfg.ProxyWhitelistSignKey = strings.TrimSpace(*proxy.WhitelistSignKey)
}
remote := shared.Remote
if remote.Enabled != nil {
cfg.RemoteEnabled = *remote.Enabled
}
if remote.URL != nil {
cfg.RemoteURL = strings.TrimSpace(*remote.URL)
}
if remote.Token != nil {
cfg.RemoteToken = strings.TrimSpace(*remote.Token)
}
if remote.MachineName != nil {
cfg.RemoteMachineName = strings.TrimSpace(*remote.MachineName)
}
normalizeProxyConfig(cfg)
}
@@ -127,6 +140,12 @@ func SaveSharedProxyConfig(path string, cfg types.Config) error {
WhitelistPassword: stringPointer(cfg.ProxyWhitelistPassword),
WhitelistSignKey: stringPointer(cfg.ProxyWhitelistSignKey),
},
Remote: types.SharedRemoteSettings{
Enabled: boolPointer(cfg.RemoteEnabled),
URL: stringPointer(cfg.RemoteURL),
Token: stringPointer(cfg.RemoteToken),
MachineName: stringPointer(cfg.RemoteMachineName),
},
}
data, err := json.MarshalIndent(shared, "", " ")
if err != nil {
@@ -179,6 +198,13 @@ func hasSharedProxySettings(proxy types.SharedProxySettings) bool {
proxy.WhitelistSignKey != nil
}
func hasSharedRemoteSettings(remote types.SharedRemoteSettings) bool {
return remote.Enabled != nil ||
remote.URL != nil ||
remote.Token != nil ||
remote.MachineName != nil
}
func boolPointer(value bool) *bool { return &value }
func intPointer(value int) *int { return &value }
func stringPointer(value string) *string { return &value }