mirror of
https://github.com/slackhq/nebula.git
synced 2025-11-11 13:03:57 +01:00
more types
This commit is contained in:
parent
540a171ef8
commit
bcaefce4ac
@ -135,6 +135,7 @@ func ixHandshakeStage1(f *Interface, addr *udp.Addr, via *ViaSender, packet []by
|
||||
HandshakePacket: make(map[uint8][]byte, 0),
|
||||
lastHandshakeTime: hs.Details.Time,
|
||||
relayState: RelayState{
|
||||
syncRWMutex: newSyncRWMutex(mutexKey{Type: mutexKeyTypeRelayState, ID: uint32(vpnIp)}),
|
||||
relays: map[iputil.VpnIp]struct{}{},
|
||||
relayForByIp: map[iputil.VpnIp]*Relay{},
|
||||
relayForByIdx: map[uint32]*Relay{},
|
||||
|
||||
@ -389,6 +389,7 @@ func (hm *HandshakeManager) StartHandshake(vpnIp iputil.VpnIp, cacheCb func(*Han
|
||||
vpnIp: vpnIp,
|
||||
HandshakePacket: make(map[uint8][]byte, 0),
|
||||
relayState: RelayState{
|
||||
syncRWMutex: newSyncRWMutex(mutexKey{Type: mutexKeyTypeRelayState, ID: uint32(vpnIp)}),
|
||||
relays: map[iputil.VpnIp]struct{}{},
|
||||
relayForByIp: map[iputil.VpnIp]*Relay{},
|
||||
relayForByIdx: map[uint32]*Relay{},
|
||||
|
||||
@ -3,7 +3,6 @@ package nebula
|
||||
import (
|
||||
"errors"
|
||||
"net"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
|
||||
@ -67,7 +66,7 @@ type HostMap struct {
|
||||
// struct, make a copy of an existing value, edit the fileds in the copy, and
|
||||
// then store a pointer to the new copy in both realyForBy* maps.
|
||||
type RelayState struct {
|
||||
sync.RWMutex
|
||||
syncRWMutex
|
||||
|
||||
relays map[iputil.VpnIp]struct{} // Set of VpnIp's of Hosts to use as relays to access this peer
|
||||
relayForByIp map[iputil.VpnIp]*Relay // Maps VpnIps of peers for which this HostInfo is a relay to some Relay info
|
||||
|
||||
5
mutex.go
5
mutex.go
@ -8,8 +8,10 @@ const (
|
||||
mutexKeyTypeHostMap mutexKeyType = "hostmap"
|
||||
|
||||
mutexKeyTypeLightHouse = "lighthouse"
|
||||
mutexKeyTypeRemoteList = "remote-list"
|
||||
mutexKeyTypeFirewallConntrack = "firewall-conntrack"
|
||||
mutexKeyTypeHostInfo = "hostinfo"
|
||||
mutexKeyTypeRelayState = "relay-state"
|
||||
mutexKeyTypeHandshakeHostInfo = "handshake-hostinfo"
|
||||
mutexKeyTypeHandshakeManager = "handshake-manager"
|
||||
mutexKeyTypeConnectionStateWrite = "connection-state-write-lock"
|
||||
@ -30,10 +32,13 @@ var allowedConcurrentLocks = map[mutexKeyType][]mutexKeyType{
|
||||
mutexKeyTypeConnectionStateWrite: {mutexKeyTypeHostMap},
|
||||
|
||||
mutexKeyTypeLightHouse: {mutexKeyTypeHandshakeManager},
|
||||
mutexKeyTypeRemoteList: {mutexKeyTypeLightHouse},
|
||||
|
||||
mutexKeyTypeConnectionManagerIn: {mutexKeyTypeHostMap},
|
||||
mutexKeyTypeConnectionManagerOut: {mutexKeyTypeConnectionStateWrite, mutexKeyTypeConnectionManagerIn},
|
||||
mutexKeyTypeConnectionManagerRelayUsed: {mutexKeyTypeHandshakeHostInfo},
|
||||
|
||||
mutexKeyTypeRelayState: {mutexKeyTypeHostMap, mutexKeyTypeConnectionManagerRelayUsed},
|
||||
}
|
||||
|
||||
type mutexKey struct {
|
||||
|
||||
@ -7,7 +7,6 @@ import (
|
||||
"net/netip"
|
||||
"sort"
|
||||
"strconv"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
|
||||
@ -190,7 +189,7 @@ func (hr *hostnamesResults) GetIPs() []netip.AddrPort {
|
||||
// It serves as a local cache of query replies, host update notifications, and locally learned addresses
|
||||
type RemoteList struct {
|
||||
// Every interaction with internals requires a lock!
|
||||
sync.RWMutex
|
||||
syncRWMutex
|
||||
|
||||
// A deduplicated set of addresses. Any accessor should lock beforehand.
|
||||
addrs []*udp.Addr
|
||||
@ -217,10 +216,11 @@ type RemoteList struct {
|
||||
// NewRemoteList creates a new empty RemoteList
|
||||
func NewRemoteList(shouldAdd func(netip.Addr) bool) *RemoteList {
|
||||
return &RemoteList{
|
||||
addrs: make([]*udp.Addr, 0),
|
||||
relays: make([]*iputil.VpnIp, 0),
|
||||
cache: make(map[iputil.VpnIp]*cache),
|
||||
shouldAdd: shouldAdd,
|
||||
syncRWMutex: newSyncRWMutex(mutexKey{Type: mutexKeyTypeRemoteList}),
|
||||
addrs: make([]*udp.Addr, 0),
|
||||
relays: make([]*iputil.VpnIp, 0),
|
||||
cache: make(map[iputil.VpnIp]*cache),
|
||||
shouldAdd: shouldAdd,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user