fix as per the code review comments

This commit is contained in:
Mary Lincy Dcouto
2021-04-19 21:12:29 +05:30
parent 17dd0ef902
commit dfdad6917b
2 changed files with 10 additions and 5 deletions
+3 -3
View File
@@ -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)
+7 -2
View File
@@ -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)
}