wintun: don't try to flush interface, but rather delete
This commit is contained in:
parent
c718f3940d
commit
a6dbe4f475
|
@ -65,30 +65,22 @@ func CreateTUN(ifname string) (TUNDevice, error) {
|
||||||
|
|
||||||
// Does an interface with this name already exist?
|
// Does an interface with this name already exist?
|
||||||
wt, err = wintun.GetInterface(ifname, 0)
|
wt, err = wintun.GetInterface(ifname, 0)
|
||||||
if wt == nil {
|
if err == nil {
|
||||||
// Interface does not exist or an error occurred. Create one.
|
// If so, we delete it, in case it has weird residual configuration.
|
||||||
wt, _, err = wintun.CreateInterface("WireGuard Tunnel Adapter", 0)
|
_, _, err = wt.DeleteInterface(0)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("wintun.CreateInterface: %v", err)
|
return nil, fmt.Errorf("Unable to delete already existing Wintun interface: %v", err)
|
||||||
}
|
}
|
||||||
} else if err != nil {
|
}
|
||||||
// Foreign interface with the same name found.
|
wt, _, err = wintun.CreateInterface("WireGuard Tunnel Adapter", 0)
|
||||||
// We could create a Wintun interface under a temporary name. But, should our
|
if err != nil {
|
||||||
// process die without deleting this interface first, the interface would remain
|
return nil, fmt.Errorf("Unable to create Wintun interface: %v", err)
|
||||||
// orphaned.
|
|
||||||
return nil, fmt.Errorf("wintun.GetInterface: %v", err)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
err = wt.SetInterfaceName(ifname)
|
err = wt.SetInterfaceName(ifname)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
wt.DeleteInterface(0)
|
wt.DeleteInterface(0)
|
||||||
return nil, fmt.Errorf("wintun.SetInterfaceName: %v", err)
|
return nil, fmt.Errorf("Unable to set name of Wintun interface: %v", err)
|
||||||
}
|
|
||||||
|
|
||||||
err = wt.FlushInterface()
|
|
||||||
if err != nil {
|
|
||||||
wt.DeleteInterface(0)
|
|
||||||
return nil, fmt.Errorf("wintun.FlushInterface: %v", err)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return &NativeTun{
|
return &NativeTun{
|
||||||
|
|
|
@ -470,15 +470,6 @@ func (wintun *Wintun) DeleteInterface(hwndParent uintptr) (bool, bool, error) {
|
||||||
return false, false, nil
|
return false, false, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// FlushInterface removes all properties from the interface and gives it only a very
|
|
||||||
// vanilla IPv4 and IPv6 configuration with no addresses of any sort assigned.
|
|
||||||
//
|
|
||||||
func (wintun *Wintun) FlushInterface() error {
|
|
||||||
//TODO: implement me!
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// checkReboot checks device install parameters if a system reboot is required.
|
// checkReboot checks device install parameters if a system reboot is required.
|
||||||
//
|
//
|
||||||
|
|
Loading…
Reference in a new issue