mirror of
https://github.com/juanfont/headscale.git
synced 2024-12-25 01:07:52 +00:00
MOve ephemeral inactivity config check to all the other config check
This commit is contained in:
parent
e0ef601123
commit
95824ac2ec
@ -7,12 +7,10 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"reflect"
|
"reflect"
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/juanfont/headscale"
|
"github.com/juanfont/headscale"
|
||||||
v1 "github.com/juanfont/headscale/gen/go/headscale/v1"
|
v1 "github.com/juanfont/headscale/gen/go/headscale/v1"
|
||||||
"github.com/rs/zerolog/log"
|
"github.com/rs/zerolog/log"
|
||||||
"github.com/spf13/viper"
|
|
||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
"google.golang.org/grpc/credentials"
|
"google.golang.org/grpc/credentials"
|
||||||
"google.golang.org/grpc/credentials/insecure"
|
"google.golang.org/grpc/credentials/insecure"
|
||||||
@ -29,21 +27,6 @@ func getHeadscaleApp() (*headscale.Headscale, error) {
|
|||||||
return nil, fmt.Errorf("failed to load configuration while creating headscale instance: %w", err)
|
return nil, fmt.Errorf("failed to load configuration while creating headscale instance: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Minimum inactivity time out is keepalive timeout (60s) plus a few seconds
|
|
||||||
// to avoid races
|
|
||||||
minInactivityTimeout, _ := time.ParseDuration("65s")
|
|
||||||
if viper.GetDuration("ephemeral_node_inactivity_timeout") <= minInactivityTimeout {
|
|
||||||
// TODO: Find a better way to return this text
|
|
||||||
//nolint
|
|
||||||
err := fmt.Errorf(
|
|
||||||
"ephemeral_node_inactivity_timeout (%s) is set too low, must be more than %s",
|
|
||||||
viper.GetString("ephemeral_node_inactivity_timeout"),
|
|
||||||
minInactivityTimeout,
|
|
||||||
)
|
|
||||||
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
app, err := headscale.NewHeadscale(cfg)
|
app, err := headscale.NewHeadscale(cfg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
11
config.go
11
config.go
@ -202,6 +202,17 @@ func LoadConfig(path string, isFile bool) error {
|
|||||||
EnforcedClientAuth)
|
EnforcedClientAuth)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Minimum inactivity time out is keepalive timeout (60s) plus a few seconds
|
||||||
|
// to avoid races
|
||||||
|
minInactivityTimeout, _ := time.ParseDuration("65s")
|
||||||
|
if viper.GetDuration("ephemeral_node_inactivity_timeout") <= minInactivityTimeout {
|
||||||
|
errorText += fmt.Sprintf(
|
||||||
|
"Fatal config error: ephemeral_node_inactivity_timeout (%s) is set too low, must be more than %s",
|
||||||
|
viper.GetString("ephemeral_node_inactivity_timeout"),
|
||||||
|
minInactivityTimeout,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
if errorText != "" {
|
if errorText != "" {
|
||||||
//nolint
|
//nolint
|
||||||
return errors.New(strings.TrimSuffix(errorText, "\n"))
|
return errors.New(strings.TrimSuffix(errorText, "\n"))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user