mirror of
https://github.com/yggdrasil-network/yggdrasil-go
synced 2024-11-09 23:20:26 +03:00
Add -normaliseconf option and temporarily correct old config item names in running config
This commit is contained in:
parent
9d9083e373
commit
ce854a76bd
@ -391,7 +391,7 @@ func (c *Core) DEBUG_setupAndStartMulticastInterface() {
|
||||
m := multicast{}
|
||||
m.init(c)
|
||||
c.multicast = m
|
||||
m.Start()
|
||||
m.start()
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -44,7 +44,7 @@ func (m *multicast) init(core *Core) {
|
||||
m.core.log.Println("Found", len(m.interfaces), "multicast interface(s)")
|
||||
}
|
||||
|
||||
func (m *multicast) Start() {
|
||||
func (m *multicast) start() {
|
||||
if len(m.core.ifceExpr) == 0 {
|
||||
m.core.log.Println("Multicast discovery is disabled")
|
||||
} else {
|
||||
|
35
yggdrasil.go
35
yggdrasil.go
@ -123,6 +123,7 @@ var pprof = flag.Bool("pprof", false, "Run pprof, see http://localhost:6060/debu
|
||||
var genconf = flag.Bool("genconf", false, "print a new config to stdout")
|
||||
var useconf = flag.Bool("useconf", false, "read config from stdin")
|
||||
var useconffile = flag.String("useconffile", "", "read config from specified file path")
|
||||
var normaliseconf = flag.Bool("normaliseconf", false, "use in combination with either -useconf or -useconffile, outputs your configuration normalised")
|
||||
var autoconf = flag.Bool("autoconf", false, "automatic mode (dynamic IP, peer with IPv6 neighbors)")
|
||||
|
||||
func main() {
|
||||
@ -147,9 +148,43 @@ func main() {
|
||||
if err := hjson.Unmarshal(config, &dat); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
// For now we will do a little bit to help the user adjust their
|
||||
// configuration to match the new configuration format
|
||||
changes := map[string]string{
|
||||
"Multicast": "",
|
||||
"LinkLocal": "MulticastInterfaces",
|
||||
"BoxPub": "EncryptionPublicKey",
|
||||
"BoxPriv": "EncryptionPrivateKey",
|
||||
"SigPub": "SigningPublicKey",
|
||||
"SigPriv": "SigningPrivateKey",
|
||||
}
|
||||
for from, to := range changes {
|
||||
if val, ok := dat[from]; ok {
|
||||
if val == "" {
|
||||
if !*normaliseconf {
|
||||
log.Println("Warning: Deprecated config option", from, " - please remove")
|
||||
}
|
||||
} else {
|
||||
if !*normaliseconf {
|
||||
log.Println("Warning: Deprecated config option", from, " - please rename to", to)
|
||||
}
|
||||
if _, ok := dat[to]; !ok {
|
||||
dat[to] = dat[from]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if err = mapstructure.Decode(dat, &cfg); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if *normaliseconf {
|
||||
bs, err := hjson.Marshal(cfg)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
fmt.Println(string(bs))
|
||||
return
|
||||
}
|
||||
case *genconf:
|
||||
fmt.Println(doGenconf())
|
||||
default:
|
||||
|
Loading…
Reference in New Issue
Block a user