From 85f12348630e20d9702c74cde7116c59dd232e36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A3=8E=E6=89=87=E6=BB=91=E7=BF=94=E7=BF=BC?= Date: Thu, 19 Mar 2026 18:18:07 +0800 Subject: [PATCH] TUN inbound: Generate deterministic GUID on Windows (#5811) Closes https://github.com/XTLS/Xray-core/issues/5810 --- proxy/tun/tun_windows.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/proxy/tun/tun_windows.go b/proxy/tun/tun_windows.go index 1452441c..8b5a09fa 100644 --- a/proxy/tun/tun_windows.go +++ b/proxy/tun/tun_windows.go @@ -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 {