aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/main.go
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2021-10-26 18:51:52 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2021-10-27 19:04:36 +0200
commitea932e4304c17eddb63dbfbd4aa6d1b83b58c0d3 (patch)
treee6b7665a5465ad614053f203734f21c6fb5f4752 /main.go
parentembeddable-dll-service: update for new wgnt API (diff)
downloadwireguard-windows-ea932e4304c17eddb63dbfbd4aa6d1b83b58c0d3.tar.xz
wireguard-windows-ea932e4304c17eddb63dbfbd4aa6d1b83b58c0d3.zip
manager: delay boottime updates and simplify
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'main.go')
-rw-r--r--main.go10
1 files changed, 10 insertions, 0 deletions
diff --git a/main.go b/main.go
index 3fad1a24..9a8a8607 100644
--- a/main.go
+++ b/main.go
@@ -6,15 +6,18 @@
package main
import (
+ "crypto/rand"
"debug/pe"
"errors"
"fmt"
"io"
"log"
+ unsafeRand "math/rand"
"os"
"strconv"
"strings"
"time"
+ "unsafe"
"golang.org/x/sys/windows"
@@ -150,12 +153,19 @@ func pipeFromHandleArgument(handleStr string) (*os.File, error) {
return os.NewFile(uintptr(handleInt), "pipe"), nil
}
+func seedUnsafeRng() {
+ var seed int64
+ rand.Read(unsafe.Slice((*byte)(unsafe.Pointer(&seed)), unsafe.Sizeof(seed)))
+ unsafeRand.Seed(seed)
+}
+
func main() {
if windows.SetDllDirectory("") != nil || windows.SetDefaultDllDirectories(windows.LOAD_LIBRARY_SEARCH_SYSTEM32) != nil {
panic("failed to restrict dll search path")
}
setLogFile()
+ seedUnsafeRng()
checkForWow64()
if len(os.Args) <= 1 {