mirror of
https://github.com/juanfont/headscale.git
synced 2026-10-31 10:44:07 +09:00
Add cache for requested expiry times
This commit adds a sentral cache to keep track of clients whom has requested an expiry time, but were we need to keep hold of it until the second request comes in.
This commit is contained in:
1 parent
e600ead3e9
commit
021c464148
4 files changed
+67
-11
No files matched your search
@@ -19,10 +19,13 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
reservedResponseHeaderSize = 4
|
||||
RegisterMethodAuthKey = "authKey"
|
||||
RegisterMethodOIDC = "oidc"
|
||||
RegisterMethodCLI = "cli"
|
||||
reservedResponseHeaderSize = 4
|
||||
RegisterMethodAuthKey = "authKey"
|
||||
RegisterMethodOIDC = "oidc"
|
||||
RegisterMethodCLI = "cli"
|
||||
ErrRegisterMethodCLIDoesNotSupportExpire = Error(
|
||||
"machines registered with CLI does not support expire",
|
||||
)
|
||||
)
|
||||
|
||||
// KeyHandler provides the Headscale pub key
|
||||
@@ -441,7 +444,16 @@ func (h *Headscale) handleMachineRegistrationNew(
|
||||
}
|
||||
|
||||
if !reqisterRequest.Expiry.IsZero() {
|
||||
machine.Expiry = &reqisterRequest.Expiry
|
||||
log.Trace().
|
||||
Caller().
|
||||
Str("machine", machine.Name).
|
||||
Time("expiry", reqisterRequest.Expiry).
|
||||
Msg("Non-zero expiry time requested, adding to cache")
|
||||
h.requestedExpiryCache.Set(
|
||||
idKey.HexString(),
|
||||
reqisterRequest.Expiry,
|
||||
requestedExpiryCacheExpiration,
|
||||
)
|
||||
}
|
||||
|
||||
machine.NodeKey = wgkey.Key(reqisterRequest.NodeKey).HexString() // save the NodeKey
|
||||
|
||||
Reference in new issue
Block a user