mirror of
https://github.com/juanfont/headscale.git
synced 2024-12-20 19:09:07 +01:00
Send Online field of tailcfg.Node based on LastSeen
This commit is contained in:
parent
cb88b16207
commit
66fffd69ce
@ -637,6 +637,10 @@ func (machine Machine) toNode(
|
|||||||
|
|
||||||
hostInfo := machine.GetHostInfo()
|
hostInfo := machine.GetHostInfo()
|
||||||
|
|
||||||
|
// A node is Online if it is connected to the control server,
|
||||||
|
// and we now we update LastSeen every keepAliveInterval duration at least.
|
||||||
|
online := machine.LastSeen.After(time.Now().Add(-keepAliveInterval))
|
||||||
|
|
||||||
node := tailcfg.Node{
|
node := tailcfg.Node{
|
||||||
ID: tailcfg.NodeID(machine.ID), // this is the actual ID
|
ID: tailcfg.NodeID(machine.ID), // this is the actual ID
|
||||||
StableID: tailcfg.StableNodeID(
|
StableID: tailcfg.StableNodeID(
|
||||||
@ -653,6 +657,7 @@ func (machine Machine) toNode(
|
|||||||
Endpoints: machine.Endpoints,
|
Endpoints: machine.Endpoints,
|
||||||
DERP: derp,
|
DERP: derp,
|
||||||
|
|
||||||
|
Online: &online,
|
||||||
Hostinfo: hostInfo.View(),
|
Hostinfo: hostInfo.View(),
|
||||||
Created: machine.CreatedAt,
|
Created: machine.CreatedAt,
|
||||||
LastSeen: machine.LastSeen,
|
LastSeen: machine.LastSeen,
|
||||||
|
Loading…
Reference in New Issue
Block a user