aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2019-05-05 15:13:08 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2019-05-05 15:13:08 +0200
commita493883070b1f7a842ddc1e3d1583c1922c4b6d0 (patch)
tree7dd2ee81ae85dfa087c3ed076fb4861bdcdd8e91
parentui: improve update logging and tray logic (diff)
downloadwireguard-windows-a493883070b1f7a842ddc1e3d1583c1922c4b6d0.tar.xz
wireguard-windows-a493883070b1f7a842ddc1e3d1583c1922c4b6d0.zip
ui: check for duplicate names always
-rw-r--r--ui/editdialog.go22
1 files changed, 9 insertions, 13 deletions
diff --git a/ui/editdialog.go b/ui/editdialog.go
index 77a044a0..724d40f3 100644
--- a/ui/editdialog.go
+++ b/ui/editdialog.go
@@ -22,7 +22,6 @@ type EditDialog struct {
syntaxEdit *syntax.SyntaxEdit
blockUntunneledTrafficCB *walk.CheckBox
saveButton *walk.PushButton
- tunnel *service.Tunnel
config conf.Config
lastPrivateKey string
blockUntunneledTraficCheckGuard bool
@@ -34,7 +33,7 @@ func runTunnelEditDialog(owner walk.Form, tunnel *service.Tunnel) *conf.Config {
name string
)
- dlg := &EditDialog{tunnel: tunnel}
+ dlg := &EditDialog{}
if tunnel == nil {
// Creating a new tunnel, create a new private key and use the default template
@@ -250,19 +249,16 @@ func (dlg *EditDialog) onSaveButtonClicked() {
return
}
- if dlg.tunnel != nil && dlg.tunnel.Name != newName {
- names, err := conf.ListConfigNames()
- if err != nil {
- walk.MsgBox(dlg, "Unable to list existing tunnels", err.Error(), walk.MsgBoxIconError)
+ names, err := conf.ListConfigNames()
+ if err != nil {
+ walk.MsgBox(dlg, "Unable to list existing tunnels", err.Error(), walk.MsgBoxIconError)
+ return
+ }
+ for _, name := range names {
+ if strings.ToLower(name) == strings.ToLower(newName) {
+ walk.MsgBox(dlg, "Tunnel already exists", fmt.Sprintf("Another tunnel already exists with the name ā€˜%sā€™.", newName), walk.MsgBoxIconWarning)
return
}
-
- for _, name := range names {
- if strings.ToLower(name) == strings.ToLower(newName) {
- walk.MsgBox(dlg, "Invalid configuration", fmt.Sprintf("Another tunnel already exists with the name ā€˜%sā€™.", newName), walk.MsgBoxIconWarning)
- return
- }
- }
}
cfg, err := conf.FromWgQuick(dlg.syntaxEdit.Text(), newName)