Clean up a hostinfo to reduce memory usage (#955)

This commit is contained in:
Nate Brown
2023-11-02 16:53:59 -05:00
committed by GitHub
parent 276978377a
commit a44e1b8b05
10 changed files with 240 additions and 265 deletions

View File

@@ -5,6 +5,7 @@ import (
"testing"
"time"
"github.com/slackhq/nebula/cert"
"github.com/slackhq/nebula/header"
"github.com/slackhq/nebula/iputil"
"github.com/slackhq/nebula/test"
@@ -21,7 +22,16 @@ func Test_NewHandshakeManagerVpnIp(t *testing.T) {
mainHM := NewHostMap(l, vpncidr, preferredRanges)
lh := newTestLighthouse()
cs := &CertState{
RawCertificate: []byte{},
PrivateKey: []byte{},
Certificate: &cert.NebulaCertificate{},
RawCertificateNoKey: []byte{},
}
blah := NewHandshakeManager(l, mainHM, lh, &udp.NoopConn{}, defaultHandshakeConfig)
blah.f = &Interface{handshakeManager: blah, pki: &PKI{}, l: l}
blah.f.pki.cs.Store(cs)
now := time.Now()
blah.NextOutboundHandshakeTimerTick(now)
@@ -31,7 +41,6 @@ func Test_NewHandshakeManagerVpnIp(t *testing.T) {
assert.Same(t, i, i2)
i.remotes = NewRemoteList(nil)
i.HandshakeReady = true
// Adding something to pending should not affect the main hostmap
assert.Len(t, mainHM.Hosts, 0)