diff options
Diffstat (limited to '')
-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) |