5
0
mirror of https://github.com/cwinfo/yggdrasil-go.git synced 2024-11-22 15:20:30 +00:00

Remove isAutoconf option to GenerateConfig

This commit is contained in:
Neil Alexander 2019-03-12 19:18:43 +00:00
parent 4062c93e18
commit 41872820c3
No known key found for this signature in database
GPG Key ID: A02A2019A2BB0944
3 changed files with 7 additions and 7 deletions

View File

@ -62,7 +62,7 @@ func readConfig(useconf *bool, useconffile *string, normaliseconf *bool) *nodeCo
// then parse the configuration we loaded above on top of it. The effect // then parse the configuration we loaded above on top of it. The effect
// of this is that any configuration item that is missing from the provided // of this is that any configuration item that is missing from the provided
// configuration will use a sane default. // configuration will use a sane default.
cfg := config.GenerateConfig(false) cfg := config.GenerateConfig()
var dat map[string]interface{} var dat map[string]interface{}
if err := hjson.Unmarshal(conf, &dat); err != nil { if err := hjson.Unmarshal(conf, &dat); err != nil {
panic(err) panic(err)
@ -154,7 +154,7 @@ func readConfig(useconf *bool, useconffile *string, normaliseconf *bool) *nodeCo
// Generates a new configuration and returns it in HJSON format. This is used // Generates a new configuration and returns it in HJSON format. This is used
// with -genconf. // with -genconf.
func doGenconf(isjson bool) string { func doGenconf(isjson bool) string {
cfg := config.GenerateConfig(false) cfg := config.GenerateConfig()
var bs []byte var bs []byte
var err error var err error
if isjson { if isjson {
@ -191,7 +191,7 @@ func main() {
case *autoconf: case *autoconf:
// Use an autoconf-generated config, this will give us random keys and // Use an autoconf-generated config, this will give us random keys and
// port numbers, and will use an automatically selected TUN/TAP interface. // port numbers, and will use an automatically selected TUN/TAP interface.
cfg = config.GenerateConfig(true) cfg = config.GenerateConfig()
case *useconffile != "" || *useconf: case *useconffile != "" || *useconf:
// Read the configuration from either stdin or from the filesystem // Read the configuration from either stdin or from the filesystem
cfg = readConfig(useconf, useconffile, normaliseconf) cfg = readConfig(useconf, useconffile, normaliseconf)

View File

@ -61,7 +61,7 @@ type SwitchOptions struct {
// or whether to generate a random port number. The only side effect of setting // or whether to generate a random port number. The only side effect of setting
// isAutoconf is that the TCP and UDP ports will likely end up with different // isAutoconf is that the TCP and UDP ports will likely end up with different
// port numbers. // port numbers.
func GenerateConfig(isAutoconf bool) *NodeConfig { func GenerateConfig() *NodeConfig {
// Generate encryption keys. // Generate encryption keys.
bpub, bpriv := crypto.NewBoxKeys() bpub, bpriv := crypto.NewBoxKeys()
spub, spriv := crypto.NewSigKeys() spub, spriv := crypto.NewSigKeys()

View File

@ -45,7 +45,7 @@ func (c *Core) addStaticPeers(cfg *config.NodeConfig) {
func (c *Core) StartAutoconfigure() error { func (c *Core) StartAutoconfigure() error {
mobilelog := MobileLogger{} mobilelog := MobileLogger{}
logger := log.New(mobilelog, "", 0) logger := log.New(mobilelog, "", 0)
nc := config.GenerateConfig(true) nc := config.GenerateConfig()
nc.IfName = "dummy" nc.IfName = "dummy"
nc.AdminListen = "tcp://localhost:9001" nc.AdminListen = "tcp://localhost:9001"
nc.Peers = []string{} nc.Peers = []string{}
@ -64,7 +64,7 @@ func (c *Core) StartAutoconfigure() error {
func (c *Core) StartJSON(configjson []byte) error { func (c *Core) StartJSON(configjson []byte) error {
mobilelog := MobileLogger{} mobilelog := MobileLogger{}
logger := log.New(mobilelog, "", 0) logger := log.New(mobilelog, "", 0)
nc := config.GenerateConfig(false) nc := config.GenerateConfig()
var dat map[string]interface{} var dat map[string]interface{}
if err := hjson.Unmarshal(configjson, &dat); err != nil { if err := hjson.Unmarshal(configjson, &dat); err != nil {
return err return err
@ -82,7 +82,7 @@ func (c *Core) StartJSON(configjson []byte) error {
// Generates mobile-friendly configuration in JSON format. // Generates mobile-friendly configuration in JSON format.
func GenerateConfigJSON() []byte { func GenerateConfigJSON() []byte {
nc := config.GenerateConfig(false) nc := config.GenerateConfig()
nc.IfName = "dummy" nc.IfName = "dummy"
if json, err := json.Marshal(nc); err == nil { if json, err := json.Marshal(nc); err == nil {
return json return json