Bugfix, missing Links
All checks were successful
continuous-integration/drone/tag Build is passing

This commit is contained in:
Stefan Hoffmann 2023-03-20 16:00:11 +01:00
parent 7fdaac3240
commit a3ecb2d8ae

21
unms.go
View File

@ -62,7 +62,7 @@ func processUNMSAPI() ([]node, []link) {
// check if remote mac address is part of our published network // check if remote mac address is part of our published network
for i := range airmaxes { for i := range airmaxes {
if isRemoteMACpublished(airmaxes[i].DeviceIdentification.MAC, d.Devices) { 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 // END OF API CALL 3
@ -321,3 +321,22 @@ func UnmsGetAddresses(ip string) []string {
adresses = append(adresses, strings.Split(ip, "/")[0]) adresses = append(adresses, strings.Split(ip, "/")[0])
return adresses 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
}