From 58439fcd569433cd7b11d4cf1da8ffd86bddb863 Mon Sep 17 00:00:00 2001 From: Tim Beatham Date: Thu, 28 Dec 2023 17:32:54 +0000 Subject: [PATCH] main - Bugfix when keepalivewg is not set causes segmentation fault - give keepalive a default value of 0 if not set --- pkg/conf/conf.go | 25 +++++-------------------- 1 file changed, 5 insertions(+), 20 deletions(-) diff --git a/pkg/conf/conf.go b/pkg/conf/conf.go index 800cc92..86ca077 100644 --- a/pkg/conf/conf.go +++ b/pkg/conf/conf.go @@ -126,26 +126,6 @@ func ValidateDaemonConfiguration(c *DaemonConfiguration) error { return err } -// ParseMeshConfiguration: parses the mesh network configuration. Parses parameters such as -// keepalive time, role and so forth. -func ParseMeshConfiguration(filePath string) (*WgConfiguration, error) { - var conf WgConfiguration - - yamlBytes, err := os.ReadFile(filePath) - - if err != nil { - return nil, err - } - - err = yaml.Unmarshal(yamlBytes, &conf) - - if err != nil { - return nil, err - } - - return &conf, ValidateMeshConfiguration(&conf) -} - // ParseDaemonConfiguration parses the mesh configuration and validates the configuration func ParseDaemonConfiguration(filePath string) (*DaemonConfiguration, error) { var conf DaemonConfiguration @@ -162,6 +142,11 @@ func ParseDaemonConfiguration(filePath string) (*DaemonConfiguration, error) { return nil, err } + if conf.BaseConfiguration.KeepAliveWg == nil { + var keepAlive int = 0 + conf.BaseConfiguration.KeepAliveWg = &keepAlive + } + return &conf, ValidateDaemonConfiguration(&conf) }