|
@@ -10,6 +10,7 @@ import (
|
|
func TestRemoteList_Rebuild(t *testing.T) {
|
|
func TestRemoteList_Rebuild(t *testing.T) {
|
|
rl := NewRemoteList()
|
|
rl := NewRemoteList()
|
|
rl.unlockedSetV4(
|
|
rl.unlockedSetV4(
|
|
|
|
+ 0,
|
|
0,
|
|
0,
|
|
[]*Ip4AndPort{
|
|
[]*Ip4AndPort{
|
|
{Ip: ip2int(net.ParseIP("70.199.182.92")), Port: 1475}, // this is duped
|
|
{Ip: ip2int(net.ParseIP("70.199.182.92")), Port: 1475}, // this is duped
|
|
@@ -23,10 +24,11 @@ func TestRemoteList_Rebuild(t *testing.T) {
|
|
{Ip: ip2int(net.ParseIP("70.199.182.92")), Port: 1476}, // almost dupe of 0 with a diff port
|
|
{Ip: ip2int(net.ParseIP("70.199.182.92")), Port: 1476}, // almost dupe of 0 with a diff port
|
|
{Ip: ip2int(net.ParseIP("70.199.182.92")), Port: 1475}, // this is a dupe
|
|
{Ip: ip2int(net.ParseIP("70.199.182.92")), Port: 1475}, // this is a dupe
|
|
},
|
|
},
|
|
- func(*Ip4AndPort) bool { return true },
|
|
|
|
|
|
+ func(uint32, *Ip4AndPort) bool { return true },
|
|
)
|
|
)
|
|
|
|
|
|
rl.unlockedSetV6(
|
|
rl.unlockedSetV6(
|
|
|
|
+ 1,
|
|
1,
|
|
1,
|
|
[]*Ip6AndPort{
|
|
[]*Ip6AndPort{
|
|
NewIp6AndPort(net.ParseIP("1::1"), 1), // this is duped
|
|
NewIp6AndPort(net.ParseIP("1::1"), 1), // this is duped
|
|
@@ -35,7 +37,7 @@ func TestRemoteList_Rebuild(t *testing.T) {
|
|
NewIp6AndPort(net.ParseIP("1::1"), 1), // this is a dupe
|
|
NewIp6AndPort(net.ParseIP("1::1"), 1), // this is a dupe
|
|
NewIp6AndPort(net.ParseIP("1::1"), 2), // this is a dupe
|
|
NewIp6AndPort(net.ParseIP("1::1"), 2), // this is a dupe
|
|
},
|
|
},
|
|
- func(*Ip6AndPort) bool { return true },
|
|
|
|
|
|
+ func(uint32, *Ip6AndPort) bool { return true },
|
|
)
|
|
)
|
|
|
|
|
|
rl.Rebuild([]*net.IPNet{})
|
|
rl.Rebuild([]*net.IPNet{})
|
|
@@ -101,6 +103,7 @@ func TestRemoteList_Rebuild(t *testing.T) {
|
|
func BenchmarkFullRebuild(b *testing.B) {
|
|
func BenchmarkFullRebuild(b *testing.B) {
|
|
rl := NewRemoteList()
|
|
rl := NewRemoteList()
|
|
rl.unlockedSetV4(
|
|
rl.unlockedSetV4(
|
|
|
|
+ 0,
|
|
0,
|
|
0,
|
|
[]*Ip4AndPort{
|
|
[]*Ip4AndPort{
|
|
{Ip: ip2int(net.ParseIP("70.199.182.92")), Port: 1475},
|
|
{Ip: ip2int(net.ParseIP("70.199.182.92")), Port: 1475},
|
|
@@ -112,10 +115,11 @@ func BenchmarkFullRebuild(b *testing.B) {
|
|
{Ip: ip2int(net.ParseIP("172.17.1.1")), Port: 10101}, // this is a dupe
|
|
{Ip: ip2int(net.ParseIP("172.17.1.1")), Port: 10101}, // this is a dupe
|
|
{Ip: ip2int(net.ParseIP("70.199.182.92")), Port: 1476}, // dupe of 0 with a diff port
|
|
{Ip: ip2int(net.ParseIP("70.199.182.92")), Port: 1476}, // dupe of 0 with a diff port
|
|
},
|
|
},
|
|
- func(*Ip4AndPort) bool { return true },
|
|
|
|
|
|
+ func(uint32, *Ip4AndPort) bool { return true },
|
|
)
|
|
)
|
|
|
|
|
|
rl.unlockedSetV6(
|
|
rl.unlockedSetV6(
|
|
|
|
+ 0,
|
|
0,
|
|
0,
|
|
[]*Ip6AndPort{
|
|
[]*Ip6AndPort{
|
|
NewIp6AndPort(net.ParseIP("1::1"), 1),
|
|
NewIp6AndPort(net.ParseIP("1::1"), 1),
|
|
@@ -123,7 +127,7 @@ func BenchmarkFullRebuild(b *testing.B) {
|
|
NewIp6AndPort(net.ParseIP("1:100::1"), 1),
|
|
NewIp6AndPort(net.ParseIP("1:100::1"), 1),
|
|
NewIp6AndPort(net.ParseIP("1::1"), 1), // this is a dupe
|
|
NewIp6AndPort(net.ParseIP("1::1"), 1), // this is a dupe
|
|
},
|
|
},
|
|
- func(*Ip6AndPort) bool { return true },
|
|
|
|
|
|
+ func(uint32, *Ip6AndPort) bool { return true },
|
|
)
|
|
)
|
|
|
|
|
|
b.Run("no preferred", func(b *testing.B) {
|
|
b.Run("no preferred", func(b *testing.B) {
|
|
@@ -164,6 +168,7 @@ func BenchmarkFullRebuild(b *testing.B) {
|
|
func BenchmarkSortRebuild(b *testing.B) {
|
|
func BenchmarkSortRebuild(b *testing.B) {
|
|
rl := NewRemoteList()
|
|
rl := NewRemoteList()
|
|
rl.unlockedSetV4(
|
|
rl.unlockedSetV4(
|
|
|
|
+ 0,
|
|
0,
|
|
0,
|
|
[]*Ip4AndPort{
|
|
[]*Ip4AndPort{
|
|
{Ip: ip2int(net.ParseIP("70.199.182.92")), Port: 1475},
|
|
{Ip: ip2int(net.ParseIP("70.199.182.92")), Port: 1475},
|
|
@@ -175,10 +180,11 @@ func BenchmarkSortRebuild(b *testing.B) {
|
|
{Ip: ip2int(net.ParseIP("172.17.1.1")), Port: 10101}, // this is a dupe
|
|
{Ip: ip2int(net.ParseIP("172.17.1.1")), Port: 10101}, // this is a dupe
|
|
{Ip: ip2int(net.ParseIP("70.199.182.92")), Port: 1476}, // dupe of 0 with a diff port
|
|
{Ip: ip2int(net.ParseIP("70.199.182.92")), Port: 1476}, // dupe of 0 with a diff port
|
|
},
|
|
},
|
|
- func(*Ip4AndPort) bool { return true },
|
|
|
|
|
|
+ func(uint32, *Ip4AndPort) bool { return true },
|
|
)
|
|
)
|
|
|
|
|
|
rl.unlockedSetV6(
|
|
rl.unlockedSetV6(
|
|
|
|
+ 0,
|
|
0,
|
|
0,
|
|
[]*Ip6AndPort{
|
|
[]*Ip6AndPort{
|
|
NewIp6AndPort(net.ParseIP("1::1"), 1),
|
|
NewIp6AndPort(net.ParseIP("1::1"), 1),
|
|
@@ -186,7 +192,7 @@ func BenchmarkSortRebuild(b *testing.B) {
|
|
NewIp6AndPort(net.ParseIP("1:100::1"), 1),
|
|
NewIp6AndPort(net.ParseIP("1:100::1"), 1),
|
|
NewIp6AndPort(net.ParseIP("1::1"), 1), // this is a dupe
|
|
NewIp6AndPort(net.ParseIP("1::1"), 1), // this is a dupe
|
|
},
|
|
},
|
|
- func(*Ip6AndPort) bool { return true },
|
|
|
|
|
|
+ func(uint32, *Ip6AndPort) bool { return true },
|
|
)
|
|
)
|
|
|
|
|
|
b.Run("no preferred", func(b *testing.B) {
|
|
b.Run("no preferred", func(b *testing.B) {
|