mirror of
https://github.com/Control-D-Inc/ctrld.git
synced 2026-07-04 01:07:49 +02:00
Resolve "OS upstream failure / wrong default route"
This commit is contained in:
committed by
Cuong Manh Le
parent
49eb152d02
commit
a0c5062e3a
@@ -120,6 +120,7 @@ type prog struct {
|
||||
runningIface string
|
||||
requiredMultiNICsConfig bool
|
||||
adDomain string
|
||||
runningOnDomainController bool
|
||||
|
||||
selfUninstallMu sync.Mutex
|
||||
refusedQueryCount int
|
||||
@@ -276,6 +277,11 @@ func (p *prog) preRun() {
|
||||
|
||||
func (p *prog) postRun() {
|
||||
if !service.Interactive() {
|
||||
if runtime.GOOS == "windows" {
|
||||
isDC, roleInt := isRunningOnDomainController()
|
||||
p.runningOnDomainController = isDC
|
||||
mainLog.Load().Debug().Msgf("running on domain controller: %t, role: %d", p.runningOnDomainController, roleInt)
|
||||
}
|
||||
p.resetDNS(false, false)
|
||||
ns := ctrld.InitializeOsResolver(false)
|
||||
mainLog.Load().Debug().Msgf("initialized OS resolver with nameservers: %v", ns)
|
||||
@@ -1410,5 +1416,25 @@ func (p *prog) leakOnUpstreamFailure() bool {
|
||||
if router.Name() != "" {
|
||||
return false
|
||||
}
|
||||
// if we are running on ADDC, we should not leak on upstream failure
|
||||
if p.runningOnDomainController {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
// Domain controller role values from Win32_ComputerSystem
|
||||
// https://learn.microsoft.com/en-us/windows/win32/cimwin32prov/win32-computersystem
|
||||
const (
|
||||
BackupDomainController = 4
|
||||
PrimaryDomainController = 5
|
||||
)
|
||||
|
||||
// isRunningOnDomainController checks if the current machine is a domain controller
|
||||
// by querying the DomainRole property from Win32_ComputerSystem via WMI.
|
||||
func isRunningOnDomainController() (bool, int) {
|
||||
if runtime.GOOS != "windows" {
|
||||
return false, 0
|
||||
}
|
||||
return isRunningOnDomainControllerWindows()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user