|
@@ -86,25 +86,25 @@ func Test_NewConnectionManagerTest(t *testing.T) {
|
|
|
// We saw traffic out to vpnIp
|
|
// We saw traffic out to vpnIp
|
|
|
nc.Out(hostinfo)
|
|
nc.Out(hostinfo)
|
|
|
nc.In(hostinfo)
|
|
nc.In(hostinfo)
|
|
|
- assert.False(t, hostinfo.pendingDeletion.Load())
|
|
|
|
|
|
|
+ assert.False(t, hostinfo.isPendingDeletion())
|
|
|
assert.Contains(t, nc.hostMap.Hosts, hostinfo.vpnAddrs[0])
|
|
assert.Contains(t, nc.hostMap.Hosts, hostinfo.vpnAddrs[0])
|
|
|
assert.Contains(t, nc.hostMap.Indexes, hostinfo.localIndexId)
|
|
assert.Contains(t, nc.hostMap.Indexes, hostinfo.localIndexId)
|
|
|
- assert.True(t, hostinfo.out.Load())
|
|
|
|
|
- assert.True(t, hostinfo.in.Load())
|
|
|
|
|
|
|
+ assert.True(t, hostinfo.sentSinceCheck())
|
|
|
|
|
+ assert.True(t, (hostinfo.state.Load()&stateIn != 0))
|
|
|
|
|
|
|
|
// Do a traffic check tick, should not be pending deletion but should not have any in/out packets recorded
|
|
// Do a traffic check tick, should not be pending deletion but should not have any in/out packets recorded
|
|
|
nc.doTrafficCheck(hostinfo.localIndexId, p, nb, out, time.Now())
|
|
nc.doTrafficCheck(hostinfo.localIndexId, p, nb, out, time.Now())
|
|
|
- assert.False(t, hostinfo.pendingDeletion.Load())
|
|
|
|
|
- assert.False(t, hostinfo.out.Load())
|
|
|
|
|
- assert.False(t, hostinfo.in.Load())
|
|
|
|
|
|
|
+ assert.False(t, hostinfo.isPendingDeletion())
|
|
|
|
|
+ assert.False(t, hostinfo.sentSinceCheck())
|
|
|
|
|
+ assert.False(t, (hostinfo.state.Load()&stateIn != 0))
|
|
|
|
|
|
|
|
// Do another traffic check tick, this host should be pending deletion now
|
|
// Do another traffic check tick, this host should be pending deletion now
|
|
|
nc.Out(hostinfo)
|
|
nc.Out(hostinfo)
|
|
|
- assert.True(t, hostinfo.out.Load())
|
|
|
|
|
|
|
+ assert.True(t, hostinfo.sentSinceCheck())
|
|
|
nc.doTrafficCheck(hostinfo.localIndexId, p, nb, out, time.Now())
|
|
nc.doTrafficCheck(hostinfo.localIndexId, p, nb, out, time.Now())
|
|
|
- assert.True(t, hostinfo.pendingDeletion.Load())
|
|
|
|
|
- assert.False(t, hostinfo.out.Load())
|
|
|
|
|
- assert.False(t, hostinfo.in.Load())
|
|
|
|
|
|
|
+ assert.True(t, hostinfo.isPendingDeletion())
|
|
|
|
|
+ assert.False(t, hostinfo.sentSinceCheck())
|
|
|
|
|
+ assert.False(t, (hostinfo.state.Load()&stateIn != 0))
|
|
|
assert.Contains(t, nc.hostMap.Indexes, hostinfo.localIndexId)
|
|
assert.Contains(t, nc.hostMap.Indexes, hostinfo.localIndexId)
|
|
|
assert.Contains(t, nc.hostMap.Hosts, hostinfo.vpnAddrs[0])
|
|
assert.Contains(t, nc.hostMap.Hosts, hostinfo.vpnAddrs[0])
|
|
|
|
|
|
|
@@ -168,33 +168,33 @@ func Test_NewConnectionManagerTest2(t *testing.T) {
|
|
|
// We saw traffic out to vpnIp
|
|
// We saw traffic out to vpnIp
|
|
|
nc.Out(hostinfo)
|
|
nc.Out(hostinfo)
|
|
|
nc.In(hostinfo)
|
|
nc.In(hostinfo)
|
|
|
- assert.True(t, hostinfo.in.Load())
|
|
|
|
|
- assert.True(t, hostinfo.out.Load())
|
|
|
|
|
- assert.False(t, hostinfo.pendingDeletion.Load())
|
|
|
|
|
|
|
+ assert.True(t, (hostinfo.state.Load()&stateIn != 0))
|
|
|
|
|
+ assert.True(t, hostinfo.sentSinceCheck())
|
|
|
|
|
+ assert.False(t, hostinfo.isPendingDeletion())
|
|
|
assert.Contains(t, nc.hostMap.Hosts, hostinfo.vpnAddrs[0])
|
|
assert.Contains(t, nc.hostMap.Hosts, hostinfo.vpnAddrs[0])
|
|
|
assert.Contains(t, nc.hostMap.Indexes, hostinfo.localIndexId)
|
|
assert.Contains(t, nc.hostMap.Indexes, hostinfo.localIndexId)
|
|
|
|
|
|
|
|
// Do a traffic check tick, should not be pending deletion but should not have any in/out packets recorded
|
|
// Do a traffic check tick, should not be pending deletion but should not have any in/out packets recorded
|
|
|
nc.doTrafficCheck(hostinfo.localIndexId, p, nb, out, time.Now())
|
|
nc.doTrafficCheck(hostinfo.localIndexId, p, nb, out, time.Now())
|
|
|
- assert.False(t, hostinfo.pendingDeletion.Load())
|
|
|
|
|
- assert.False(t, hostinfo.out.Load())
|
|
|
|
|
- assert.False(t, hostinfo.in.Load())
|
|
|
|
|
|
|
+ assert.False(t, hostinfo.isPendingDeletion())
|
|
|
|
|
+ assert.False(t, hostinfo.sentSinceCheck())
|
|
|
|
|
+ assert.False(t, (hostinfo.state.Load()&stateIn != 0))
|
|
|
|
|
|
|
|
// Do another traffic check tick, this host should be pending deletion now
|
|
// Do another traffic check tick, this host should be pending deletion now
|
|
|
nc.Out(hostinfo)
|
|
nc.Out(hostinfo)
|
|
|
nc.doTrafficCheck(hostinfo.localIndexId, p, nb, out, time.Now())
|
|
nc.doTrafficCheck(hostinfo.localIndexId, p, nb, out, time.Now())
|
|
|
- assert.True(t, hostinfo.pendingDeletion.Load())
|
|
|
|
|
- assert.False(t, hostinfo.out.Load())
|
|
|
|
|
- assert.False(t, hostinfo.in.Load())
|
|
|
|
|
|
|
+ assert.True(t, hostinfo.isPendingDeletion())
|
|
|
|
|
+ assert.False(t, hostinfo.sentSinceCheck())
|
|
|
|
|
+ assert.False(t, (hostinfo.state.Load()&stateIn != 0))
|
|
|
assert.Contains(t, nc.hostMap.Indexes, hostinfo.localIndexId)
|
|
assert.Contains(t, nc.hostMap.Indexes, hostinfo.localIndexId)
|
|
|
assert.Contains(t, nc.hostMap.Hosts, hostinfo.vpnAddrs[0])
|
|
assert.Contains(t, nc.hostMap.Hosts, hostinfo.vpnAddrs[0])
|
|
|
|
|
|
|
|
// We saw traffic, should no longer be pending deletion
|
|
// We saw traffic, should no longer be pending deletion
|
|
|
nc.In(hostinfo)
|
|
nc.In(hostinfo)
|
|
|
nc.doTrafficCheck(hostinfo.localIndexId, p, nb, out, time.Now())
|
|
nc.doTrafficCheck(hostinfo.localIndexId, p, nb, out, time.Now())
|
|
|
- assert.False(t, hostinfo.pendingDeletion.Load())
|
|
|
|
|
- assert.False(t, hostinfo.out.Load())
|
|
|
|
|
- assert.False(t, hostinfo.in.Load())
|
|
|
|
|
|
|
+ assert.False(t, hostinfo.isPendingDeletion())
|
|
|
|
|
+ assert.False(t, hostinfo.sentSinceCheck())
|
|
|
|
|
+ assert.False(t, (hostinfo.state.Load()&stateIn != 0))
|
|
|
assert.Contains(t, nc.hostMap.Indexes, hostinfo.localIndexId)
|
|
assert.Contains(t, nc.hostMap.Indexes, hostinfo.localIndexId)
|
|
|
assert.Contains(t, nc.hostMap.Hosts, hostinfo.vpnAddrs[0])
|
|
assert.Contains(t, nc.hostMap.Hosts, hostinfo.vpnAddrs[0])
|
|
|
}
|
|
}
|
|
@@ -326,31 +326,31 @@ func Test_NewConnectionManager_DisconnectInactive(t *testing.T) {
|
|
|
// Do a traffic check tick, in and out should be cleared but should not be pending deletion
|
|
// Do a traffic check tick, in and out should be cleared but should not be pending deletion
|
|
|
nc.Out(hostinfo)
|
|
nc.Out(hostinfo)
|
|
|
nc.In(hostinfo)
|
|
nc.In(hostinfo)
|
|
|
- assert.True(t, hostinfo.out.Load())
|
|
|
|
|
- assert.True(t, hostinfo.in.Load())
|
|
|
|
|
|
|
+ assert.True(t, hostinfo.sentSinceCheck())
|
|
|
|
|
+ assert.True(t, (hostinfo.state.Load()&stateIn != 0))
|
|
|
|
|
|
|
|
now := time.Now()
|
|
now := time.Now()
|
|
|
decision, _, _ := nc.makeTrafficDecision(hostinfo.localIndexId, now)
|
|
decision, _, _ := nc.makeTrafficDecision(hostinfo.localIndexId, now)
|
|
|
assert.Equal(t, tryRehandshake, decision)
|
|
assert.Equal(t, tryRehandshake, decision)
|
|
|
assert.Equal(t, now, hostinfo.lastUsed)
|
|
assert.Equal(t, now, hostinfo.lastUsed)
|
|
|
- assert.False(t, hostinfo.pendingDeletion.Load())
|
|
|
|
|
- assert.False(t, hostinfo.out.Load())
|
|
|
|
|
- assert.False(t, hostinfo.in.Load())
|
|
|
|
|
|
|
+ assert.False(t, hostinfo.isPendingDeletion())
|
|
|
|
|
+ assert.False(t, hostinfo.sentSinceCheck())
|
|
|
|
|
+ assert.False(t, (hostinfo.state.Load()&stateIn != 0))
|
|
|
|
|
|
|
|
decision, _, _ = nc.makeTrafficDecision(hostinfo.localIndexId, now.Add(time.Second*5))
|
|
decision, _, _ = nc.makeTrafficDecision(hostinfo.localIndexId, now.Add(time.Second*5))
|
|
|
assert.Equal(t, doNothing, decision)
|
|
assert.Equal(t, doNothing, decision)
|
|
|
assert.Equal(t, now, hostinfo.lastUsed)
|
|
assert.Equal(t, now, hostinfo.lastUsed)
|
|
|
- assert.False(t, hostinfo.pendingDeletion.Load())
|
|
|
|
|
- assert.False(t, hostinfo.out.Load())
|
|
|
|
|
- assert.False(t, hostinfo.in.Load())
|
|
|
|
|
|
|
+ assert.False(t, hostinfo.isPendingDeletion())
|
|
|
|
|
+ assert.False(t, hostinfo.sentSinceCheck())
|
|
|
|
|
+ assert.False(t, (hostinfo.state.Load()&stateIn != 0))
|
|
|
|
|
|
|
|
// Do another traffic check tick, should still not be pending deletion
|
|
// Do another traffic check tick, should still not be pending deletion
|
|
|
decision, _, _ = nc.makeTrafficDecision(hostinfo.localIndexId, now.Add(time.Second*10))
|
|
decision, _, _ = nc.makeTrafficDecision(hostinfo.localIndexId, now.Add(time.Second*10))
|
|
|
assert.Equal(t, doNothing, decision)
|
|
assert.Equal(t, doNothing, decision)
|
|
|
assert.Equal(t, now, hostinfo.lastUsed)
|
|
assert.Equal(t, now, hostinfo.lastUsed)
|
|
|
- assert.False(t, hostinfo.pendingDeletion.Load())
|
|
|
|
|
- assert.False(t, hostinfo.out.Load())
|
|
|
|
|
- assert.False(t, hostinfo.in.Load())
|
|
|
|
|
|
|
+ assert.False(t, hostinfo.isPendingDeletion())
|
|
|
|
|
+ assert.False(t, hostinfo.sentSinceCheck())
|
|
|
|
|
+ assert.False(t, (hostinfo.state.Load()&stateIn != 0))
|
|
|
assert.Contains(t, nc.hostMap.Indexes, hostinfo.localIndexId)
|
|
assert.Contains(t, nc.hostMap.Indexes, hostinfo.localIndexId)
|
|
|
assert.Contains(t, nc.hostMap.Hosts, hostinfo.vpnAddrs[0])
|
|
assert.Contains(t, nc.hostMap.Hosts, hostinfo.vpnAddrs[0])
|
|
|
|
|
|
|
@@ -358,9 +358,9 @@ func Test_NewConnectionManager_DisconnectInactive(t *testing.T) {
|
|
|
decision, _, _ = nc.makeTrafficDecision(hostinfo.localIndexId, now.Add(time.Minute*10))
|
|
decision, _, _ = nc.makeTrafficDecision(hostinfo.localIndexId, now.Add(time.Minute*10))
|
|
|
assert.Equal(t, closeTunnel, decision)
|
|
assert.Equal(t, closeTunnel, decision)
|
|
|
assert.Equal(t, now, hostinfo.lastUsed)
|
|
assert.Equal(t, now, hostinfo.lastUsed)
|
|
|
- assert.False(t, hostinfo.pendingDeletion.Load())
|
|
|
|
|
- assert.False(t, hostinfo.out.Load())
|
|
|
|
|
- assert.False(t, hostinfo.in.Load())
|
|
|
|
|
|
|
+ assert.False(t, hostinfo.isPendingDeletion())
|
|
|
|
|
+ assert.False(t, hostinfo.sentSinceCheck())
|
|
|
|
|
+ assert.False(t, (hostinfo.state.Load()&stateIn != 0))
|
|
|
assert.Contains(t, nc.hostMap.Indexes, hostinfo.localIndexId)
|
|
assert.Contains(t, nc.hostMap.Indexes, hostinfo.localIndexId)
|
|
|
assert.Contains(t, nc.hostMap.Hosts, hostinfo.vpnAddrs[0])
|
|
assert.Contains(t, nc.hostMap.Hosts, hostinfo.vpnAddrs[0])
|
|
|
}
|
|
}
|