mirror of
https://github.com/juanfont/headscale.git
synced 2025-01-11 12:23:18 -05:00
feat: allow setting node registration expiration via config
This commit is contained in:
parent
757defa2f2
commit
7518eba82e
@ -95,6 +95,7 @@ This will also affect the way you [reference users in policies](https://github.c
|
||||
- Fixed missing `stable-debug` container tag [#2232](https://github.com/juanfont/headscale/pr/2232)
|
||||
- Loosened up `server_url` and `base_domain` check. It was overly strict in some cases. [#2248](https://github.com/juanfont/headscale/pull/2248)
|
||||
- CLI for managing users now accepts `--identifier` in addition to `--name`, usage of `--identifier` is recommended [#2261](https://github.com/juanfont/headscale/pull/2261)
|
||||
- Added option to set Node registration expiration/cleanup options via config [#2280](https://github.com/juanfont/headscale/pull/2280)
|
||||
|
||||
## 0.23.0 (2024-09-18)
|
||||
|
||||
|
@ -72,9 +72,6 @@ const (
|
||||
updateInterval = 5 * time.Second
|
||||
privateKeyFileMode = 0o600
|
||||
headscaleDirPerm = 0o700
|
||||
|
||||
registerCacheExpiration = time.Minute * 15
|
||||
registerCacheCleanup = time.Minute * 20
|
||||
)
|
||||
|
||||
// Headscale represents the base app of the service.
|
||||
@ -122,8 +119,8 @@ func NewHeadscale(cfg *types.Config) (*Headscale, error) {
|
||||
}
|
||||
|
||||
registrationCache := zcache.New[string, types.Node](
|
||||
registerCacheExpiration,
|
||||
registerCacheCleanup,
|
||||
cfg.Tuning.NodeRegistrationCacheExpiration,
|
||||
cfg.Tuning.NodeRegistrationCacheCleanup,
|
||||
)
|
||||
|
||||
app := Headscale{
|
||||
@ -171,6 +168,7 @@ func NewHeadscale(cfg *types.Config) (*Headscale, error) {
|
||||
app.nodeNotifier,
|
||||
app.ipAlloc,
|
||||
app.polMan,
|
||||
&cfg.Tuning,
|
||||
)
|
||||
if err != nil {
|
||||
if cfg.OIDC.OnlyStartIfOIDCIsAvailable {
|
||||
|
@ -68,6 +68,7 @@ func NewAuthProviderOIDC(
|
||||
notif *notifier.Notifier,
|
||||
ipAlloc *db.IPAllocator,
|
||||
polMan policy.PolicyManager,
|
||||
tuningCfg *types.Tuning,
|
||||
) (*AuthProviderOIDC, error) {
|
||||
var err error
|
||||
// grab oidc config if it hasn't been already
|
||||
@ -88,8 +89,8 @@ func NewAuthProviderOIDC(
|
||||
}
|
||||
|
||||
registrationCache := zcache.New[string, key.MachinePublic](
|
||||
registerCacheExpiration,
|
||||
registerCacheCleanup,
|
||||
tuningCfg.NodeRegistrationCacheExpiration,
|
||||
tuningCfg.NodeRegistrationCacheCleanup,
|
||||
)
|
||||
|
||||
return &AuthProviderOIDC{
|
||||
|
@ -212,6 +212,10 @@ type Tuning struct {
|
||||
NotifierSendTimeout time.Duration
|
||||
BatchChangeDelay time.Duration
|
||||
NodeMapSessionBufferedChanSize int
|
||||
|
||||
// Node registration cache expiration
|
||||
NodeRegistrationCacheExpiration time.Duration
|
||||
NodeRegistrationCacheCleanup time.Duration
|
||||
}
|
||||
|
||||
// LoadConfig prepares and loads the Headscale configuration into Viper.
|
||||
@ -291,6 +295,8 @@ func LoadConfig(path string, isFile bool) error {
|
||||
viper.SetDefault("tuning.notifier_send_timeout", "800ms")
|
||||
viper.SetDefault("tuning.batch_change_delay", "800ms")
|
||||
viper.SetDefault("tuning.node_mapsession_buffered_chan_size", 30)
|
||||
viper.SetDefault("tuning.node_registration_cache_expiration", "15m")
|
||||
viper.SetDefault("tuning.node_registration_cache_cleanup", "20m")
|
||||
|
||||
viper.SetDefault("prefixes.allocation", string(IPAllocationStrategySequential))
|
||||
|
||||
@ -935,6 +941,8 @@ func LoadServerConfig() (*Config, error) {
|
||||
NodeMapSessionBufferedChanSize: viper.GetInt(
|
||||
"tuning.node_mapsession_buffered_chan_size",
|
||||
),
|
||||
NodeRegistrationCacheExpiration: viper.GetDuration("tuning.node_registration_cache_expiration"),
|
||||
NodeRegistrationCacheCleanup: viper.GetDuration("tuning.node_registration_cache_cleanup"),
|
||||
},
|
||||
}, nil
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user