aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/ui/syntax/syntaxedit.go
diff options
context:
space:
mode:
Diffstat (limited to 'ui/syntax/syntaxedit.go')
-rw-r--r--ui/syntax/syntaxedit.go50
1 files changed, 29 insertions, 21 deletions
diff --git a/ui/syntax/syntaxedit.go b/ui/syntax/syntaxedit.go
index 26cd533f..a3c94d86 100644
--- a/ui/syntax/syntaxedit.go
+++ b/ui/syntax/syntaxedit.go
@@ -1,6 +1,6 @@
/* SPDX-License-Identifier: MIT
*
- * Copyright (C) 2019-2021 WireGuard LLC. All Rights Reserved.
+ * Copyright (C) 2019-2022 WireGuard LLC. All Rights Reserved.
*/
package syntax
@@ -90,26 +90,29 @@ type spanStyle struct {
}
var stylemap = map[highlight]spanStyle{
- highlightSection: spanStyle{color: win.RGB(0x32, 0x6D, 0x74), effects: win.CFE_BOLD},
- highlightField: spanStyle{color: win.RGB(0x9B, 0x23, 0x93), effects: win.CFE_BOLD},
- highlightPrivateKey: spanStyle{color: win.RGB(0x64, 0x38, 0x20)},
- highlightPublicKey: spanStyle{color: win.RGB(0x64, 0x38, 0x20)},
- highlightPresharedKey: spanStyle{color: win.RGB(0x64, 0x38, 0x20)},
- highlightIP: spanStyle{color: win.RGB(0x0E, 0x0E, 0xFF)},
- highlightCidr: spanStyle{color: win.RGB(0x81, 0x5F, 0x03)},
- highlightHost: spanStyle{color: win.RGB(0x0E, 0x0E, 0xFF)},
- highlightPort: spanStyle{color: win.RGB(0x81, 0x5F, 0x03)},
- highlightMTU: spanStyle{color: win.RGB(0x1C, 0x00, 0xCF)},
- highlightKeepalive: spanStyle{color: win.RGB(0x1C, 0x00, 0xCF)},
- highlightComment: spanStyle{color: win.RGB(0x53, 0x65, 0x79), effects: win.CFE_ITALIC},
- highlightDelimiter: spanStyle{color: win.RGB(0x00, 0x00, 0x00)},
- highlightCmd: spanStyle{color: win.RGB(0x63, 0x75, 0x89)},
- highlightError: spanStyle{color: win.RGB(0xC4, 0x1A, 0x16), effects: win.CFE_UNDERLINE},
+ highlightSection: {color: win.RGB(0x32, 0x6D, 0x74), effects: win.CFE_BOLD},
+ highlightField: {color: win.RGB(0x9B, 0x23, 0x93), effects: win.CFE_BOLD},
+ highlightPrivateKey: {color: win.RGB(0x64, 0x38, 0x20)},
+ highlightPublicKey: {color: win.RGB(0x64, 0x38, 0x20)},
+ highlightPresharedKey: {color: win.RGB(0x64, 0x38, 0x20)},
+ highlightIP: {color: win.RGB(0x0E, 0x0E, 0xFF)},
+ highlightCidr: {color: win.RGB(0x81, 0x5F, 0x03)},
+ highlightHost: {color: win.RGB(0x0E, 0x0E, 0xFF)},
+ highlightPort: {color: win.RGB(0x81, 0x5F, 0x03)},
+ highlightMTU: {color: win.RGB(0x1C, 0x00, 0xCF)},
+ highlightTable: {color: win.RGB(0x1C, 0x00, 0xCF)},
+ highlightKeepalive: {color: win.RGB(0x1C, 0x00, 0xCF)},
+ highlightComment: {color: win.RGB(0x53, 0x65, 0x79), effects: win.CFE_ITALIC},
+ highlightDelimiter: {color: win.RGB(0x00, 0x00, 0x00)},
+ highlightCmd: {color: win.RGB(0x63, 0x75, 0x89)},
+ highlightError: {color: win.RGB(0xC4, 0x1A, 0x16), effects: win.CFE_UNDERLINE},
}
func (se *SyntaxEdit) evaluateUntunneledBlocking(cfg string, spans []highlightSpan) {
state := InevaluableBlockingUntunneledTraffic
var onAllowedIPs,
+ onTable,
+ tableOff,
seenPeer,
seen00v6,
seen00v4,
@@ -132,10 +135,13 @@ func (se *SyntaxEdit) evaluateUntunneledBlocking(cfg string, spans []highlightSp
} else {
goto done
}
- break
case highlightField:
onAllowedIPs = strings.EqualFold(cfg[span.s:span.s+span.len], "AllowedIPs")
- break
+ onTable = strings.EqualFold(cfg[span.s:span.s+span.len], "Table")
+ case highlightTable:
+ if onTable {
+ tableOff = cfg[span.s:span.s+span.len] == "off"
+ }
case highlightIP:
if !onAllowedIPs || !seenPeer {
break
@@ -166,9 +172,11 @@ func (se *SyntaxEdit) evaluateUntunneledBlocking(cfg string, spans []highlightSp
seen80001v6 = true
}
}
- break
}
}
+ if tableOff {
+ return
+ }
if seen00v4 || seen00v6 {
state = BlockingUntunneledTraffic
@@ -469,10 +477,10 @@ func NewSyntaxEdit(parent walk.Container) (*SyntaxEdit, error) {
se.GraphicsEffects().Add(walk.InteractionEffect)
se.GraphicsEffects().Add(walk.FocusEffect)
se.MustRegisterProperty("Text", walk.NewProperty(
- func() interface{} {
+ func() any {
return se.Text()
},
- func(v interface{}) error {
+ func(v any) error {
if s, ok := v.(string); ok {
return se.SetText(s)
}