aboutsummaryrefslogtreecommitdiffstats
path: root/device/allowedips_rand_test.go
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2021-11-05 01:52:54 +0100
committerJason A. Donenfeld <Jason@zx2c4.com>2021-11-23 22:03:15 +0100
commitef8d6804d77d9ce09f0e2c7f6d85bbe222712b73 (patch)
tree5b4a3b53dfb092f10cf11fbe0b5724f58df3a1bf /device/allowedips_rand_test.go
parentdevice: only propagate roaming value before peer is referenced elsewhere (diff)
downloadwireguard-go-ef8d6804d77d9ce09f0e2c7f6d85bbe222712b73.tar.xz
wireguard-go-ef8d6804d77d9ce09f0e2c7f6d85bbe222712b73.zip
global: use netip where possible now
There are more places where we'll need to add it later, when Go 1.18 comes out with support for it in the "net" package. Also, allowedips still uses slices internally, which might be suboptimal. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'device/allowedips_rand_test.go')
-rw-r--r--device/allowedips_rand_test.go6
1 files changed, 4 insertions, 2 deletions
diff --git a/device/allowedips_rand_test.go b/device/allowedips_rand_test.go
index 16de170..ff56fe6 100644
--- a/device/allowedips_rand_test.go
+++ b/device/allowedips_rand_test.go
@@ -10,6 +10,8 @@ import (
"net"
"sort"
"testing"
+
+ "golang.zx2c4.com/go118/netip"
)
const (
@@ -93,14 +95,14 @@ func TestTrieRandom(t *testing.T) {
rand.Read(addr4[:])
cidr := uint8(rand.Intn(32) + 1)
index := rand.Intn(NumberOfPeers)
- allowedIPs.Insert(addr4[:], cidr, peers[index])
+ allowedIPs.Insert(netip.PrefixFrom(netip.AddrFrom4(addr4), int(cidr)), peers[index])
slow4 = slow4.Insert(addr4[:], cidr, peers[index])
var addr6 [16]byte
rand.Read(addr6[:])
cidr = uint8(rand.Intn(128) + 1)
index = rand.Intn(NumberOfPeers)
- allowedIPs.Insert(addr6[:], cidr, peers[index])
+ allowedIPs.Insert(netip.PrefixFrom(netip.AddrFrom16(addr6), int(cidr)), peers[index])
slow6 = slow6.Insert(addr6[:], cidr, peers[index])
}