mirror of
https://github.com/slackhq/nebula.git
synced 2025-11-08 21:53:59 +01:00
more
This commit is contained in:
parent
94dd14c1a3
commit
1be8dc43a7
@ -64,7 +64,7 @@ func newConnectionManager(ctx context.Context, l *logrus.Logger, intf *Interface
|
|||||||
outLock: newSyncRWMutex("connection-manager-out"),
|
outLock: newSyncRWMutex("connection-manager-out"),
|
||||||
relayUsed: make(map[uint32]struct{}),
|
relayUsed: make(map[uint32]struct{}),
|
||||||
relayUsedLock: newSyncRWMutex("connection-manager-relay-used"),
|
relayUsedLock: newSyncRWMutex("connection-manager-relay-used"),
|
||||||
trafficTimer: NewLockingTimerWheel[uint32](time.Millisecond*500, max),
|
trafficTimer: NewLockingTimerWheel[uint32]("connection-manager-timer", time.Millisecond*500, max),
|
||||||
intf: intf,
|
intf: intf,
|
||||||
pendingDeletion: make(map[uint32]struct{}),
|
pendingDeletion: make(map[uint32]struct{}),
|
||||||
checkInterval: checkInterval,
|
checkInterval: checkInterval,
|
||||||
|
|||||||
@ -5,7 +5,6 @@ import (
|
|||||||
"net"
|
"net"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
|
||||||
|
|
||||||
"github.com/miekg/dns"
|
"github.com/miekg/dns"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
@ -20,15 +19,16 @@ var dnsServer *dns.Server
|
|||||||
var dnsAddr string
|
var dnsAddr string
|
||||||
|
|
||||||
type dnsRecords struct {
|
type dnsRecords struct {
|
||||||
sync.RWMutex
|
syncRWMutex
|
||||||
dnsMap map[string]string
|
dnsMap map[string]string
|
||||||
hostMap *HostMap
|
hostMap *HostMap
|
||||||
}
|
}
|
||||||
|
|
||||||
func newDnsRecords(hostMap *HostMap) *dnsRecords {
|
func newDnsRecords(hostMap *HostMap) *dnsRecords {
|
||||||
return &dnsRecords{
|
return &dnsRecords{
|
||||||
dnsMap: make(map[string]string),
|
syncRWMutex: newSyncRWMutex("dns-records"),
|
||||||
hostMap: hostMap,
|
dnsMap: make(map[string]string),
|
||||||
|
hostMap: hostMap,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -110,7 +110,7 @@ func NewHandshakeManager(l *logrus.Logger, mainHostMap *HostMap, lightHouse *Lig
|
|||||||
outside: outside,
|
outside: outside,
|
||||||
config: config,
|
config: config,
|
||||||
trigger: make(chan iputil.VpnIp, config.triggerBuffer),
|
trigger: make(chan iputil.VpnIp, config.triggerBuffer),
|
||||||
OutboundHandshakeTimer: NewLockingTimerWheel[iputil.VpnIp](config.tryInterval, hsTimeout(config.retries, config.tryInterval)),
|
OutboundHandshakeTimer: NewLockingTimerWheel[iputil.VpnIp]("handshake-manager-timer", config.tryInterval, hsTimeout(config.retries, config.tryInterval)),
|
||||||
messageMetrics: config.messageMetrics,
|
messageMetrics: config.messageMetrics,
|
||||||
metricInitiated: metrics.GetOrRegisterCounter("handshake_manager.initiated", nil),
|
metricInitiated: metrics.GetOrRegisterCounter("handshake_manager.initiated", nil),
|
||||||
metricTimedOut: metrics.GetOrRegisterCounter("handshake_manager.timed_out", nil),
|
metricTimedOut: metrics.GetOrRegisterCounter("handshake_manager.timed_out", nil),
|
||||||
|
|||||||
@ -21,9 +21,11 @@ var allowedConcurrentLocks = map[mutexKey][]mutexKey{
|
|||||||
"connection-manager-in": {"hostmap"},
|
"connection-manager-in": {"hostmap"},
|
||||||
"connection-manager-out": {"connection-state-write", "connection-manager-in"},
|
"connection-manager-out": {"connection-state-write", "connection-manager-in"},
|
||||||
"connection-manager-relay-used": {"handshake-hostinfo"},
|
"connection-manager-relay-used": {"handshake-hostinfo"},
|
||||||
|
"connection-manager-timer": {"connection-manager-out"},
|
||||||
"connection-state-write": {"hostmap"},
|
"connection-state-write": {"hostmap"},
|
||||||
"firewall-conntrack": {"handshake-hostinfo"},
|
"firewall-conntrack": {"handshake-hostinfo"},
|
||||||
"handshake-manager": {"hostmap"},
|
"handshake-manager": {"hostmap"},
|
||||||
|
"handshake-manager-timer": {"handshake-manager"},
|
||||||
"hostmap": {"handshake-hostinfo"},
|
"hostmap": {"handshake-hostinfo"},
|
||||||
"lighthouse": {"handshake-manager"},
|
"lighthouse": {"handshake-manager"},
|
||||||
"relay-state": {"hostmap", "connection-manager-relay-used"},
|
"relay-state": {"hostmap", "connection-manager-relay-used"},
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
package nebula
|
package nebula
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"sync"
|
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -34,7 +33,7 @@ type TimerWheel[T any] struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type LockingTimerWheel[T any] struct {
|
type LockingTimerWheel[T any] struct {
|
||||||
m sync.Mutex
|
m syncMutex
|
||||||
t *TimerWheel[T]
|
t *TimerWheel[T]
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,8 +80,9 @@ func NewTimerWheel[T any](min, max time.Duration) *TimerWheel[T] {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewLockingTimerWheel is version of TimerWheel that is safe for concurrent use with a small performance penalty
|
// NewLockingTimerWheel is version of TimerWheel that is safe for concurrent use with a small performance penalty
|
||||||
func NewLockingTimerWheel[T any](min, max time.Duration) *LockingTimerWheel[T] {
|
func NewLockingTimerWheel[T any](name string, min, max time.Duration) *LockingTimerWheel[T] {
|
||||||
return &LockingTimerWheel[T]{
|
return &LockingTimerWheel[T]{
|
||||||
|
m: newSyncMutex(name),
|
||||||
t: NewTimerWheel[T](min, max),
|
t: NewTimerWheel[T](min, max),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user