MCPcopy Create free account
hub / github.com/AandStep/ResultV / ImportConfig

Method ImportConfig

app.go:1332–1357  ·  view source on GitHub ↗

ImportConfig accepts both RESULTPROXY2: (password required) and the legacy RESULTPROXY: prefix (no password — surfaced with a warning). - For v2 payloads: pass the user-supplied password. Wrong password returns config.ErrWrongPassword. - For legacy payloads: the first call returns config.ErrLegacyP

(data, password string, allowLegacy bool)

Source from the content-addressed store, hash-verified

1330// so the UI can warn the user that the source export was unencrypted.
1331// The UI must re-call with allowLegacy=true once the user confirms.
1332func (a *App) ImportConfig(data, password string, allowLegacy bool) error {
1333 if a.config == nil {
1334 return fmt.Errorf("config manager not initialized")
1335 }
1336 imported, err := config.ImportConfig(data, password)
1337 if err != nil {
1338 if errors.Is(err, config.ErrLegacyPlaintext) {
1339 if !allowLegacy {
1340 // Bubble up so the UI can show the "unencrypted export" warning.
1341 return err
1342 }
1343 // User has acknowledged; fall through and apply.
1344 } else {
1345 a.log.Warning(fmt.Sprintf("Ошибка импорта: %v", err))
1346 return err
1347 }
1348 }
1349 existing := a.config.GetConfig()
1350 merged := config.MergeImport(existing, imported)
1351 if err := a.config.SaveConfig(merged); err != nil {
1352 return err
1353 }
1354 a.log.Success(fmt.Sprintf("Импортировано %d прокси", len(imported.Proxies)))
1355 wailsRuntime.EventsEmit(a.ctx, "config:updated", merged)
1356 return nil
1357}
1358
1359func (a *App) GetPlatform() string {
1360 return runtime.GOOS

Callers

nothing calls this directly

Calls 6

ImportConfigFunction · 0.92
MergeImportFunction · 0.92
SuccessMethod · 0.80
WarningMethod · 0.65
GetConfigMethod · 0.45
SaveConfigMethod · 0.45

Tested by

no test coverage detected