From 7fc09f8ed1431f5e7584e56cbf64258d62a62961 Mon Sep 17 00:00:00 2001 From: Owen Date: Sat, 8 Nov 2025 20:39:36 -0800 Subject: [PATCH] Fix windows build Former-commit-id: 6af69cdcd6889bcf78971d02cfc3923c956b7ac4 --- go.mod | 7 ++++--- go.sum | 2 ++ main.go | 13 +++++++++---- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/go.mod b/go.mod index 5107cd6..e6ae7f2 100644 --- a/go.mod +++ b/go.mod @@ -3,20 +3,21 @@ module github.com/fosrl/olm go 1.25 require ( + github.com/Microsoft/go-winio v0.6.2 github.com/fosrl/newt v0.0.0-20250929233849-71c5bf7e65f7 + github.com/gorilla/websocket v1.5.3 github.com/vishvananda/netlink v1.3.1 golang.org/x/crypto v0.43.0 golang.org/x/exp v0.0.0-20250718183923-645b1fa84792 + golang.org/x/net v0.45.0 golang.org/x/sys v0.37.0 golang.zx2c4.com/wireguard v0.0.0-20250521234502-f333402bd9cb golang.zx2c4.com/wireguard/wgctrl v0.0.0-20241231184526-a9ab2273dd10 + software.sslmate.com/src/go-pkcs12 v0.6.0 ) require ( - github.com/gorilla/websocket v1.5.3 // indirect github.com/vishvananda/netns v0.0.5 // indirect - golang.org/x/net v0.45.0 // indirect golang.zx2c4.com/wintun v0.0.0-20230126152724-0fa3db229ce2 // indirect gvisor.dev/gvisor v0.0.0-20250718192347-d7830d968c56 // indirect - software.sslmate.com/src/go-pkcs12 v0.6.0 // indirect ) diff --git a/go.sum b/go.sum index 17ce82d..88dc4e7 100644 --- a/go.sum +++ b/go.sum @@ -1,3 +1,5 @@ +github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY= +github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU= github.com/fosrl/newt v0.0.0-20250929233849-71c5bf7e65f7 h1:6bSU8Efyhx1SR53iSw1Wjk5V8vDfizGAudq/GlE9b+o= github.com/fosrl/newt v0.0.0-20250929233849-71c5bf7e65f7/go.mod h1:Ac0k2FmAMC+hu21rAK+p7EnnEGrqKO/QZuGTVHA/XDM= github.com/google/btree v1.1.3 h1:CVpQJjYgC4VbzxeGVHfvZrv1ctoYCAI8vbl07Fcxlyg= diff --git a/main.go b/main.go index 77373b6..5fc8dd7 100644 --- a/main.go +++ b/main.go @@ -153,6 +153,15 @@ func main() { } } + // Create a context that will be cancelled on interrupt signals + ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM) + defer stop() + + // Run in console mode + runOlmMainWithArgs(ctx, os.Args[1:]) +} + +func runOlmMainWithArgs(ctx context.Context, args []string) { // Setup Windows event logging if on Windows if runtime.GOOS != "windows" { setupWindowsEventLog() @@ -212,9 +221,5 @@ func main() { // DoNotCreateNewClient: config.DoNotCreateNewClient, } - // Create a context that will be cancelled on interrupt signals - ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM) - defer stop() - olm.Run(ctx, olmConfig) }