diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2019-05-31 13:15:53 +0200 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2019-05-31 13:15:53 +0200 |
commit | 7d21ebb3161e3283723db3f202e52ce5fddfdc8c (patch) | |
tree | b7270a6f503dd9106c1d4d824230b3f09abda740 /tunnel/firewall/helpers.go | |
parent | tunnel: logical simplification (diff) | |
download | wireguard-windows-7d21ebb3161e3283723db3f202e52ce5fddfdc8c.tar.xz wireguard-windows-7d21ebb3161e3283723db3f202e52ce5fddfdc8c.zip |
firewall: use random GUIDs
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to '')
-rw-r--r-- | tunnel/firewall/helpers.go | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/tunnel/firewall/helpers.go b/tunnel/firewall/helpers.go index ee783c2d..79ab0d82 100644 --- a/tunnel/firewall/helpers.go +++ b/tunnel/firewall/helpers.go @@ -7,10 +7,12 @@ package firewall import ( "fmt" + "io" "os" "runtime" "syscall" "unsafe" + "crypto/rand" "golang.org/x/sys/windows" ) @@ -135,3 +137,15 @@ func getCurrentProcessAppID() (*wtFwpByteBlob, error) { } return appID, nil } + +func randGUID() (windows.GUID, error) { + guid := windows.GUID{} + n, err := rand.Read((*[16]byte)(unsafe.Pointer(&guid))[:]) + if err != nil { + return guid, err + } + if n != 16 { + return guid, io.ErrShortBuffer + } + return guid, nil +}
\ No newline at end of file |