mirror of
https://github.com/openziti/desktop-edge-win.git
synced 2026-10-12 07:48:05 +00:00
fix as per the code review comments
This commit is contained in:
@@ -239,9 +239,9 @@ ForEach ($ns in $toRemove){
|
||||
}
|
||||
}
|
||||
|
||||
func IsNrptPoliciesEffective() bool {
|
||||
script := fmt.Sprintf(`Add-DnsClientNrptRule -Namespace ".ziti.test" -NameServers "100.64.0.1" -Comment "Added by ziti-tunnel" -DisplayName "ziti-tunnel:.ziti.test"
|
||||
Get-DnsClientNrptPolicy -Effective | Select-Object Namespace -Unique | Where-Object Namespace -Eq ".ziti.test"`)
|
||||
func IsNrptPoliciesEffective(dnsserver string) bool {
|
||||
script := fmt.Sprintf(`Add-DnsClientNrptRule -Namespace ".ziti.test" -NameServers "%s" -Comment "Added by ziti-tunnel" -DisplayName "ziti-tunnel:.ziti.test"
|
||||
Get-DnsClientNrptPolicy -Effective | Select-Object Namespace -Unique | Where-Object Namespace -Eq ".ziti.test"`, dnsserver)
|
||||
log.Debugf("checking the nrpt policies with: %s", script)
|
||||
|
||||
cmd := exec.Command("powershell", "-Command", script)
|
||||
|
||||
@@ -223,9 +223,14 @@ func (t *RuntimeState) CreateTun(ipv4 string, ipv4mask int, applyDns bool) (net.
|
||||
}
|
||||
log.Info("routing applied")
|
||||
|
||||
zitiPoliciesEffective := windns.IsNrptPoliciesEffective()
|
||||
zitiPoliciesEffective := windns.IsNrptPoliciesEffective(ipv4)
|
||||
if applyDns || !zitiPoliciesEffective {
|
||||
log.Info("DNS is applied to the TUN interface, because apply Dns flag in the config file: %t and ziti policies test result in this client: %t ", applyDns, zitiPoliciesEffective)
|
||||
if applyDns {
|
||||
log.Infof("DNS is applied to the TUN interface, because apply Dns flag in the config file is %t ", applyDns)
|
||||
}
|
||||
if !applyDns && !zitiPoliciesEffective {
|
||||
log.Infof("DNS is applied to the TUN interface, because Ziti policies test result in this client is %t", zitiPoliciesEffective)
|
||||
}
|
||||
//for windows 10+, could 'domains' be able to replace NRPT? dunno - didn't test it
|
||||
luid.SetDNS(windows.AF_INET, []net.IP{ip}, nil)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user