From 88fdc227a3737e95e1d868c4e77df3717399be5f Mon Sep 17 00:00:00 2001 From: Stefan Hoffmann Date: Tue, 18 May 2021 20:49:06 +0200 Subject: [PATCH] Bugfixing Meshviewer error --- main.go | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index 9045f8c..6425355 100644 --- a/main.go +++ b/main.go @@ -88,6 +88,7 @@ func processUcAPIs() ([]node, []link) { } //build nodes struct + //mvJson, err := getMeshviewerJSON() for _, jsonDevice := range d.Devices { var currentDevice ucDevice var currentJSONDevice device @@ -98,7 +99,10 @@ func processUcAPIs() ([]node, []link) { } } 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) if err != nil { @@ -507,6 +511,17 @@ func getMeshviewerJSON(url string) (mvDevices, error) { } 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 { for i := range ucDev.Devices { if ucDev.Devices[i].GatewayNexthop == NodeID { @@ -521,7 +536,7 @@ func addmvDevices(d mvDevices) ([]node, []link) { for i := range d.Nodes { mvNode := d.Nodes[i] - if findNodeID(mvNode.NodeID) == true { + if findNodeID(mvNode.NodeID) { mvNode.Clients = 0 mvNode.ClientsWifi24 = 0 mvNode.ClientsWifi5 = 0