mirror of
https://github.com/juanfont/headscale.git
synced 2025-11-29 13:28:03 -05:00
Make tailnet updates check configurable
This commit is contained in:
16
config.go
16
config.go
@@ -26,6 +26,7 @@ type Config struct {
|
||||
GRPCAddr string
|
||||
GRPCAllowInsecure bool
|
||||
EphemeralNodeInactivityTimeout time.Duration
|
||||
ChangesCheckInterval time.Duration
|
||||
IPPrefixes []netaddr.IPPrefix
|
||||
PrivateKeyPath string
|
||||
BaseDomain string
|
||||
@@ -162,6 +163,8 @@ func LoadConfig(path string, isFile bool) error {
|
||||
|
||||
viper.SetDefault("ephemeral_node_inactivity_timeout", "120s")
|
||||
|
||||
viper.SetDefault("changes_check_interval", "10s")
|
||||
|
||||
if err := viper.ReadInConfig(); err != nil {
|
||||
log.Warn().Err(err).Msg("Failed to read configuration from disk")
|
||||
|
||||
@@ -217,6 +220,15 @@ func LoadConfig(path string, isFile bool) error {
|
||||
)
|
||||
}
|
||||
|
||||
maxChangesCheckInterval, _ := time.ParseDuration("60s")
|
||||
if viper.GetDuration("changes_check_interval") > maxChangesCheckInterval {
|
||||
errorText += fmt.Sprintf(
|
||||
"Fatal config error: changes_check_interval (%s) is set too high, must be less than %s",
|
||||
viper.GetString("changes_check_interval"),
|
||||
maxChangesCheckInterval,
|
||||
)
|
||||
}
|
||||
|
||||
if errorText != "" {
|
||||
//nolint
|
||||
return errors.New(strings.TrimSuffix(errorText, "\n"))
|
||||
@@ -478,6 +490,10 @@ func GetHeadscaleConfig() (*Config, error) {
|
||||
"ephemeral_node_inactivity_timeout",
|
||||
),
|
||||
|
||||
ChangesCheckInterval: viper.GetDuration(
|
||||
"changes_check_interval",
|
||||
),
|
||||
|
||||
DBtype: viper.GetString("db_type"),
|
||||
DBpath: AbsolutePathFromConfigPath(viper.GetString("db_path")),
|
||||
DBhost: viper.GetString("db_host"),
|
||||
|
||||
Reference in New Issue
Block a user