Release 3.8.2.12: export/import full server list as JSON.
Save and replace profiles via system file dialog; buttons after Best; prefs unchanged on import. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -629,6 +629,37 @@ func (m *Manager) DeleteProfile(name string) error {
|
||||
return config.Save(m.cfgPath, *m.cfg)
|
||||
}
|
||||
|
||||
// ExportServers writes the current profile list (with secrets) to path.
|
||||
func (m *Manager) ExportServers(path string) (int, error) {
|
||||
m.mu.Lock()
|
||||
defer m.mu.Unlock()
|
||||
return config.WriteServersFile(path, m.cfg)
|
||||
}
|
||||
|
||||
// ImportServersReplace replaces all profiles with those from path.
|
||||
// Prefs (system proxy, reconnect, subscription URL) are preserved.
|
||||
func (m *Manager) ImportServersReplace(path string) (int, error) {
|
||||
m.mu.Lock()
|
||||
defer m.mu.Unlock()
|
||||
if m.engine != nil && m.engine.Running() {
|
||||
return 0, fmt.Errorf("сначала отключитесь")
|
||||
}
|
||||
doc, err := config.ReadServersFile(path)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
if err := m.cfg.ApplyServersReplace(doc); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
for i := range m.cfg.Profiles {
|
||||
hysteria2.EnrichProfile(&m.cfg.Profiles[i])
|
||||
}
|
||||
if err := config.Save(m.cfgPath, *m.cfg); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return len(m.cfg.Profiles), nil
|
||||
}
|
||||
|
||||
func (m *Manager) Profiles() []config.ProfileInfo {
|
||||
m.mu.Lock()
|
||||
defer m.mu.Unlock()
|
||||
|
||||
Reference in New Issue
Block a user