diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2019-06-09 19:20:17 +0200 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2019-06-10 10:43:02 +0200 |
commit | e924280baa36f6fd80f4a65f2fb6223a4965b281 (patch) | |
tree | f1d8f36e9282b6bf5cb3b3aa888f07ecb20fc790 /tun/tun_windows.go | |
parent | bb3f1932faa4f75800a145e7f0476d8a8dcf104a (diff) |
wintun: allow controlling GUID
Diffstat (limited to 'tun/tun_windows.go')
-rw-r--r-- | tun/tun_windows.go | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/tun/tun_windows.go b/tun/tun_windows.go index 0b41be9..1881e5b 100644 --- a/tun/tun_windows.go +++ b/tun/tun_windows.go @@ -60,6 +60,14 @@ func packetAlign(size uint32) uint32 { // adapter with the same name exist, it is reused. // func CreateTUN(ifname string) (TUNDevice, error) { + return CreateTUNWithRequestedGUID(ifname, nil) +} + +// +// CreateTUNWithRequestedGUID creates a Wintun adapter with the given name and +// a requested GUID. Should a Wintun adapter with the same name exist, it is reused. +// +func CreateTUNWithRequestedGUID(ifname string, requestedGUID *windows.GUID) (TUNDevice, error) { var err error var wt *wintun.Wintun @@ -74,7 +82,7 @@ func CreateTUN(ifname string) (TUNDevice, error) { } 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) + wt, _, err = wintun.CreateInterface("WireGuard Tunnel Adapter", requestedGUID, 0) if err != nil { return nil, fmt.Errorf("Unable to create Wintun interface: %v", err) } |