mirror of
https://github.com/tailscale/tailscale.git
synced 2025-01-08 09:07:44 +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 {
|
type EngineStatus struct {
|
||||||
RBytes, WBytes wgengine.ByteCount
|
RBytes, WBytes wgengine.ByteCount
|
||||||
NumLive int
|
NumLive int
|
||||||
|
LiveDERPs int // number of active DERP connections
|
||||||
LivePeers map[tailcfg.NodeKey]wgengine.PeerStatus
|
LivePeers map[tailcfg.NodeKey]wgengine.PeerStatus
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -520,6 +520,7 @@ func (b *LocalBackend) parseWgStatus(s *wgengine.Status) EngineStatus {
|
|||||||
RBytes: rx,
|
RBytes: rx,
|
||||||
WBytes: tx,
|
WBytes: tx,
|
||||||
NumLive: live,
|
NumLive: live,
|
||||||
|
LiveDERPs: s.DERPs,
|
||||||
LivePeers: peers,
|
LivePeers: peers,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -710,7 +711,7 @@ func (b *LocalBackend) nextState() State {
|
|||||||
// (if we get here, we know MachineAuthorized == true)
|
// (if we get here, we know MachineAuthorized == true)
|
||||||
return Starting
|
return Starting
|
||||||
} else if state == Starting {
|
} else if state == Starting {
|
||||||
if b.EngineStatus().NumLive > 0 {
|
if st := b.EngineStatus(); st.NumLive > 0 || st.LiveDERPs > 0 {
|
||||||
return Running
|
return Running
|
||||||
} else {
|
} else {
|
||||||
return state
|
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) SetMark(value uint32) error { return nil }
|
||||||
func (c *Conn) LastMark() uint32 { return 0 }
|
func (c *Conn) LastMark() uint32 { return 0 }
|
||||||
|
|
||||||
|
@ -530,6 +530,7 @@ func (e *userspaceEngine) getStatus() (*Status, error) {
|
|||||||
return &Status{
|
return &Status{
|
||||||
LocalAddrs: append([]string(nil), e.endpoints...),
|
LocalAddrs: append([]string(nil), e.endpoints...),
|
||||||
Peers: peers,
|
Peers: peers,
|
||||||
|
DERPs: e.magicConn.DERPs(),
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,6 +32,7 @@ type PeerStatus struct {
|
|||||||
type Status struct {
|
type Status struct {
|
||||||
Peers []PeerStatus
|
Peers []PeerStatus
|
||||||
LocalAddrs []string // TODO(crawshaw): []wgcfg.Endpoint?
|
LocalAddrs []string // TODO(crawshaw): []wgcfg.Endpoint?
|
||||||
|
DERPs int // number of active DERP connections
|
||||||
}
|
}
|
||||||
|
|
||||||
// StatusCallback is the type of status callbacks used by
|
// StatusCallback is the type of status callbacks used by
|
||||||
|
Loading…
x
Reference in New Issue
Block a user