2023-01-27 21:37:20 +00:00
|
|
|
// Copyright (c) Tailscale Inc & AUTHORS
|
|
|
|
// SPDX-License-Identifier: BSD-3-Clause
|
2021-01-09 01:17:08 +00:00
|
|
|
|
|
|
|
package tstun
|
|
|
|
|
|
|
|
import (
|
2022-12-09 23:12:20 +00:00
|
|
|
"github.com/tailscale/wireguard-go/tun"
|
2021-01-09 01:17:08 +00:00
|
|
|
"golang.org/x/sys/windows"
|
2021-04-06 05:45:56 +01:00
|
|
|
"golang.zx2c4.com/wireguard/windows/tunnel/winipcfg"
|
2021-01-09 01:17:08 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func init() {
|
2021-10-12 22:25:00 +01:00
|
|
|
tun.WintunTunnelType = "Tailscale"
|
2021-01-09 01:17:08 +00:00
|
|
|
guid, err := windows.GUIDFromString("{37217669-42da-4657-a55b-0d995d328250}")
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
tun.WintunStaticRequestedGUID = &guid
|
|
|
|
}
|
2021-04-06 05:45:56 +01:00
|
|
|
|
|
|
|
func interfaceName(dev tun.Device) (string, error) {
|
|
|
|
guid, err := winipcfg.LUID(dev.(*tun.NativeTun).LUID()).GUID()
|
|
|
|
if err != nil {
|
|
|
|
return "", err
|
|
|
|
}
|
|
|
|
return guid.String(), nil
|
|
|
|
}
|