Skip to content

Commit

Permalink
Remove resolved notes in connection manager
Browse files Browse the repository at this point in the history
  • Loading branch information
nbrownus committed Jul 5, 2024
1 parent 7ea16be commit c407658
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 28 deletions.
1 change: 0 additions & 1 deletion connection_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,6 @@ func (n *connectionManager) shouldSwapPrimary(current, primary *HostInfo) bool {
// If we are here then we have multiple tunnels for a host pair and neither side believes the same tunnel is primary.
// Let's sort this out.

//TODO: ensure this is still current is < than my vpn ip
if current.vpnIp.Compare(n.intf.myVpnNet.Addr()) < 0 {
// Only one side should flip primary because if both flip then we may never resolve to a single tunnel.
// vpn ip is static across all tunnels for this host pair so lets use that to determine who is flipping.
Expand Down
36 changes: 9 additions & 27 deletions connection_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,9 @@ func newTestLighthouse() *LightHouse {
func Test_NewConnectionManagerTest(t *testing.T) {
l := test.NewLogger()
//_, tuncidr, _ := net.ParseCIDR("1.1.1.1/24")
vpncidr, err := netip.ParsePrefix("172.1.1.1/24")
assert.NoError(t, err)

localrange, err := netip.ParsePrefix("10.1.1.1/24")
assert.NoError(t, err)

vpnIp, err := netip.ParseAddr("172.1.1.2")
assert.NoError(t, err)

vpncidr := netip.MustParsePrefix("172.1.1.1/24")
localrange := netip.MustParsePrefix("10.1.1.1/24")
vpnIp := netip.MustParseAddr("172.1.1.2")
preferredRanges := []netip.Prefix{localrange}

// Very incomplete mock objects
Expand Down Expand Up @@ -124,15 +118,9 @@ func Test_NewConnectionManagerTest(t *testing.T) {
func Test_NewConnectionManagerTest2(t *testing.T) {
l := test.NewLogger()
//_, tuncidr, _ := net.ParseCIDR("1.1.1.1/24")
vpncidr, err := netip.ParsePrefix("172.1.1.1/24")
assert.NoError(t, err)

localrange, err := netip.ParsePrefix("10.1.1.1/24")
assert.NoError(t, err)

vpnIp, err := netip.ParseAddr("172.1.1.2")
assert.NoError(t, err)

vpncidr := netip.MustParsePrefix("172.1.1.1/24")
localrange := netip.MustParsePrefix("10.1.1.1/24")
vpnIp := netip.MustParseAddr("172.1.1.2")
preferredRanges := []netip.Prefix{localrange}

// Very incomplete mock objects
Expand Down Expand Up @@ -222,15 +210,9 @@ func Test_NewConnectionManagerTest_DisconnectInvalid(t *testing.T) {
IP: net.IPv4(172, 1, 1, 2),
Mask: net.IPMask{255, 255, 255, 0},
}
vpncidr, err := netip.ParsePrefix("172.1.1.1/24")
assert.NoError(t, err)

localrange, err := netip.ParsePrefix("10.1.1.1/24")
assert.NoError(t, err)

vpnIp, err := netip.ParseAddr("172.1.1.2")
assert.NoError(t, err)

vpncidr := netip.MustParsePrefix("172.1.1.1/24")
localrange := netip.MustParsePrefix("10.1.1.1/24")
vpnIp := netip.MustParseAddr("172.1.1.2")
preferredRanges := []netip.Prefix{localrange}
hostMap := newHostMap(l, vpncidr)
hostMap.preferredRanges.Store(&preferredRanges)
Expand Down

0 comments on commit c407658

Please sign in to comment.