mirror of
				https://github.com/yggdrasil-network/yggdrasil-go.git
				synced 2025-11-04 03:05:07 +03:00 
			
		
		
		
	Add StartJSON
This commit is contained in:
		
							parent
							
								
									4ff3db2309
								
							
						
					
					
						commit
						f7b0a85b5e
					
				
					 1 changed files with 19 additions and 0 deletions
				
			
		| 
						 | 
				
			
			@ -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()
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue