5
0
mirror of https://github.com/cwinfo/yggdrasil-go.git synced 2024-11-10 02:50:27 +00:00

Add StartJSON

This commit is contained in:
Neil Alexander 2019-01-02 23:15:36 +00:00
parent 4ff3db2309
commit f7b0a85b5e
No known key found for this signature in database
GPG Key ID: A02A2019A2BB0944

View File

@ -7,6 +7,8 @@ import (
"os"
"regexp"
hjson "github.com/hjson/hjson-go"
"github.com/mitchellh/mapstructure"
"github.com/yggdrasil-network/yggdrasil-go/src/config"
"github.com/yggdrasil-network/yggdrasil-go/src/util"
)
@ -36,6 +38,23 @@ func (c *Core) StartAutoconfigure() error {
return nil
}
func (c *Core) StartJSON(configjson []byte) error {
logger := log.New(os.Stdout, "", 0)
nc := config.GenerateConfig(false)
var dat map[string]interface{}
if err := hjson.Unmarshal(configjson, &dat); err != nil {
return err
}
if err := mapstructure.Decode(dat, &nc); err != nil {
return err
}
nc.IfName = "dummy"
if err := c.Start(nc, logger); err != nil {
return err
}
return nil
}
func (c *Core) GetAddressString() string {
return c.GetAddress().String()
}