From 5dda894e29c4bdc4bfdf9ee393bb981bff2b2587 Mon Sep 17 00:00:00 2001 From: Artem Lytkin <146867384+4RH1T3CT0R7@users.noreply.github.com> Date: Sun, 27 Sep 2026 23:39:17 +0300 Subject: [PATCH] TUN inbound: Reuse existing Wintun adapter by name on Windows again (#6811) Fixes https://github.com/XTLS/Xray-core/issues/6780 --- proxy/tun/tun_windows.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/proxy/tun/tun_windows.go b/proxy/tun/tun_windows.go index 2097b6894..aa65694bc 100644 --- a/proxy/tun/tun_windows.go +++ b/proxy/tun/tun_windows.go @@ -78,8 +78,13 @@ func open(name, desc string) (*wintun.Adapter, error) { // 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 { + return adapter, nil + } // try to create adapter anew - adapter, err := wintun.CreateAdapter(name, desc, guid) + adapter, err = wintun.CreateAdapter(name, desc, guid) if err == nil { return adapter, nil }