diff options
author | Steven Honson <steven@honson.id.au> | 2019-05-11 22:04:08 +1000 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2019-05-11 17:33:22 +0200 |
commit | c47b9596dd41f29c25c259ea733dc3cd5debc664 (patch) | |
tree | 374939792068b6eeb7d6cbf62a46f4e3b61a9036 /ui/editdialog.go | |
parent | ui: edit requires further information (diff) | |
download | wireguard-windows-c47b9596dd41f29c25c259ea733dc3cd5debc664.tar.xz wireguard-windows-c47b9596dd41f29c25c259ea733dc3cd5debc664.zip |
ui: tunnel cloning
Allows a tunnel to be cloned verbatim. It's not part of the toolbar or
with a shortcut, as it's a rather obscure action.
Signed-off-by: Steven Honson <steven@honson.id.au>
[zx2c4: removed from toolbar and shortcut]
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'ui/editdialog.go')
-rw-r--r-- | ui/editdialog.go | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/ui/editdialog.go b/ui/editdialog.go index ba868893..b4ed8ebe 100644 --- a/ui/editdialog.go +++ b/ui/editdialog.go @@ -27,7 +27,7 @@ type EditDialog struct { blockUntunneledTraficCheckGuard bool } -func runTunnelEditDialog(owner walk.Form, tunnel *service.Tunnel) *conf.Config { +func runTunnelEditDialog(owner walk.Form, tunnel *service.Tunnel, clone bool) *conf.Config { var ( title string name string @@ -35,14 +35,21 @@ func runTunnelEditDialog(owner walk.Form, tunnel *service.Tunnel) *conf.Config { dlg := &EditDialog{} + if tunnel == nil || clone { + title = "Create new tunnel" + } else { + title = "Edit tunnel" + } + if tunnel == nil { // Creating a new tunnel, create a new private key and use the default template - title = "Create new tunnel" pk, _ := conf.NewPrivateKey() dlg.config = conf.Config{Interface: conf.Interface{PrivateKey: *pk}} } else { - title = "Edit tunnel" name = tunnel.Name + if clone { + name += "-copy" + } dlg.config, _ = tunnel.StoredConfig() } @@ -107,7 +114,7 @@ func runTunnelEditDialog(owner walk.Form, tunnel *service.Tunnel) *conf.Config { dlg.syntaxEdit.BlockUntunneledTrafficStateChanged().Attach(dlg.onBlockUntunneledTrafficStateChanged) dlg.syntaxEdit.SetText(dlg.config.ToWgQuick()) - if tunnel != nil { + if tunnel != nil && !clone { dlg.nameEdit.SetFocus() //TODO: This works around a walk issue with scrolling in weird ways <https://github.com/lxn/walk/issues/505>. We should fix this in walk instead of here. dlg.Starting().Attach(func() { |