[BUG] fix target.hostname of links

Before this commit, the value of target.hostname was incorrect.
It was accidentially pointing to the hostname of the source of
the link. This means target.hostname was equal to source.hostname.

Fixes: #197
Fixes: 0325aad24e
PR: #200
This commit is contained in:
lemoer 2021-04-03 05:11:33 +02:00 committed by GitHub
parent a76df9b9ac
commit 3aac902632
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 3 deletions

View File

@ -117,7 +117,7 @@ func (nodes *Nodes) NodeLinks(node *Node) (result []Link) {
for sourceMAC, batadv := range neighbours.Batadv {
for neighbourMAC, link := range batadv.Neighbours {
if neighbourID := nodes.ifaceToNodeID[neighbourMAC]; neighbourID != "" {
neighbour := nodes.List[neighbours.NodeID]
neighbour := nodes.List[neighbourID]
link := Link{
SourceID: neighbours.NodeID,
@ -128,10 +128,10 @@ func (nodes *Nodes) NodeLinks(node *Node) (result []Link) {
}
if neighbour.Nodeinfo != nil {
link.SourceHostname = neighbour.Nodeinfo.Hostname
link.TargetHostname = neighbour.Nodeinfo.Hostname
}
if node.Nodeinfo != nil {
link.TargetHostname = node.Nodeinfo.Hostname
link.SourceHostname = node.Nodeinfo.Hostname
}
result = append(result, link)