From a3ecb2d8ae0ded4b4926e43d48c88fe067bb7996 Mon Sep 17 00:00:00 2001 From: Stefan Date: Mon, 20 Mar 2023 16:00:11 +0100 Subject: [PATCH] Bugfix, missing Links --- unms.go | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/unms.go b/unms.go index 0c479eb..1067de1 100644 --- a/unms.go +++ b/unms.go @@ -62,7 +62,7 @@ func processUNMSAPI() ([]node, []link) { // check if remote mac address is part of our published network for i := range airmaxes { if isRemoteMACpublished(airmaxes[i].DeviceIdentification.MAC, d.Devices) { - //links = UnmsAddLink(dev, airmaxes[i], links) + links = UnmsAddLink(dev, airmaxes[i], links) } } // END OF API CALL 3 @@ -321,3 +321,22 @@ func UnmsGetAddresses(ip string) []string { adresses = append(adresses, strings.Split(ip, "/")[0]) return adresses } + +func UnmsAddLink(dev unifiAPIResponse, airmaxes unifiAPIAirmax, links []link) []link { + for i := range links { + if links[i].SourceAddr == airmaxes.DeviceIdentification.MAC { + // link already exists + return links + } + } + links = append(links, link{ + Type: "wifi", + Source: strings.ReplaceAll(dev.Identification.MAC, ":", ""), + Target: strings.ReplaceAll(airmaxes.DeviceIdentification.MAC, ":", ""), + SourceTQ: airmaxes.Statistics.LinkScore, + TargetTQ: airmaxes.Statistics.LinkScore, + SourceAddr: dev.Identification.MAC, + TargetAddr: airmaxes.DeviceIdentification.MAC, + }) + return links +}