cleanup ziti network adapter profile, set the lower interface metric

This commit is contained in:
Mary Lincy Dcouto
2021-05-20 14:42:15 +05:30
parent aa12e8ab65
commit 155ca06eb2
4 changed files with 26 additions and 3 deletions
+1 -1
View File
@@ -193,7 +193,7 @@ namespace ZitiUpdateService {
outputIpconfigInfo(destinationLocation);
outputSystemInfo(destinationLocation);
// removing this as of 1.9.0+ since we use NRPT... outputDnsCache(destinationLocation);
outputDnsCache(destinationLocation);
outputExternalIP(destinationLocation);
outputTasklist(destinationLocation);
outputRouteInfo(destinationLocation);
+20
View File
@@ -288,3 +288,23 @@ func removeSingleNrtpRule(nrptRule string) {
log.Errorf("ERROR removing the nrpt rules: %v", err)
}
}
func CleanUpNetworkAdapterProfile() {
script := fmt.Sprintf(`$key="Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkList\Signatures\Unmanaged\*"
Get-ItemProperty -Path $key | where {$_.FirstNetwork -match "ziti.*"} | Remove-Item
$key="Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkList\Profiles\*"
Get-ItemProperty -Path $key | where {$_.ProfileName -match "Ziti.*"} | Remove-Item`)
log.Debugf("Cleaning up the Network Adapter profiles with: %s", script)
cmd := exec.Command("powershell", "-Command", script)
cmd.Stderr = os.Stdout
output := new(bytes.Buffer)
cmd.Stdout = output
err := cmd.Run()
if err != nil {
log.Errorf("ERROR Cleaning up the Network Adapter profiles: %v", err)
}
}
+2 -2
View File
@@ -65,6 +65,8 @@ var shutdown = make(chan bool, 8) //a channel informing go routines to exit
func SubMain(ops chan string, changes chan<- svc.Status) error {
log.Info("============================== service begins ==============================")
windns.RemoveAllNrptRules()
// cleanup old ziti tun profiles
windns.CleanUpNetworkAdapterProfile()
rts.LoadConfig()
l := rts.state.LogLevel
@@ -287,8 +289,6 @@ func initialize(cLogLevel int) error {
return err
}
cziti.SetInterfaceMetric(TunName, 255)
cziti.Start(rts, rts.state.TunIpv4, rts.state.TunIpv4Mask, cLogLevel)
err = cziti.HookupTun(*t)
if err != nil {
+3
View File
@@ -234,6 +234,9 @@ func (t *RuntimeState) CreateTun(ipv4 string, ipv4mask int, applyDns bool) (net.
}
//for windows 10+, could 'domains' be able to replace NRPT? dunno - didn't test it
luid.SetDNS(windows.AF_INET, []net.IP{ip}, nil)
cziti.SetInterfaceMetric(TunName, 5)
} else {
cziti.SetInterfaceMetric(TunName, 255)
}
return ip, t.tun, nil