Register new machines needing callback in memory
This commit stores temporary registration data in cache, instead of memory allowing us to only have actually registered machines in the database.
This commit is contained in:
parent
1caa6f5d69
commit
469551bc5d
7 changed files with 136 additions and 95 deletions
9
app.go
9
app.go
|
|
@ -154,6 +154,8 @@ type Headscale struct {
|
|||
|
||||
requestedExpiryCache *cache.Cache
|
||||
|
||||
registrationCache *cache.Cache
|
||||
|
||||
ipAllocationMutex sync.Mutex
|
||||
}
|
||||
|
||||
|
|
@ -207,6 +209,12 @@ func NewHeadscale(cfg Config) (*Headscale, error) {
|
|||
requestedExpiryCacheCleanupInterval,
|
||||
)
|
||||
|
||||
registrationCache := cache.New(
|
||||
// TODO(kradalby): Add unified cache expiry config options
|
||||
requestedExpiryCacheExpiration,
|
||||
requestedExpiryCacheCleanupInterval,
|
||||
)
|
||||
|
||||
app := Headscale{
|
||||
cfg: cfg,
|
||||
dbType: cfg.DBtype,
|
||||
|
|
@ -214,6 +222,7 @@ func NewHeadscale(cfg Config) (*Headscale, error) {
|
|||
privateKey: privKey,
|
||||
aclRules: tailcfg.FilterAllowAll, // default allowall
|
||||
requestedExpiryCache: requestedExpiryCache,
|
||||
registrationCache: registrationCache,
|
||||
}
|
||||
|
||||
err = app.initDB()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue