From 9be15aeec8a815f68b1443822d8b5ddfa635df4a Mon Sep 17 00:00:00 2001 From: Cuong Manh Le Date: Tue, 3 Mar 2026 15:11:29 +0700 Subject: [PATCH] fix(windows): make staticcheck happy --- cmd/cli/dns_intercept_windows.go | 35 -------------------------------- discover_user_windows.go | 2 -- 2 files changed, 37 deletions(-) diff --git a/cmd/cli/dns_intercept_windows.go b/cmd/cli/dns_intercept_windows.go index 5a07d46..fb56782 100644 --- a/cmd/cli/dns_intercept_windows.go +++ b/cmd/cli/dns_intercept_windows.go @@ -1062,36 +1062,6 @@ func (p *prog) stopDNSIntercept() error { return nil } -// dnsInterceptSupported reports whether DNS intercept mode is supported on this platform. -func dnsInterceptSupported() bool { - if err := fwpuclntDLL.Load(); err != nil { - return false - } - return true -} - -// validateDNSIntercept checks that the system meets requirements for DNS intercept mode. -func (p *prog) validateDNSIntercept() error { - // Hard mode requires WFP and elevation for filter management. - if hardIntercept { - if !dnsInterceptSupported() { - return fmt.Errorf("dns intercept: fwpuclnt.dll not available — WFP requires Windows Vista or later") - } - if !isElevated() { - return fmt.Errorf("dns intercept: administrator privileges required for WFP filter management in hard mode") - } - } - // dns mode only needs NRPT (HKLM registry writes), which services can do - // without explicit elevation checks. - return nil -} - -// isElevated checks if the current process has administrator privileges. -func isElevated() bool { - token := windows.GetCurrentProcessToken() - return token.IsElevated() -} - // exemptVPNDNSServers updates the WFP filters to permit outbound DNS to the given // VPN DNS server IPs. This prevents the block filters from intercepting ctrld's own // forwarded queries to VPN DNS servers (split DNS routing). @@ -1319,11 +1289,6 @@ func (p *prog) ensurePFAnchorActive() bool { return false } -// pfAnchorIsWiped is a no-op on Windows (WFP handles intercept differently). -func (p *prog) pfAnchorIsWiped() bool { - return false -} - // checkTunnelInterfaceChanges is a no-op on Windows (WFP handles intercept differently). func (p *prog) checkTunnelInterfaceChanges() bool { return false diff --git a/discover_user_windows.go b/discover_user_windows.go index 3e5db11..d4dcd1e 100644 --- a/discover_user_windows.go +++ b/discover_user_windows.go @@ -14,9 +14,7 @@ import ( ) var ( - kernel32 = windows.NewLazySystemDLL("kernel32.dll") wtsapi32 = windows.NewLazySystemDLL("wtsapi32.dll") - procGetConsoleWindow = kernel32.NewProc("GetConsoleWindow") procWTSGetActiveConsoleSessionId = wtsapi32.NewProc("WTSGetActiveConsoleSessionId") procWTSQuerySessionInformation = wtsapi32.NewProc("WTSQuerySessionInformationW") procWTSFreeMemory = wtsapi32.NewProc("WTSFreeMemory")