TUN inbound: Generate deterministic GUID on Windows (#5811)

Closes https://github.com/XTLS/Xray-core/issues/5810
This commit is contained in:
风扇滑翔翼
2026-03-19 18:18:07 +08:00
committed by GitHub
parent 695a28c424
commit 85f1234863

View File

@@ -3,8 +3,9 @@
package tun
import (
"crypto/md5"
"errors"
_ "unsafe"
"unsafe"
"golang.org/x/sys/windows"
"golang.zx2c4.com/wintun"
@@ -66,7 +67,9 @@ func NewTun(options TunOptions) (Tun, error) {
}
func open(name string) (*wintun.Adapter, error) {
var guid *windows.GUID
// generate a deterministic GUID from the adapter name
id := md5.Sum([]byte(name))
guid := (*windows.GUID)(unsafe.Pointer(&id[0]))
// try to open existing adapter by name
adapter, err := wintun.OpenAdapter(name)
if err == nil {