diff options
Diffstat (limited to '')
-rw-r--r-- | ui/confview.go | 53 |
1 files changed, 47 insertions, 6 deletions
diff --git a/ui/confview.go b/ui/confview.go index e34d81b1..78e4df91 100644 --- a/ui/confview.go +++ b/ui/confview.go @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: MIT * - * Copyright (C) 2019 WireGuard LLC. All Rights Reserved. + * Copyright (C) 2019-2022 WireGuard LLC. All Rights Reserved. */ package ui @@ -50,6 +50,8 @@ type interfaceView struct { mtu *labelTextLine addresses *labelTextLine dns *labelTextLine + scripts *labelTextLine + table *labelTextLine toggleActive *toggleActiveLine lines []widgetsLine } @@ -305,6 +307,8 @@ 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}, + {l18n.Sprintf("Table:"), &iv.table}, } if iv.lines, err = createLabelTextLines(items, parent, &disposables); err != nil { return nil, err @@ -364,7 +368,11 @@ func (iv *interfaceView) widgetsLines() []widgetsLine { } func (iv *interfaceView) apply(c *conf.Interface) { - iv.publicKey.show(c.PrivateKey.Public().String()) + if IsAdmin { + iv.publicKey.show(c.PrivateKey.Public().String()) + } else { + iv.publicKey.hide() + } if c.ListenPort > 0 { iv.listenPort.show(strconv.Itoa(int(c.ListenPort))) @@ -398,6 +406,35 @@ 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() + } + + if c.TableOff { + iv.table.show(l18n.Sprintf("off")) + } else { + iv.table.hide() + } } func (pv *peerView) widgetsLines() []widgetsLine { @@ -405,9 +442,13 @@ func (pv *peerView) widgetsLines() []widgetsLine { } func (pv *peerView) apply(c *conf.Peer) { - pv.publicKey.show(c.PublicKey.String()) + if IsAdmin { + pv.publicKey.show(c.PublicKey.String()) + } else { + pv.publicKey.hide() + } - if !c.PresharedKey.IsZero() { + if !c.PresharedKey.IsZero() && IsAdmin { pv.presharedKey.show(l18n.Sprintf("enabled")) } else { pv.presharedKey.hide() @@ -564,7 +605,7 @@ func (cv *ConfView) onToggleActiveClicked() { }() } -func (cv *ConfView) onTunnelChanged(tunnel *manager.Tunnel, state manager.TunnelState, globalState manager.TunnelState, err error) { +func (cv *ConfView) onTunnelChanged(tunnel *manager.Tunnel, state, globalState manager.TunnelState, err error) { cv.Synchronize(func() { cv.interfaze.toggleActive.updateGlobal(globalState) if cv.tunnel != nil && cv.tunnel.Name == tunnel.Name { @@ -587,7 +628,7 @@ func (cv *ConfView) onTunnelChanged(tunnel *manager.Tunnel, state manager.Tunnel } func (cv *ConfView) SetTunnel(tunnel *manager.Tunnel) { - cv.tunnel = tunnel //XXX: This races with the read in the updateTicker, but it's pointer-sized! + cv.tunnel = tunnel // XXX: This races with the read in the updateTicker, but it's pointer-sized! var config conf.Config var state manager.TunnelState |