From c53503b52b6fc6de37b6053719521054003fa50b Mon Sep 17 00:00:00 2001 From: James O'Doherty Date: Thu, 4 Jun 2026 00:21:56 -0400 Subject: clean up debugging prints and silence successful execution output - Remove leftover DEBUG prints from CLI and wireguard internal packages. - Silence stdout during successful command wrapping to ensure only the wrapped command's output is visible. - Redirect all warnings and internal errors to stderr. - Implement a verbose mode via `WG_WRAP_VERBOSE=1` to enable tunnel status messages. - Update E2E tests to use verbose mode for verification of tunnel lifecycle events. - Fix errcheck linting issue in wireguard.go and apply go fmt. --- internal/wireguard/wireguard.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'internal/wireguard') diff --git a/internal/wireguard/wireguard.go b/internal/wireguard/wireguard.go index 45e6292..0c341f2 100644 --- a/internal/wireguard/wireguard.go +++ b/internal/wireguard/wireguard.go @@ -25,9 +25,9 @@ import ( // Tunnel represents an active Userspace WireGuard tunnel inside a network namespace. type Tunnel struct { - Device *device.Device - Tun tun.Device - dnsFile string + Device *device.Device + Tun tun.Device + dnsFile string } // StartTunnel creates a TUN device, launches wireguard-go over it, and configures IPs/routes. @@ -108,7 +108,9 @@ func StartTunnel(pm *paths.PathManager, profile string, cfg *wgconf.Config, dnsS } else { dnsFile = path cleanups = append(cleanups, func() { - UnmountResolvConf(dnsFile) + if err := UnmountResolvConf(dnsFile); err != nil { + fmt.Printf("warning: failed to unmount resolv.conf during cleanup: %v\n", err) + } }) } @@ -243,7 +245,7 @@ func ConfigureResolvConf(dns string, profileDir string) (string, error) { if dns == "" { return "", nil } - + // Create the temporary resolv.conf file within the profile directory // so it can be cleaned up during namespace unpinning. tmpFile, err := os.CreateTemp(profileDir, "resolvconf") @@ -274,8 +276,6 @@ func UnmountResolvConf(path string) error { return nil } - fmt.Printf("DEBUG: Unmounting resolv.conf file: %s\n", path) - // Attempt to unmount. If it fails, it might already be unmounted // or the namespace might be gone. _ = unix.Unmount("/etc/resolv.conf", unix.MNT_DETACH) @@ -335,7 +335,7 @@ func (h *HostBind) Close() error { return ni func (h *HostBind) SetMark(mark uint32) error { return nil } func (h *HostBind) Send(bufs [][]byte, endpoint conn.Endpoint) error { return nil } func (h *HostBind) ParseEndpoint(s string) (conn.Endpoint, error) { return nil, nil } -func (h *HostBind) BatchSize() int { return 0} +func (h *HostBind) BatchSize() int { return 0 } type FDBind struct { originalFd int -- cgit v1.2.3