mirror of
https://github.com/cwinfo/yggdrasil-go.git
synced 2024-11-22 22:20:27 +00:00
Fix panic if Peers or InterfacePeers is commented out
This commit is contained in:
parent
fe30ec9a92
commit
a50964b334
@ -191,7 +191,8 @@ func main() {
|
|||||||
}
|
}
|
||||||
// Check to see if the peers are in a parsable format, if not then default
|
// Check to see if the peers are in a parsable format, if not then default
|
||||||
// them to the TCP scheme
|
// them to the TCP scheme
|
||||||
for index, peer := range dat["Peers"].([]interface{}) {
|
if peers, ok := dat["Peers"].([]interface{}); ok {
|
||||||
|
for index, peer := range peers {
|
||||||
uri := peer.(string)
|
uri := peer.(string)
|
||||||
if strings.HasPrefix(uri, "tcp://") || strings.HasPrefix(uri, "socks://") {
|
if strings.HasPrefix(uri, "tcp://") || strings.HasPrefix(uri, "socks://") {
|
||||||
continue
|
continue
|
||||||
@ -201,8 +202,10 @@ func main() {
|
|||||||
}
|
}
|
||||||
(dat["Peers"].([]interface{}))[index] = "tcp://" + uri
|
(dat["Peers"].([]interface{}))[index] = "tcp://" + uri
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// Now do the same with the interface peers
|
// Now do the same with the interface peers
|
||||||
for intf, peers := range dat["InterfacePeers"].(map[string]interface{}) {
|
if interfacepeers, ok := dat["InterfacePeers"].(map[string]interface{}); ok {
|
||||||
|
for intf, peers := range interfacepeers {
|
||||||
for index, peer := range peers.([]interface{}) {
|
for index, peer := range peers.([]interface{}) {
|
||||||
uri := peer.(string)
|
uri := peer.(string)
|
||||||
if strings.HasPrefix(uri, "tcp://") || strings.HasPrefix(uri, "socks://") {
|
if strings.HasPrefix(uri, "tcp://") || strings.HasPrefix(uri, "socks://") {
|
||||||
@ -214,6 +217,7 @@ func main() {
|
|||||||
((dat["InterfacePeers"].(map[string]interface{}))[intf]).([]interface{})[index] = "tcp://" + uri
|
((dat["InterfacePeers"].(map[string]interface{}))[intf]).([]interface{})[index] = "tcp://" + uri
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// Overlay our newly mapped configuration onto the autoconf node config that
|
// Overlay our newly mapped configuration onto the autoconf node config that
|
||||||
// we generated above.
|
// we generated above.
|
||||||
if err = mapstructure.Decode(dat, &cfg); err != nil {
|
if err = mapstructure.Decode(dat, &cfg); err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user