aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/conf/store.go
diff options
context:
space:
mode:
Diffstat (limited to 'conf/store.go')
-rw-r--r--conf/store.go18
1 files changed, 8 insertions, 10 deletions
diff --git a/conf/store.go b/conf/store.go
index f6f450c6..02807b77 100644
--- a/conf/store.go
+++ b/conf/store.go
@@ -1,6 +1,6 @@
/* SPDX-License-Identifier: MIT
*
- * Copyright (C) 2019-2021 WireGuard LLC. All Rights Reserved.
+ * Copyright (C) 2019-2022 WireGuard LLC. All Rights Reserved.
*/
package conf
@@ -14,8 +14,10 @@ import (
"golang.zx2c4.com/wireguard/windows/conf/dpapi"
)
-const configFileSuffix = ".conf.dpapi"
-const configFileUnencryptedSuffix = ".conf"
+const (
+ configFileSuffix = ".conf.dpapi"
+ configFileUnencryptedSuffix = ".conf"
+)
func ListConfigNames() ([]string, error) {
configFileDir, err := tunnelConfigurationsDirectory()
@@ -29,8 +31,8 @@ func ListConfigNames() ([]string, error) {
configs := make([]string, len(files))
i := 0
for _, file := range files {
- name := filepath.Base(file.Name())
- if len(name) <= len(configFileSuffix) || !strings.HasSuffix(name, configFileSuffix) {
+ name, err := NameFromPath(file.Name())
+ if err != nil {
continue
}
if !file.Type().IsRegular() {
@@ -40,11 +42,7 @@ func ListConfigNames() ([]string, error) {
if err != nil {
continue
}
- if info.Mode().Perm()&0444 == 0 {
- continue
- }
- name = strings.TrimSuffix(name, configFileSuffix)
- if !TunnelNameIsValid(name) {
+ if info.Mode().Perm()&0o444 == 0 {
continue
}
configs[i] = name