mirror of
https://github.com/juanfont/headscale.git
synced 2026-10-26 00:06:53 +09:00
Add isEphemeral() method to Machine
This commit is contained in:
1 parent
6db9656008
commit
4de49f5f49
2 files changed
+7
-2
No files matched your search
@@ -257,8 +257,7 @@ func (h *Headscale) expireEphemeralNodesWorker() {
|
|||||||
|
|
||||||
expiredFound := false
|
expiredFound := false
|
||||||
for _, machine := range machines {
|
for _, machine := range machines {
|
||||||
if machine.AuthKey != nil && machine.LastSeen != nil &&
|
if machine.isEphemeral() && machine.LastSeen != nil &&
|
||||||
machine.AuthKey.Ephemeral &&
|
|
||||||
time.Now().
|
time.Now().
|
||||||
After(machine.LastSeen.Add(h.cfg.EphemeralNodeInactivityTimeout)) {
|
After(machine.LastSeen.Add(h.cfg.EphemeralNodeInactivityTimeout)) {
|
||||||
expiredFound = true
|
expiredFound = true
|
||||||
|
|||||||
@@ -153,6 +153,12 @@ func (machine *Machine) isOnline() bool {
|
|||||||
return machine.LastSeen.After(time.Now().Add(-keepAliveInterval))
|
return machine.LastSeen.After(time.Now().Add(-keepAliveInterval))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// isEphemeral returns if the machine is registered as an Ephemeral node.
|
||||||
|
// https://tailscale.com/kb/1111/ephemeral-nodes/
|
||||||
|
func (machine *Machine) isEphemeral() bool {
|
||||||
|
return machine.AuthKey != nil && machine.AuthKey.Ephemeral
|
||||||
|
}
|
||||||
|
|
||||||
func containsAddresses(inputs []string, addrs []string) bool {
|
func containsAddresses(inputs []string, addrs []string) bool {
|
||||||
for _, addr := range addrs {
|
for _, addr := range addrs {
|
||||||
if containsStr(inputs, addr) {
|
if containsStr(inputs, addr) {
|
||||||
|
|||||||
Reference in new issue
Block a user