mirror of
https://github.com/tailscale/tailscale.git
synced 2025-01-05 14:57:49 +00:00
wgengine, ipn: include number of active DERPs in status
Use this when making the ipn state transition from Starting to Running. This way a network of quiet nodes with no active handshaking will still transition to Active. Signed-off-by: David Crawshaw <crawshaw@tailscale.com>
This commit is contained in:
parent
1ad78ce698
commit
addbdce296
@ -33,6 +33,7 @@ func (s State) String() string {
|
||||
type EngineStatus struct {
|
||||
RBytes, WBytes wgengine.ByteCount
|
||||
NumLive int
|
||||
LiveDERPs int // number of active DERP connections
|
||||
LivePeers map[tailcfg.NodeKey]wgengine.PeerStatus
|
||||
}
|
||||
|
||||
|
@ -520,6 +520,7 @@ func (b *LocalBackend) parseWgStatus(s *wgengine.Status) EngineStatus {
|
||||
RBytes: rx,
|
||||
WBytes: tx,
|
||||
NumLive: live,
|
||||
LiveDERPs: s.DERPs,
|
||||
LivePeers: peers,
|
||||
}
|
||||
}
|
||||
@ -710,7 +711,7 @@ func (b *LocalBackend) nextState() State {
|
||||
// (if we get here, we know MachineAuthorized == true)
|
||||
return Starting
|
||||
} else if state == Starting {
|
||||
if b.EngineStatus().NumLive > 0 {
|
||||
if st := b.EngineStatus(); st.NumLive > 0 || st.LiveDERPs > 0 {
|
||||
return Running
|
||||
} else {
|
||||
return state
|
||||
|
@ -1080,6 +1080,14 @@ func (c *Conn) cleanStaleDerp() {
|
||||
}
|
||||
}
|
||||
|
||||
// DERPs reports the number of active DERP connections.
|
||||
func (c *Conn) DERPs() int {
|
||||
c.mu.Lock()
|
||||
defer c.mu.Unlock()
|
||||
|
||||
return len(c.activeDerp)
|
||||
}
|
||||
|
||||
func (c *Conn) SetMark(value uint32) error { return nil }
|
||||
func (c *Conn) LastMark() uint32 { return 0 }
|
||||
|
||||
|
@ -530,6 +530,7 @@ func (e *userspaceEngine) getStatus() (*Status, error) {
|
||||
return &Status{
|
||||
LocalAddrs: append([]string(nil), e.endpoints...),
|
||||
Peers: peers,
|
||||
DERPs: e.magicConn.DERPs(),
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
@ -32,6 +32,7 @@ type PeerStatus struct {
|
||||
type Status struct {
|
||||
Peers []PeerStatus
|
||||
LocalAddrs []string // TODO(crawshaw): []wgcfg.Endpoint?
|
||||
DERPs int // number of active DERP connections
|
||||
}
|
||||
|
||||
// StatusCallback is the type of status callbacks used by
|
||||
|
Loading…
x
Reference in New Issue
Block a user