From 7dfd6728480b5562a6e26c7c63a94134482e688a Mon Sep 17 00:00:00 2001 From: capossele <angelocapossele@gmail.com> Date: Thu, 18 Jun 2020 18:29:36 +0100 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20improve=20analysis=20plugi?= =?UTF-8?q?n?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/analysis/dashboard/recorded_events.go | 9 +++++---- plugins/analysis/server/plugin.go | 4 ++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/plugins/analysis/dashboard/recorded_events.go b/plugins/analysis/dashboard/recorded_events.go index 2d175067..89a97d5c 100644 --- a/plugins/analysis/dashboard/recorded_events.go +++ b/plugins/analysis/dashboard/recorded_events.go @@ -25,6 +25,7 @@ var ( lock sync.RWMutex ) +// NeighborMetric contains the number of inbound/outbound neighbors. type NeighborMetric struct { Inbound uint Outbound uint @@ -35,7 +36,7 @@ func NumOfNeighbors() map[string]*NeighborMetric { lock.RLock() defer lock.RUnlock() result := make(map[string]*NeighborMetric) - for nodeID, _ := range nodes { + for nodeID := range nodes { // number of outgoing neighbors if _, exist := result[nodeID]; !exist { result[nodeID] = &NeighborMetric{Outbound: uint(len(links[nodeID]))} @@ -44,7 +45,7 @@ func NumOfNeighbors() map[string]*NeighborMetric { } // fill in incoming neighbors - for outNeighborID, _ := range links[nodeID] { + for outNeighborID := range links[nodeID] { if _, exist := result[outNeighborID]; !exist { result[outNeighborID] = &NeighborMetric{Inbound: 1} } else { @@ -60,13 +61,13 @@ func NetworkGraph() *graph.Graph { lock.RLock() defer lock.RUnlock() var nodeIDs []string - for id, _ := range nodes { + for id := range nodes { nodeIDs = append(nodeIDs, id) } g := graph.New(nodeIDs) for src, trgMap := range links { - for dst, _ := range trgMap { + for dst := range trgMap { g.AddEdge(src, dst) } } diff --git a/plugins/analysis/server/plugin.go b/plugins/analysis/server/plugin.go index 12821d33..668308c8 100644 --- a/plugins/analysis/server/plugin.go +++ b/plugins/analysis/server/plugin.go @@ -86,7 +86,7 @@ func run(_ *node.Plugin) { func HandleConnection(conn *network.ManagedConnection) { err := conn.SetReadTimeout(IdleTimeout) if err != nil { - log.Debugw("Error setting read timeout; closing connection", "err", err) + log.Warnw("Error setting read timeout; closing connection", "err", err) _ = conn.Close() return } @@ -103,7 +103,7 @@ func HandleConnection(conn *network.ManagedConnection) { buffer := make([]byte, 2048) _, err := conn.Read(buffer) if err != nil && err != io.EOF && !strings.Contains(err.Error(), "use of closed network connection") { - log.Debugw("Read error", "err", err) + log.Warnw("Read error", "err", err) } // always close the connection when we've stopped reading from it _ = conn.Close() -- GitLab