mirror of
https://github.com/slackhq/nebula.git
synced 2025-12-06 02:30:57 -08:00
Rework some things into packages (#489)
This commit is contained in:
parent
1f75fb3c73
commit
bcabcfdaca
73 changed files with 2526 additions and 2374 deletions
|
|
@ -4,6 +4,7 @@ import (
|
|||
"net"
|
||||
"testing"
|
||||
|
||||
"github.com/slackhq/nebula/iputil"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
|
|
@ -13,18 +14,18 @@ func TestRemoteList_Rebuild(t *testing.T) {
|
|||
0,
|
||||
0,
|
||||
[]*Ip4AndPort{
|
||||
{Ip: ip2int(net.ParseIP("70.199.182.92")), Port: 1475}, // this is duped
|
||||
{Ip: ip2int(net.ParseIP("172.17.0.182")), Port: 10101},
|
||||
{Ip: ip2int(net.ParseIP("172.17.1.1")), Port: 10101}, // this is duped
|
||||
{Ip: ip2int(net.ParseIP("172.18.0.1")), Port: 10101}, // this is duped
|
||||
{Ip: ip2int(net.ParseIP("172.18.0.1")), Port: 10101}, // this is a dupe
|
||||
{Ip: ip2int(net.ParseIP("172.19.0.1")), Port: 10101},
|
||||
{Ip: ip2int(net.ParseIP("172.31.0.1")), Port: 10101},
|
||||
{Ip: ip2int(net.ParseIP("172.17.1.1")), Port: 10101}, // this is a dupe
|
||||
{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: uint32(iputil.Ip2VpnIp(net.ParseIP("70.199.182.92"))), Port: 1475}, // this is duped
|
||||
{Ip: uint32(iputil.Ip2VpnIp(net.ParseIP("172.17.0.182"))), Port: 10101},
|
||||
{Ip: uint32(iputil.Ip2VpnIp(net.ParseIP("172.17.1.1"))), Port: 10101}, // this is duped
|
||||
{Ip: uint32(iputil.Ip2VpnIp(net.ParseIP("172.18.0.1"))), Port: 10101}, // this is duped
|
||||
{Ip: uint32(iputil.Ip2VpnIp(net.ParseIP("172.18.0.1"))), Port: 10101}, // this is a dupe
|
||||
{Ip: uint32(iputil.Ip2VpnIp(net.ParseIP("172.19.0.1"))), Port: 10101},
|
||||
{Ip: uint32(iputil.Ip2VpnIp(net.ParseIP("172.31.0.1"))), Port: 10101},
|
||||
{Ip: uint32(iputil.Ip2VpnIp(net.ParseIP("172.17.1.1"))), Port: 10101}, // this is a dupe
|
||||
{Ip: uint32(iputil.Ip2VpnIp(net.ParseIP("70.199.182.92"))), Port: 1476}, // almost dupe of 0 with a diff port
|
||||
{Ip: uint32(iputil.Ip2VpnIp(net.ParseIP("70.199.182.92"))), Port: 1475}, // this is a dupe
|
||||
},
|
||||
func(uint32, *Ip4AndPort) bool { return true },
|
||||
func(iputil.VpnIp, *Ip4AndPort) bool { return true },
|
||||
)
|
||||
|
||||
rl.unlockedSetV6(
|
||||
|
|
@ -37,7 +38,7 @@ func TestRemoteList_Rebuild(t *testing.T) {
|
|||
NewIp6AndPort(net.ParseIP("1::1"), 1), // this is a dupe
|
||||
NewIp6AndPort(net.ParseIP("1::1"), 2), // this is a dupe
|
||||
},
|
||||
func(uint32, *Ip6AndPort) bool { return true },
|
||||
func(iputil.VpnIp, *Ip6AndPort) bool { return true },
|
||||
)
|
||||
|
||||
rl.Rebuild([]*net.IPNet{})
|
||||
|
|
@ -106,16 +107,16 @@ func BenchmarkFullRebuild(b *testing.B) {
|
|||
0,
|
||||
0,
|
||||
[]*Ip4AndPort{
|
||||
{Ip: ip2int(net.ParseIP("70.199.182.92")), Port: 1475},
|
||||
{Ip: ip2int(net.ParseIP("172.17.0.182")), Port: 10101},
|
||||
{Ip: ip2int(net.ParseIP("172.17.1.1")), Port: 10101},
|
||||
{Ip: ip2int(net.ParseIP("172.18.0.1")), Port: 10101},
|
||||
{Ip: ip2int(net.ParseIP("172.19.0.1")), Port: 10101},
|
||||
{Ip: ip2int(net.ParseIP("172.31.0.1")), Port: 10101},
|
||||
{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: uint32(iputil.Ip2VpnIp(net.ParseIP("70.199.182.92"))), Port: 1475},
|
||||
{Ip: uint32(iputil.Ip2VpnIp(net.ParseIP("172.17.0.182"))), Port: 10101},
|
||||
{Ip: uint32(iputil.Ip2VpnIp(net.ParseIP("172.17.1.1"))), Port: 10101},
|
||||
{Ip: uint32(iputil.Ip2VpnIp(net.ParseIP("172.18.0.1"))), Port: 10101},
|
||||
{Ip: uint32(iputil.Ip2VpnIp(net.ParseIP("172.19.0.1"))), Port: 10101},
|
||||
{Ip: uint32(iputil.Ip2VpnIp(net.ParseIP("172.31.0.1"))), Port: 10101},
|
||||
{Ip: uint32(iputil.Ip2VpnIp(net.ParseIP("172.17.1.1"))), Port: 10101}, // this is a dupe
|
||||
{Ip: uint32(iputil.Ip2VpnIp(net.ParseIP("70.199.182.92"))), Port: 1476}, // dupe of 0 with a diff port
|
||||
},
|
||||
func(uint32, *Ip4AndPort) bool { return true },
|
||||
func(iputil.VpnIp, *Ip4AndPort) bool { return true },
|
||||
)
|
||||
|
||||
rl.unlockedSetV6(
|
||||
|
|
@ -127,7 +128,7 @@ func BenchmarkFullRebuild(b *testing.B) {
|
|||
NewIp6AndPort(net.ParseIP("1:100::1"), 1),
|
||||
NewIp6AndPort(net.ParseIP("1::1"), 1), // this is a dupe
|
||||
},
|
||||
func(uint32, *Ip6AndPort) bool { return true },
|
||||
func(iputil.VpnIp, *Ip6AndPort) bool { return true },
|
||||
)
|
||||
|
||||
b.Run("no preferred", func(b *testing.B) {
|
||||
|
|
@ -171,16 +172,16 @@ func BenchmarkSortRebuild(b *testing.B) {
|
|||
0,
|
||||
0,
|
||||
[]*Ip4AndPort{
|
||||
{Ip: ip2int(net.ParseIP("70.199.182.92")), Port: 1475},
|
||||
{Ip: ip2int(net.ParseIP("172.17.0.182")), Port: 10101},
|
||||
{Ip: ip2int(net.ParseIP("172.17.1.1")), Port: 10101},
|
||||
{Ip: ip2int(net.ParseIP("172.18.0.1")), Port: 10101},
|
||||
{Ip: ip2int(net.ParseIP("172.19.0.1")), Port: 10101},
|
||||
{Ip: ip2int(net.ParseIP("172.31.0.1")), Port: 10101},
|
||||
{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: uint32(iputil.Ip2VpnIp(net.ParseIP("70.199.182.92"))), Port: 1475},
|
||||
{Ip: uint32(iputil.Ip2VpnIp(net.ParseIP("172.17.0.182"))), Port: 10101},
|
||||
{Ip: uint32(iputil.Ip2VpnIp(net.ParseIP("172.17.1.1"))), Port: 10101},
|
||||
{Ip: uint32(iputil.Ip2VpnIp(net.ParseIP("172.18.0.1"))), Port: 10101},
|
||||
{Ip: uint32(iputil.Ip2VpnIp(net.ParseIP("172.19.0.1"))), Port: 10101},
|
||||
{Ip: uint32(iputil.Ip2VpnIp(net.ParseIP("172.31.0.1"))), Port: 10101},
|
||||
{Ip: uint32(iputil.Ip2VpnIp(net.ParseIP("172.17.1.1"))), Port: 10101}, // this is a dupe
|
||||
{Ip: uint32(iputil.Ip2VpnIp(net.ParseIP("70.199.182.92"))), Port: 1476}, // dupe of 0 with a diff port
|
||||
},
|
||||
func(uint32, *Ip4AndPort) bool { return true },
|
||||
func(iputil.VpnIp, *Ip4AndPort) bool { return true },
|
||||
)
|
||||
|
||||
rl.unlockedSetV6(
|
||||
|
|
@ -192,7 +193,7 @@ func BenchmarkSortRebuild(b *testing.B) {
|
|||
NewIp6AndPort(net.ParseIP("1:100::1"), 1),
|
||||
NewIp6AndPort(net.ParseIP("1::1"), 1), // this is a dupe
|
||||
},
|
||||
func(uint32, *Ip6AndPort) bool { return true },
|
||||
func(iputil.VpnIp, *Ip6AndPort) bool { return true },
|
||||
)
|
||||
|
||||
b.Run("no preferred", func(b *testing.B) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue