optimize usage of bart (#1395)

Use `bart.Lite` and `.Contains` as suggested by the bart maintainer:

- 9455952eed (commitcomment-155362580)
This commit is contained in:
Wade Simmons 2025-04-18 12:37:20 -04:00 committed by GitHub
parent 4eb056af9d
commit b8ea55eb90
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 61 additions and 80 deletions

View file

@ -22,14 +22,12 @@ func (f *Interface) consumeInsidePacket(packet []byte, fwPacket *firewall.Packet
// Ignore local broadcast packets
if f.dropLocalBroadcast {
_, found := f.myBroadcastAddrsTable.Lookup(fwPacket.RemoteAddr)
if found {
if f.myBroadcastAddrsTable.Contains(fwPacket.RemoteAddr) {
return
}
}
_, found := f.myVpnAddrsTable.Lookup(fwPacket.RemoteAddr)
if found {
if f.myVpnAddrsTable.Contains(fwPacket.RemoteAddr) {
// Immediately forward packets from self to self.
// This should only happen on Darwin-based and FreeBSD hosts, which
// routes packets from the Nebula addr to the Nebula addr through the Nebula
@ -130,8 +128,7 @@ func (f *Interface) Handshake(vpnAddr netip.Addr) {
// getOrHandshakeNoRouting returns nil if the vpnAddr is not routable.
// If the 2nd return var is false then the hostinfo is not ready to be used in a tunnel
func (f *Interface) getOrHandshakeNoRouting(vpnAddr netip.Addr, cacheCallback func(*HandshakeHostInfo)) (*HostInfo, bool) {
_, found := f.myVpnNetworksTable.Lookup(vpnAddr)
if found {
if f.myVpnNetworksTable.Contains(vpnAddr) {
return f.handshakeManager.GetOrHandshake(vpnAddr, cacheCallback)
}