mirror of
https://github.com/Control-D-Inc/ctrld.git
synced 2026-07-04 01:07:49 +02:00
fix(windows): make staticcheck happy
This commit is contained in:
committed by
Cuong Manh Le
parent
9b2e51f53a
commit
9be15aeec8
@@ -1062,36 +1062,6 @@ func (p *prog) stopDNSIntercept() error {
|
|||||||
return nil
|
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
|
// 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
|
// VPN DNS server IPs. This prevents the block filters from intercepting ctrld's own
|
||||||
// forwarded queries to VPN DNS servers (split DNS routing).
|
// forwarded queries to VPN DNS servers (split DNS routing).
|
||||||
@@ -1319,11 +1289,6 @@ func (p *prog) ensurePFAnchorActive() bool {
|
|||||||
return false
|
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).
|
// checkTunnelInterfaceChanges is a no-op on Windows (WFP handles intercept differently).
|
||||||
func (p *prog) checkTunnelInterfaceChanges() bool {
|
func (p *prog) checkTunnelInterfaceChanges() bool {
|
||||||
return false
|
return false
|
||||||
|
|||||||
@@ -14,9 +14,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
kernel32 = windows.NewLazySystemDLL("kernel32.dll")
|
|
||||||
wtsapi32 = windows.NewLazySystemDLL("wtsapi32.dll")
|
wtsapi32 = windows.NewLazySystemDLL("wtsapi32.dll")
|
||||||
procGetConsoleWindow = kernel32.NewProc("GetConsoleWindow")
|
|
||||||
procWTSGetActiveConsoleSessionId = wtsapi32.NewProc("WTSGetActiveConsoleSessionId")
|
procWTSGetActiveConsoleSessionId = wtsapi32.NewProc("WTSGetActiveConsoleSessionId")
|
||||||
procWTSQuerySessionInformation = wtsapi32.NewProc("WTSQuerySessionInformationW")
|
procWTSQuerySessionInformation = wtsapi32.NewProc("WTSQuerySessionInformationW")
|
||||||
procWTSFreeMemory = wtsapi32.NewProc("WTSFreeMemory")
|
procWTSFreeMemory = wtsapi32.NewProc("WTSFreeMemory")
|
||||||
|
|||||||
Reference in New Issue
Block a user