diff --git a/connection_manager.go b/connection_manager.go index e3d4a4e50..d2e861647 100644 --- a/connection_manager.go +++ b/connection_manager.go @@ -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. diff --git a/connection_manager_test.go b/connection_manager_test.go index 869527355..5f97cad9d 100644 --- a/connection_manager_test.go +++ b/connection_manager_test.go @@ -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 @@ -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 @@ -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)