mirror of
https://github.com/XTLS/Xray-core.git
synced 2026-05-08 14:13:22 +00:00
TUN inbound: Generate deterministic GUID on Windows (#5811)
Closes https://github.com/XTLS/Xray-core/issues/5810
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user