feat: embed wireguard-go as a library, removing client-side external binary dependencies#477
Open
sechmann wants to merge 1 commit into
Open
feat: embed wireguard-go as a library, removing client-side external binary dependencies#477sechmann wants to merge 1 commit into
sechmann wants to merge 1 commit into
Conversation
📝 Changelog previewBelow is a preview of the Changelog that will be added to the next release. Only commit messages that follow the Conventional Commits specification will be included in the Changelog. v1.15.0 - 2026-05-04Full Changelog: v1.14.7...v1.15.0 🚀 Features
⚙️ Miscellaneous Changes
|
sechmann
added a commit
that referenced
this pull request
Feb 25, 2026
- Remove custom wireguard.PrivateKey type; use wgtypes.Key everywhere - Fix ReadOrCreatePrivateKey to write/read base64 format (not raw bytes) - Fix double base64 encoding in enrollgateway.go - Replace fragile manual base64+copy with wgtypes.ParseKey in EnsurePrivateKey - Add strings.TrimSpace when reading key files to handle trailing newlines - Fix error wrapping: %v -> %w for proper errors.Is/As support - Make Configure retry loop context-aware (select on ctx.Done vs time.Sleep) - Clean up Linux interface on partial SetupInterface failure - Make IPv6 address configuration conditional on all platforms - Change GatewayRequest.WireGuardPublicKey from []byte to string
sechmann
added a commit
that referenced
this pull request
Mar 16, 2026
- Remove custom wireguard.PrivateKey type; use wgtypes.Key everywhere - Fix ReadOrCreatePrivateKey to write/read base64 format (not raw bytes) - Fix double base64 encoding in enrollgateway.go - Replace fragile manual base64+copy with wgtypes.ParseKey in EnsurePrivateKey - Add strings.TrimSpace when reading key files to handle trailing newlines - Fix error wrapping: %v -> %w for proper errors.Is/As support - Make Configure retry loop context-aware (select on ctx.Done vs time.Sleep) - Clean up Linux interface on partial SetupInterface failure - Make IPv6 address configuration conditional on all platforms - Change GatewayRequest.WireGuardPublicKey from []byte to string
cb6fb80 to
75eb38d
Compare
sechmann
added a commit
that referenced
this pull request
Mar 17, 2026
- Remove custom wireguard.PrivateKey type; use wgtypes.Key everywhere - Fix ReadOrCreatePrivateKey to write/read base64 format (not raw bytes) - Fix double base64 encoding in enrollgateway.go - Replace fragile manual base64+copy with wgtypes.ParseKey in EnsurePrivateKey - Add strings.TrimSpace when reading key files to handle trailing newlines - Fix error wrapping: %v -> %w for proper errors.Is/As support - Make Configure retry loop context-aware (select on ctx.Done vs time.Sleep) - Clean up Linux interface on partial SetupInterface failure - Make IPv6 address configuration conditional on all platforms - Change GatewayRequest.WireGuardPublicKey from []byte to string
75eb38d to
5384124
Compare
5384124 to
e3c598b
Compare
7d746f0 to
74d7644
Compare
Replace external wireguard-go/wg binaries and the Windows WireGuard MSI with wireguard-go embedded as a Go library. The helper now creates TUN devices, configures peers via wgctrl, and manages routes through native OS APIs (BSD routing sockets, netlink, winipcfg) instead of shelling out. Migrate key handling from custom crypto wrappers to wgtypes.Key with automatic legacy key migration. Add WireGuard public key validation at enrollment time, an iputil package for CIDR parsing, and cross- platform post-install smoke tests. Remove wireguard-go/wireguard-tools from all package dependencies (Homebrew, nix, deb).
74d7644 to
cb67e51
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replaces all external WireGuard binary dependencies (
wireguard-go,wg,wireguard.exe) with in-process wireguard-go and wgctrl on client platforms. Thenaisdevice-helpernow manages WireGuard interfaces, configuration, and routes entirely as a Go library — no subprocesses needed.Changes by platform
macOS
SetupInterface:tun.CreateTUN+device.NewDevice(userspace wireguard-go) + UAPI socketSyncConf: wgctrl via new sharedwgconfig.ApplyConfig()SetupRoutes: BSD routing sockets (x/net/route) instead ofroutecommandTeardownInterface: closes UAPI + wgDevice in-processLinux
SetupInterface:netlink.LinkAdd(&netlink.Wireguard{})+netlink.AddrAdd+netlink.LinkSetUpSyncConf: wgctrl viawgconfig.ApplyConfig()SetupRoutes:netlink.RouteAddinstead ofip routeTeardownInterface:netlink.LinkDelWindows
SetupInterface:tun.CreateTUN(wintun) +device.NewDevice(userspace wireguard-go) + UAPI named pipeSyncConf: wgctrl viawgconfig.ApplyConfig()SetupRoutes:winipcfg.LUID.AddIPAddress+LUID.AddRouteinstead of wireguard.exe AllowedIPs routingwintun.dllalongside binary instead of bundling WireGuard MSIShared / cleanup
internal/wgconfigpackage — shared wgctrl-based config builder and applier (with tests)internal/wireguard/keys.goMarshal,MarshalHeader,writeConfigFile,WireGuardConfigPath)wireguard-go/wireguard-toolsfrom Homebrew caskdepends_onwireguard-tools/iproute2from Nix client service PATHwintun.dllinsteadConfigure()where wrong error variable was loggedTesting
mise run check— all passing (govet, golangci-lint, staticcheck, govulncheck, ratchet)mise run test— all passing