diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2019-05-05 15:13:08 +0200 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2019-05-05 15:13:08 +0200 |
commit | 54229f73bc3a1e6a88168183a9cf9f62b07476c2 (patch) | |
tree | 7dd2ee81ae85dfa087c3ed076fb4861bdcdd8e91 | |
parent | ui: improve update logging and tray logic (diff) | |
download | wireguard-windows-54229f73bc3a1e6a88168183a9cf9f62b07476c2.tar.xz wireguard-windows-54229f73bc3a1e6a88168183a9cf9f62b07476c2.zip |
ui: check for duplicate names always
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
-rw-r--r-- | ui/editdialog.go | 22 |
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) |