aboutsummaryrefslogtreecommitdiffstats
path: root/tun/wintun/wintun_windows.go
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2019-08-30 10:31:27 -0600
committerJason A. Donenfeld <Jason@zx2c4.com>2019-08-30 11:03:21 -0600
commit950ca2ba8c026be809ced2438f89ec9146734cf7 (patch)
treee2cbd6166091290152824681d8099e76b6d258e4 /tun/wintun/wintun_windows.go
parentnamespaceapi: fix mistake (diff)
downloadwireguard-go-950ca2ba8c026be809ced2438f89ec9146734cf7.tar.xz
wireguard-go-950ca2ba8c026be809ced2438f89ec9146734cf7.zip
wintun: put mutex into private namespace
Diffstat (limited to 'tun/wintun/wintun_windows.go')
-rw-r--r--tun/wintun/wintun_windows.go26
1 files changed, 0 insertions, 26 deletions
diff --git a/tun/wintun/wintun_windows.go b/tun/wintun/wintun_windows.go
index d6fa35f..c654b02 100644
--- a/tun/wintun/wintun_windows.go
+++ b/tun/wintun/wintun_windows.go
@@ -6,17 +6,14 @@
package wintun
import (
- "encoding/hex"
"errors"
"fmt"
"strings"
"time"
"unsafe"
- "golang.org/x/crypto/blake2s"
"golang.org/x/sys/windows"
"golang.org/x/sys/windows/registry"
- "golang.org/x/text/unicode/norm"
"golang.zx2c4.com/wireguard/tun/wintun/iphlpapi"
"golang.zx2c4.com/wireguard/tun/wintun/nci"
@@ -758,26 +755,3 @@ func (wintun *Interface) GUID() windows.GUID {
func (wintun *Interface) LUID() uint64 {
return ((uint64(wintun.luidIndex) & ((1 << 24) - 1)) << 24) | ((uint64(wintun.ifType) & ((1 << 16) - 1)) << 48)
}
-
-func (pool Pool) takeNameMutex() (windows.Handle, error) {
- const mutexLabel = "WireGuard Adapter Name Mutex Stable Suffix v1 jason@zx2c4.com"
- b2, _ := blake2s.New256(nil)
- b2.Write([]byte(mutexLabel))
- b2.Write(norm.NFC.Bytes([]byte(string(pool))))
- mutexName := `Global\Wintun-Name-Mutex-` + hex.EncodeToString(b2.Sum(nil))
- mutex, err := windows.CreateMutex(nil, false, windows.StringToUTF16Ptr(mutexName))
- if err != nil {
- err = fmt.Errorf("Error creating name mutex: %v", err)
- return 0, err
- }
- event, err := windows.WaitForSingleObject(mutex, windows.INFINITE)
- if err != nil {
- windows.CloseHandle(mutex)
- return 0, fmt.Errorf("Error waiting on name mutex: %v", err)
- }
- if event != windows.WAIT_OBJECT_0 {
- windows.CloseHandle(mutex)
- return 0, errors.New("Error with event trigger of name mutex")
- }
- return mutex, nil
-} \ No newline at end of file