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:
parent
e600ead3e9
commit
021c464148
4 changed files with 67 additions and 11 deletions
23
app.go
23
app.go
|
@ -53,6 +53,9 @@ const (
|
|||
updateInterval = 5000
|
||||
HTTPReadTimeout = 30 * time.Second
|
||||
|
||||
requestedExpiryCacheExpiration = time.Minute * 5
|
||||
requestedExpiryCacheCleanupInterval = time.Minute * 10
|
||||
|
||||
errUnsupportedDatabase = Error("unsupported DB")
|
||||
errUnsupportedLetsEncryptChallengeType = Error(
|
||||
"unknown value for Lets Encrypt challenge type",
|
||||
|
@ -139,6 +142,8 @@ type Headscale struct {
|
|||
oidcProvider *oidc.Provider
|
||||
oauth2Config *oauth2.Config
|
||||
oidcStateCache *cache.Cache
|
||||
|
||||
requestedExpiryCache *cache.Cache
|
||||
}
|
||||
|
||||
// NewHeadscale returns the Headscale app.
|
||||
|
@ -171,13 +176,19 @@ func NewHeadscale(cfg Config) (*Headscale, error) {
|
|||
return nil, errUnsupportedDatabase
|
||||
}
|
||||
|
||||
requestedExpiryCache := cache.New(
|
||||
requestedExpiryCacheExpiration,
|
||||
requestedExpiryCacheCleanupInterval,
|
||||
)
|
||||
|
||||
app := Headscale{
|
||||
cfg: cfg,
|
||||
dbType: cfg.DBtype,
|
||||
dbString: dbString,
|
||||
privateKey: privKey,
|
||||
publicKey: &pubKey,
|
||||
aclRules: tailcfg.FilterAllowAll, // default allowall
|
||||
cfg: cfg,
|
||||
dbType: cfg.DBtype,
|
||||
dbString: dbString,
|
||||
privateKey: privKey,
|
||||
publicKey: &pubKey,
|
||||
aclRules: tailcfg.FilterAllowAll, // default allowall
|
||||
requestedExpiryCache: requestedExpiryCache,
|
||||
}
|
||||
|
||||
err = app.initDB()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue