Bugfixing Meshviewer error
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is passing

This commit is contained in:
Stefan Hoffmann 2021-05-18 20:49:06 +02:00
parent 801ac20dfd
commit 88fdc227a3

19
main.go
View File

@ -88,6 +88,7 @@ func processUcAPIs() ([]node, []link) {
} }
//build nodes struct //build nodes struct
//mvJson, err := getMeshviewerJSON()
for _, jsonDevice := range d.Devices { for _, jsonDevice := range d.Devices {
var currentDevice ucDevice var currentDevice ucDevice
var currentJSONDevice device var currentJSONDevice device
@ -98,7 +99,10 @@ func processUcAPIs() ([]node, []link) {
} }
} }
if isRemoteMACpublished(jsonDevice.MAC, d.Devices) == true { if isRemoteMACpublished(jsonDevice.MAC, d.Devices) == true {
links = ucAddLink(jsonDevice, links) //hier muss gecheckt werden ob der link valide ist
if checkMeshviewerLink(jsonDevice.LinkedTo) {
links = ucAddLink(jsonDevice, links)
}
} }
load, err := strconv.ParseFloat(currentDevice.Sysstats.CPU, 64) load, err := strconv.ParseFloat(currentDevice.Sysstats.CPU, 64)
if err != nil { if err != nil {
@ -507,6 +511,17 @@ func getMeshviewerJSON(url string) (mvDevices, error) {
} }
return n, nil return n, nil
} }
func checkMeshviewerLink(s string) bool {
mvNodes, _ := getMeshviewer()
for i := range mvNodes {
if mvNodes[i].MAC == s {
return true
}
}
return false
}
func findNodeID(NodeID string) bool { func findNodeID(NodeID string) bool {
for i := range ucDev.Devices { for i := range ucDev.Devices {
if ucDev.Devices[i].GatewayNexthop == NodeID { if ucDev.Devices[i].GatewayNexthop == NodeID {
@ -521,7 +536,7 @@ func addmvDevices(d mvDevices) ([]node, []link) {
for i := range d.Nodes { for i := range d.Nodes {
mvNode := d.Nodes[i] mvNode := d.Nodes[i]
if findNodeID(mvNode.NodeID) == true { if findNodeID(mvNode.NodeID) {
mvNode.Clients = 0 mvNode.Clients = 0
mvNode.ClientsWifi24 = 0 mvNode.ClientsWifi24 = 0
mvNode.ClientsWifi5 = 0 mvNode.ClientsWifi5 = 0