feat(vpn): add Linux support for vpn-daemon and OS networking stack by ibetitsmike · Pull Request #22051 · coder/coder

Skip to content

Navigation Menu

Sign in

Appearance settings

Conversation

@ibetitsmike

Summary

Adds Linux support for the Desktop VPN daemon by sharing the Windows/Linux CLI implementation and wiring up a Linux networking stack, while removing unsupported-platform stubs. Also hardens the shared daemon tests so in-process runs do not double-close RPC pipe handles.

Changes

  • Shared Windows/Linux daemon implementation and tests in OS-agnostic files (cli/vpndaemon_windows_linux_shared*.go) with //go:build windows || linux.
  • Added Linux networking stack implementation in vpn/tun_linux.go (TUN + router + DNS configurator).
  • Removed unsupported-platform stubs (cli/vpndaemon_other.go, vpn/tun.go).
  • Adjusted shared daemon tests to duplicate RPC handles (Linux unix.Dup, Windows syscall.DuplicateHandle) before passing them to the in-process daemon to avoid FD/handle reuse issues.

Testing

  • go test -tags=testsmallbatch ./cli -run 'TestVPNDaemonRun|TestOpenApp' -count=1
  • go test -race -tags=testsmallbatch ./cli -run 'TestVPNDaemonRun|TestOpenApp' -count=1
  • go test -tags=testsmallbatch ./cli -count=1
  • go test -race -tags=testsmallbatch ./cli -count=1
  • make lint

@ibetitsmike

@ibetitsmike

@chatgpt-codex-connector

ethanndickson

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!

deansheather

@ibetitsmike

Addressed Dean's review feedback in 79888291e:

  • Shared Windows/Linux daemon implementation in cli/vpndaemon_windows_linux.go with //go:build windows || linux.
  • Shared Windows/Linux tests in cli/vpndaemon_windows_linux_test.go.
  • Removed cli/vpndaemon_linux.go, cli/vpndaemon_linux_test.go, and unsupported-platform stubs (cli/vpndaemon_other.go, vpn/tun.go).
  • Kept stderr-based logging (no tunnel-pipe logging) and adjusted the handshake test path for race-safety.

Validation run locally:

  • go test ./cli -run TestVPNDaemonRun -count=1
  • go test -race ./cli -run TestVPNDaemonRun -count=1
  • go test ./vpn -count=1
  • go build ./cli/...
  • go build ./vpn/...
  • make lint/go