mirror of
https://github.com/juanfont/headscale.git
synced 2024-11-24 18:45:24 +00:00
error if no prefix is configured (#1918)
Signed-off-by: Kristoffer Dalby <kristoffer@tailscale.com>
This commit is contained in:
parent
87e2ae4d52
commit
d5ed8bc074
@ -51,7 +51,7 @@ func initConfig() {
|
|||||||
|
|
||||||
cfg, err := types.GetHeadscaleConfig()
|
cfg, err := types.GetHeadscaleConfig()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal().Caller().Err(err).Msg("Failed to get headscale configuration")
|
log.Fatal().Err(err).Msg("Failed to read headscale configuration")
|
||||||
}
|
}
|
||||||
|
|
||||||
machineOutput := HasMachineOutputFlag()
|
machineOutput := HasMachineOutputFlag()
|
||||||
|
@ -650,6 +650,10 @@ func GetHeadscaleConfig() (*Config, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if prefix4 == nil && prefix6 == nil {
|
||||||
|
return nil, fmt.Errorf("no IPv4 or IPv6 prefix configured, minimum one prefix is required")
|
||||||
|
}
|
||||||
|
|
||||||
allocStr := viper.GetString("prefixes.allocation")
|
allocStr := viper.GetString("prefixes.allocation")
|
||||||
var alloc IPAllocationStrategy
|
var alloc IPAllocationStrategy
|
||||||
switch allocStr {
|
switch allocStr {
|
||||||
@ -658,7 +662,7 @@ func GetHeadscaleConfig() (*Config, error) {
|
|||||||
case string(IPAllocationStrategyRandom):
|
case string(IPAllocationStrategyRandom):
|
||||||
alloc = IPAllocationStrategyRandom
|
alloc = IPAllocationStrategyRandom
|
||||||
default:
|
default:
|
||||||
log.Fatal().Msgf("config error, prefixes.allocation is set to %s, which is not a valid strategy, allowed options: %s, %s", allocStr, IPAllocationStrategySequential, IPAllocationStrategyRandom)
|
return nil, fmt.Errorf("config error, prefixes.allocation is set to %s, which is not a valid strategy, allowed options: %s, %s", allocStr, IPAllocationStrategySequential, IPAllocationStrategyRandom)
|
||||||
}
|
}
|
||||||
|
|
||||||
dnsConfig, baseDomain := GetDNSConfig()
|
dnsConfig, baseDomain := GetDNSConfig()
|
||||||
|
Loading…
Reference in New Issue
Block a user