mirror of
https://github.com/openziti/desktop-edge-win.git
synced 2026-10-13 16:21:25 +00:00
cleanup ziti network adapter profile, set the lower interface metric
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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 {
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user