diff --git a/runtime/node.go b/runtime/node.go index fd7ad7e..34d1b2d 100644 --- a/runtime/node.go +++ b/runtime/node.go @@ -1,6 +1,7 @@ package runtime import ( + "fmt" "net" "strings" @@ -80,9 +81,11 @@ func (n *Node) IsEqual(node *Node) bool { if n.NodeID != node.NodeID { return false } - if n.Address != node.Address { - return false - } + /* + if n.Address != node.Address { + return false + } + */ if n.Hostname != node.Hostname { return false } @@ -98,16 +101,20 @@ func (n *Node) IsEqual(node *Node) bool { return true } +const LOCATION_EQUAL_FORMAT_STRING = "%.6f" + func locationEqual(a, b yanicData.Location) bool { - if a.Latitude != b.Latitude { + if fmt.Sprintf(LOCATION_EQUAL_FORMAT_STRING, a.Latitude) != fmt.Sprintf(LOCATION_EQUAL_FORMAT_STRING, b.Latitude) { return false } - if a.Longitude != b.Longitude { + if fmt.Sprintf(LOCATION_EQUAL_FORMAT_STRING, a.Longitude) != fmt.Sprintf(LOCATION_EQUAL_FORMAT_STRING, b.Longitude) { return false } + if a.Altitude != b.Altitude { return false } + return true } diff --git a/runtime/yanic.go b/runtime/yanic.go index d3aa57f..b4cbe6f 100644 --- a/runtime/yanic.go +++ b/runtime/yanic.go @@ -49,16 +49,17 @@ func (conn *YanicDB) InsertNode(n *runtimeYanic.Node) { //"StatsClients": node.StatsClients, "Address": node.Address, }) - conn.sendNode(node, false) if lNode.Blacklist { logger.Debug("on blacklist") return } + conn.sendNode(node, false) if !node.IsEqual(&lNode) { lNode.SSHUpdate(conn.ssh, node) - logger.Debug("run sshupdate again") + logger.Debug("yanic trigger sshupdate again") + } else { + logger.Debug("yanic update") } - logger.Debug("yanic update") return } @@ -71,10 +72,6 @@ func (conn *YanicDB) InsertNode(n *runtimeYanic.Node) { } conn.db.Create(&node) conn.sendNode(node, true) - if err == nil { - lNode.SSHUpdate(conn.ssh, node) - logger.Debug("run sshupdate") - } } func (conn *YanicDB) InsertLink(link *runtimeYanic.Link, time time.Time) {