diff options
author | Simon Rozman <simon@rozman.si> | 2019-05-24 09:28:50 +0200 |
---|---|---|
committer | Simon Rozman <simon@rozman.si> | 2019-05-24 09:29:57 +0200 |
commit | 6a0a3a54067182aee4c2cb4c7ef7ac5aaf2fd961 (patch) | |
tree | f2278f9c28d443d198e2fdb7819753a4d9d5b682 /tun/tun_windows.go | |
parent | 8fdcf5ee30d9576b5ddb163180f5d5506a349eea (diff) |
wintun: revise GetInterface()
- Make foreign interface found error numeric to ease condition
detection.
- Update GetInterface() documentation.
- Make tun.CreateTUN() quit when foreign interface found before
attempting to create a Wintun interface with a duplicate name.
Creation is futile.
Signed-off-by: Simon Rozman <simon@rozman.si>
Diffstat (limited to 'tun/tun_windows.go')
-rw-r--r-- | tun/tun_windows.go | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/tun/tun_windows.go b/tun/tun_windows.go index c17f6d1..b352cd1 100644 --- a/tun/tun_windows.go +++ b/tun/tun_windows.go @@ -71,6 +71,8 @@ func CreateTUN(ifname string) (TUNDevice, error) { if err != nil { return nil, fmt.Errorf("Unable to delete already existing Wintun interface: %v", err) } + } else if err == windows.ERROR_ALREADY_EXISTS { + return nil, fmt.Errorf("Foreign network interface with the same name exists") } wt, _, err = wintun.CreateInterface("WireGuard Tunnel Adapter", 0) if err != nil { |