aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2020-11-26 13:13:44 +0100
committerJason A. Donenfeld <Jason@zx2c4.com>2020-11-27 12:50:53 +0100
commit10678f4ba3fc5165a0215029aa4ceeed3a297dca (patch)
tree9ea8fb434b086b0ab4ce226a667fd8b133163ccb
parentconf: rework migration flows around a single Save() (diff)
downloadwireguard-windows-10678f4ba3fc5165a0215029aa4ceeed3a297dca.tar.xz
wireguard-windows-10678f4ba3fc5165a0215029aa4ceeed3a297dca.zip
manager: move legacy store from conf
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
-rw-r--r--conf/path_windows.go3
-rw-r--r--conf/store.go4
-rw-r--r--manager/legacystore.go (renamed from conf/legacy_windows.go)9
-rw-r--r--manager/service.go2
4 files changed, 6 insertions, 12 deletions
diff --git a/conf/path_windows.go b/conf/path_windows.go
index d1ce07cc..9bda7918 100644
--- a/conf/path_windows.go
+++ b/conf/path_windows.go
@@ -19,7 +19,6 @@ import (
var cachedConfigFileDir string
var cachedRootDir string
-var disableAutoMigration bool
func tunnelConfigurationsDirectory() (string, error) {
if cachedConfigFileDir != "" {
@@ -35,7 +34,6 @@ func tunnelConfigurationsDirectory() (string, error) {
return "", err
}
cachedConfigFileDir = c
- moveConfigsFromLegacyStore()
return cachedConfigFileDir, nil
}
@@ -44,7 +42,6 @@ func tunnelConfigurationsDirectory() (string, error) {
// consumers of our libraries who might want to do strange things.
func PresetRootDirectory(root string) {
cachedRootDir = root
- disableAutoMigration = true
}
func RootDirectory(create bool) (string, error) {
diff --git a/conf/store.go b/conf/store.go
index 9a0f8c7d..5cc2ce46 100644
--- a/conf/store.go
+++ b/conf/store.go
@@ -132,10 +132,6 @@ func LoadFromName(name string) (*Config, error) {
}
func LoadFromPath(path string) (*Config, error) {
- if !disableAutoMigration {
- tunnelConfigurationsDirectory() // Provoke migrations, if needed.
- }
-
name, err := NameFromPath(path)
if err != nil {
return nil, err
diff --git a/conf/legacy_windows.go b/manager/legacystore.go
index ea8513cb..faa2b844 100644
--- a/conf/legacy_windows.go
+++ b/manager/legacystore.go
@@ -3,7 +3,7 @@
* Copyright (C) 2019-2020 WireGuard LLC. All Rights Reserved.
*/
-package conf
+package manager
import (
"fmt"
@@ -16,12 +16,11 @@ import (
"golang.org/x/sys/windows"
"golang.org/x/sys/windows/registry"
"golang.org/x/sys/windows/svc/mgr"
+
+ "golang.zx2c4.com/wireguard/windows/conf"
)
func moveConfigsFromLegacyStore() {
- if disableAutoMigration {
- return
- }
oldRoot, err := windows.KnownFolderPath(windows.FOLDERID_LocalAppData, windows.KF_FLAG_DEFAULT)
if err != nil {
return
@@ -50,7 +49,7 @@ func moveConfigsFromLegacyStore() {
if pendingDeletion[strings.ToLower(oldPath)] {
continue
}
- config, err := LoadFromPath(oldPath)
+ config, err := conf.LoadFromPath(oldPath)
if err != nil {
continue
}
diff --git a/manager/service.go b/manager/service.go
index 5ae8c9df..9044d9fb 100644
--- a/manager/service.go
+++ b/manager/service.go
@@ -77,6 +77,8 @@ func (service *managerService) Execute(args []string, r <-chan svc.ChangeRequest
return
}
+ moveConfigsFromLegacyStore()
+
err = trackExistingTunnels()
if err != nil {
serviceError = services.ErrorTrackTunnels