only show warning on Update Node (during recieving respondd data)
fixes #178
This commit is contained in:
parent
9d836f87c2
commit
d4c898d1c9
|
@ -48,7 +48,7 @@ func (nodes *Nodes) AddNode(node *Node) {
|
||||||
nodes.Lock()
|
nodes.Lock()
|
||||||
defer nodes.Unlock()
|
defer nodes.Unlock()
|
||||||
nodes.List[nodeinfo.NodeID] = node
|
nodes.List[nodeinfo.NodeID] = node
|
||||||
nodes.readIfaces(nodeinfo)
|
nodes.readIfaces(nodeinfo, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update a Node
|
// Update a Node
|
||||||
|
@ -65,7 +65,7 @@ func (nodes *Nodes) Update(nodeID string, res *data.ResponseData) *Node {
|
||||||
nodes.List[nodeID] = node
|
nodes.List[nodeID] = node
|
||||||
}
|
}
|
||||||
if res.Nodeinfo != nil {
|
if res.Nodeinfo != nil {
|
||||||
nodes.readIfaces(res.Nodeinfo)
|
nodes.readIfaces(res.Nodeinfo, true)
|
||||||
}
|
}
|
||||||
nodes.Unlock()
|
nodes.Unlock()
|
||||||
|
|
||||||
|
@ -183,7 +183,7 @@ func (nodes *Nodes) expire() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// adds the nodes interface addresses to the internal map
|
// 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
|
nodeID := nodeinfo.NodeID
|
||||||
network := nodeinfo.Network
|
network := nodeinfo.Network
|
||||||
|
|
||||||
|
@ -203,7 +203,7 @@ func (nodes *Nodes) readIfaces(nodeinfo *data.Nodeinfo) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if oldNodeID, _ := nodes.ifaceToNodeID[addr]; oldNodeID != nodeID {
|
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)
|
log.Warnf("override nodeID from %s to %s on MAC address %s", oldNodeID, nodeID, addr)
|
||||||
}
|
}
|
||||||
nodes.ifaceToNodeID[addr] = nodeID
|
nodes.ifaceToNodeID[addr] = nodeID
|
||||||
|
@ -221,7 +221,7 @@ func (nodes *Nodes) load() {
|
||||||
nodes.Lock()
|
nodes.Lock()
|
||||||
for _, node := range nodes.List {
|
for _, node := range nodes.List {
|
||||||
if node.Nodeinfo != nil {
|
if node.Nodeinfo != nil {
|
||||||
nodes.readIfaces(node.Nodeinfo)
|
nodes.readIfaces(node.Nodeinfo, false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
nodes.Unlock()
|
nodes.Unlock()
|
||||||
|
|
Loading…
Reference in New Issue