move GenerateConfig to defaults, to adjust dependency ordering, needed for stuff later

This commit is contained in:
Arceliar 2021-06-27 02:18:51 -05:00
parent 2db46c1250
commit 2a7a53b6b6
3 changed files with 26 additions and 31 deletions

View file

@ -1,5 +1,7 @@
package defaults
import "github.com/yggdrasil-network/yggdrasil-go/src/config"
// Defines which parameters are expected by default for configuration on a
// specific platform. These values are populated in the relevant defaults_*.go
// for the platform being targeted. They must be set.
@ -18,3 +20,23 @@ type platformDefaultParameters struct {
DefaultIfMTU uint64
DefaultIfName string
}
// Generates default configuration and returns a pointer to the resulting
// NodeConfig. This is used when outputting the -genconf parameter and also when
// using -autoconf.
func GenerateConfig() *config.NodeConfig {
// Create a node configuration and populate it.
cfg := new(config.NodeConfig)
cfg.NewKeys()
cfg.Listen = []string{}
cfg.AdminListen = GetDefaults().DefaultAdminListen
cfg.Peers = []string{}
cfg.InterfacePeers = map[string][]string{}
cfg.AllowedPublicKeys = []string{}
cfg.MulticastInterfaces = GetDefaults().DefaultMulticastInterfaces
cfg.IfName = GetDefaults().DefaultIfName
cfg.IfMTU = GetDefaults().DefaultIfMTU
cfg.NodeInfoPrivacy = false
return cfg
}