From a8cb01e6df93ee6bb43760fa7c08f399f5e039de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=96=E7=95=8C?= Date: Tue, 9 Sep 2025 14:48:31 +0800 Subject: [PATCH] Prevent panic when wintun dll fails to load --- internal/wintun/wintun_windows.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/internal/wintun/wintun_windows.go b/internal/wintun/wintun_windows.go index a817e6c..288d364 100644 --- a/internal/wintun/wintun_windows.go +++ b/internal/wintun/wintun_windows.go @@ -39,6 +39,10 @@ func closeAdapter(wintun *Adapter) { // deterministically. If it is set to nil, the GUID is chosen by the system at random, // and hence a new NLA entry is created for each new adapter. func CreateAdapter(name string, tunnelType string, requestedGUID *windows.GUID) (wintun *Adapter, err error) { + err = procWintunCloseAdapter.Find() + if err != nil { + return + } var name16 *uint16 name16, err = windows.UTF16PtrFromString(name) if err != nil {