aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/ui/syntax/syntaxedit.go
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2019-05-04 22:40:19 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2019-05-05 13:34:54 +0200
commit20f9b0386d62fa8df8835fec7238188ab87e792a (patch)
tree72a2ac5a937643459bc4c07a5b657557225ca177 /ui/syntax/syntaxedit.go
parentui: use more windows icons (diff)
downloadwireguard-windows-20f9b0386d62fa8df8835fec7238188ab87e792a.tar.xz
wireguard-windows-20f9b0386d62fa8df8835fec7238188ab87e792a.zip
ui: syntax: implement trafic blocking semantics
This is our "auto kill switch". Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'ui/syntax/syntaxedit.go')
-rw-r--r--ui/syntax/syntaxedit.go17
1 files changed, 15 insertions, 2 deletions
diff --git a/ui/syntax/syntaxedit.go b/ui/syntax/syntaxedit.go
index 5598d7a8..67e132c4 100644
--- a/ui/syntax/syntaxedit.go
+++ b/ui/syntax/syntaxedit.go
@@ -20,10 +20,17 @@ import "C"
type SyntaxEdit struct {
walk.WidgetBase
- textChangedPublisher walk.EventPublisher
- privateKeyPublisher walk.StringEventPublisher
+ textChangedPublisher walk.EventPublisher
+ privateKeyPublisher walk.StringEventPublisher
+ blockUntunneledTrafficPublisher walk.IntEventPublisher
}
+const (
+ InevaluableBlockingUntunneledTraffic = C.InevaluableBlockingUntunneledTraffic
+ BlockingUntunneledTraffic = C.BlockingUntunneledTraffic
+ NotBlockingUntunneledTraffic = C.NotBlockingUntunneledTraffic
+)
+
func (se *SyntaxEdit) LayoutFlags() walk.LayoutFlags {
return walk.GrowableHorz | walk.GrowableVert | walk.GreedyHorz | walk.GreedyVert
}
@@ -63,6 +70,10 @@ func (se *SyntaxEdit) PrivateKeyChanged() *walk.StringEvent {
return se.privateKeyPublisher.Event()
}
+func (se *SyntaxEdit) BlockUntunneledTrafficStateChanged() *walk.IntEvent {
+ return se.blockUntunneledTrafficPublisher.Event()
+}
+
func (se *SyntaxEdit) WndProc(hwnd win.HWND, msg uint32, wParam, lParam uintptr) uintptr {
switch msg {
case win.WM_NOTIFY, win.WM_COMMAND:
@@ -78,6 +89,8 @@ func (se *SyntaxEdit) WndProc(hwnd win.HWND, msg uint32, wParam, lParam uintptr)
} else {
se.privateKeyPublisher.Publish(C.GoString((*C.char)(unsafe.Pointer(lParam))))
}
+ case C.SE_TRAFFIC_BLOCK:
+ se.blockUntunneledTrafficPublisher.Publish(int(lParam))
}
return se.WidgetBase.WndProc(hwnd, msg, wParam, lParam)
}