only show warning on Update Node (during recieving respondd data)

fixes #178
This commit is contained in:
genofire 2020-03-21 10:21:47 +01:00
parent 9d836f87c2
commit d4c898d1c9
No known key found for this signature in database
GPG Key ID: 9D7D3C6BFF600C6A
1 changed files with 5 additions and 5 deletions

View File

@ -48,7 +48,7 @@ func (nodes *Nodes) AddNode(node *Node) {
nodes.Lock()
defer nodes.Unlock()
nodes.List[nodeinfo.NodeID] = node
nodes.readIfaces(nodeinfo)
nodes.readIfaces(nodeinfo, false)
}
// Update a Node
@ -65,7 +65,7 @@ func (nodes *Nodes) Update(nodeID string, res *data.ResponseData) *Node {
nodes.List[nodeID] = node
}
if res.Nodeinfo != nil {
nodes.readIfaces(res.Nodeinfo)
nodes.readIfaces(res.Nodeinfo, true)
}
nodes.Unlock()
@ -183,7 +183,7 @@ func (nodes *Nodes) expire() {
}
// adds the nodes interface addresses to the internal map
func (nodes *Nodes) readIfaces(nodeinfo *data.Nodeinfo) {
func (nodes *Nodes) readIfaces(nodeinfo *data.Nodeinfo, warning bool) {
nodeID := nodeinfo.NodeID
network := nodeinfo.Network
@ -203,7 +203,7 @@ func (nodes *Nodes) readIfaces(nodeinfo *data.Nodeinfo) {
continue
}
if oldNodeID, _ := nodes.ifaceToNodeID[addr]; oldNodeID != nodeID {
if oldNodeID != "" {
if oldNodeID != "" && warning {
log.Warnf("override nodeID from %s to %s on MAC address %s", oldNodeID, nodeID, addr)
}
nodes.ifaceToNodeID[addr] = nodeID
@ -221,7 +221,7 @@ func (nodes *Nodes) load() {
nodes.Lock()
for _, node := range nodes.List {
if node.Nodeinfo != nil {
nodes.readIfaces(node.Nodeinfo)
nodes.readIfaces(node.Nodeinfo, false)
}
}
nodes.Unlock()