fix(windows): make staticcheck happy

This commit is contained in:
Cuong Manh Le
2026-03-03 15:11:29 +07:00
committed by Cuong Manh Le
parent 9b2e51f53a
commit 9be15aeec8
2 changed files with 0 additions and 37 deletions

View File

@@ -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

View File

@@ -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")