mirror of
https://github.com/netbirdio/netbird.git
synced 2024-11-28 02:53:20 +01:00
13e7198046
wait on engine down to not only wait for the interface to be down but completely removed. If the waiting loop reaches the timeout we will trigger an interface destroy. On the up command, it now waits until the engine is fully running before sending the response to the CLI. Includes a small refactor of probes to comply with sonar rules about parameter count in the function call
33 lines
907 B
Go
33 lines
907 B
Go
//go:build windows
|
|
|
|
package iface
|
|
|
|
import (
|
|
"fmt"
|
|
"os/exec"
|
|
|
|
log "github.com/sirupsen/logrus"
|
|
)
|
|
|
|
func (w *WGIface) Destroy() error {
|
|
netshCmd := GetSystem32Command("netsh")
|
|
out, err := exec.Command(netshCmd, "interface", "set", "interface", w.Name(), "admin=disable").CombinedOutput()
|
|
if err != nil {
|
|
return fmt.Errorf("failed to remove interface %s: %w - %s", w.Name(), err, out)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// GetSystem32Command checks if a command can be found in the system path and returns it. In case it can't find it
|
|
// in the path it will return the full path of a command assuming C:\windows\system32 as the base path.
|
|
func GetSystem32Command(command string) string {
|
|
_, err := exec.LookPath(command)
|
|
if err == nil {
|
|
return command
|
|
}
|
|
|
|
log.Tracef("Command %s not found in PATH, using C:\\windows\\system32\\%s.exe path", command, command)
|
|
|
|
return "C:\\windows\\system32\\" + command + ".exe"
|
|
}
|