Skip to content

Commit e91ba82

Browse files
committed
fixup! chore: get TUN/DNS working on Windows for CoderVPN
1 parent a7154ac commit e91ba82

File tree

4 files changed

+11
-10
lines changed

4 files changed

+11
-10
lines changed

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ require (
423423
go.opentelemetry.io/proto/otlp v1.4.0 // indirect
424424
go4.org/mem v0.0.0-20220726221520-4f986261bf13 // indirect
425425
golang.org/x/time v0.9.0 // indirect
426-
golang.zx2c4.com/wintun v0.0.0-20230126152724-0fa3db229ce2 // indirect
426+
golang.zx2c4.com/wintun v0.0.0-20230126152724-0fa3db229ce2
427427
golang.zx2c4.com/wireguard/wgctrl v0.0.0-20230429144221-925a1e7659e6 // indirect
428428
golang.zx2c4.com/wireguard/windows v0.5.3 // indirect
429429
google.golang.org/appengine v1.6.8 // indirect

vpn/tun.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ package vpn
55
import "cdr.dev/slog"
66

77
// This is a no-op on every platform except Darwin and Windows.
8-
func GetNetworkingStack(t *Tunnel, req *StartRequest, logger slog.Logger) (NetworkStack, error) {
8+
func GetNetworkingStack(_ *Tunnel, _ *StartRequest, _ slog.Logger) (NetworkStack, error) {
99
return NetworkStack{}, nil
1010
}

vpn/tun_windows.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ func windowsUptime() time.Duration {
9595
}
9696

9797
// TODO(@dean): implement a way to install/uninstall the wintun driver, most
98-
// likely as a CLI command
98+
// likely as a CLI command
9999
//
100100
// This is taken from Tailscale:
101101
// https://github.com/tailscale/tailscale/blob/3abfbf50aebbe3ba57dc749165edb56be6715c0a/cmd/tailscaled/tailscaled_windows.go#L543

vpn/tunnel.go

+8-7
Original file line numberDiff line numberDiff line change
@@ -233,13 +233,14 @@ func (t *Tunnel) start(req *StartRequest) error {
233233
for _, h := range req.GetHeaders() {
234234
header.Add(h.GetName(), h.GetValue())
235235
}
236-
if t.networkingStackFn == nil {
237-
return xerrors.New("dev error: missing networking stack function")
238-
}
239-
240-
networkingStack, err := t.networkingStackFn(t, req, t.clientLogger)
241-
if err != nil {
242-
return xerrors.Errorf("failed to create networking stack dependencies: %w", err)
236+
var networkingStack NetworkStack
237+
if t.networkingStackFn != nil {
238+
networkingStack, err = t.networkingStackFn(t, req, t.clientLogger)
239+
if err != nil {
240+
return xerrors.Errorf("failed to create networking stack dependencies: %w", err)
241+
}
242+
} else {
243+
t.logger.Debug(t.ctx, "using default networking stack as no custom stack was provided")
243244
}
244245

245246
conn, err := t.client.NewConn(

0 commit comments

Comments
 (0)