diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2020-11-21 15:45:08 +0100 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2020-11-22 22:00:32 +0100 |
commit | 224336aa077020c35d3feb8a534f92c814b232e9 (patch) | |
tree | a6b366f7061ba69c31138b1961f30994b9dfc38e /ui | |
parent | conf: allow administrators to add and remove configs easily (diff) | |
download | wireguard-windows-224336aa077020c35d3feb8a534f92c814b232e9.tar.xz wireguard-windows-224336aa077020c35d3feb8a534f92c814b232e9.zip |
tunnel: enable {Pre,Post}{Up,Down} scripts gated behind admin knob
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'ui')
-rw-r--r-- | ui/confview.go | 25 | ||||
-rw-r--r-- | ui/syntax/highlighter.go | 4 |
2 files changed, 26 insertions, 3 deletions
diff --git a/ui/confview.go b/ui/confview.go index 089f6572..c712c29d 100644 --- a/ui/confview.go +++ b/ui/confview.go @@ -50,6 +50,7 @@ type interfaceView struct { mtu *labelTextLine addresses *labelTextLine dns *labelTextLine + scripts *labelTextLine toggleActive *toggleActiveLine lines []widgetsLine } @@ -305,6 +306,7 @@ func newInterfaceView(parent walk.Container) (*interfaceView, error) { {l18n.Sprintf("MTU:"), &iv.mtu}, {l18n.Sprintf("Addresses:"), &iv.addresses}, {l18n.Sprintf("DNS servers:"), &iv.dns}, + {l18n.Sprintf("Scripts:"), &iv.scripts}, } if iv.lines, err = createLabelTextLines(items, parent, &disposables); err != nil { return nil, err @@ -402,6 +404,29 @@ func (iv *interfaceView) apply(c *conf.Interface) { } else { iv.dns.hide() } + + var scriptsInUse []string + if len(c.PreUp) > 0 { + scriptsInUse = append(scriptsInUse, l18n.Sprintf("pre-up")) + } + if len(c.PostUp) > 0 { + scriptsInUse = append(scriptsInUse, l18n.Sprintf("post-up")) + } + if len(c.PreDown) > 0 { + scriptsInUse = append(scriptsInUse, l18n.Sprintf("pre-down")) + } + if len(c.PostDown) > 0 { + scriptsInUse = append(scriptsInUse, l18n.Sprintf("post-down")) + } + if len(scriptsInUse) > 0 { + if conf.AdminBool("DangerousScriptExecution") { + iv.scripts.show(strings.Join(scriptsInUse, l18n.EnumerationSeparator())) + } else { + iv.scripts.show(l18n.Sprintf("disabled, per policy")) + } + } else { + iv.scripts.hide() + } } func (pv *peerView) widgetsLines() []widgetsLine { diff --git a/ui/syntax/highlighter.go b/ui/syntax/highlighter.go index fa6a6530..f6edc712 100644 --- a/ui/syntax/highlighter.go +++ b/ui/syntax/highlighter.go @@ -405,8 +405,6 @@ func (s stringSpan) field() field { return fieldEndpoint case s.isCaselessSame("PersistentKeepalive"): return fieldPersistentKeepalive - } - /* TODO: uncomment this once we support these in the client case s.isCaselessSame("PreUp"): return fieldPreUp case s.isCaselessSame("PostUp"): @@ -415,7 +413,7 @@ func (s stringSpan) field() field { return fieldPreDown case s.isCaselessSame("PostDown"): return fieldPostDown - */ + } return fieldInvalid } |