mirror of
https://github.com/cwinfo/yggdrasil-go.git
synced 2024-11-23 00:51:35 +00:00
Add StartJSON
This commit is contained in:
parent
4ff3db2309
commit
f7b0a85b5e
@ -7,6 +7,8 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"regexp"
|
"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/config"
|
||||||
"github.com/yggdrasil-network/yggdrasil-go/src/util"
|
"github.com/yggdrasil-network/yggdrasil-go/src/util"
|
||||||
)
|
)
|
||||||
@ -36,6 +38,23 @@ func (c *Core) StartAutoconfigure() error {
|
|||||||
return nil
|
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 {
|
func (c *Core) GetAddressString() string {
|
||||||
return c.GetAddress().String()
|
return c.GetAddress().String()
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user