From 2d39594fe7728769f9c8619e3853efd66d0cdca6 Mon Sep 17 00:00:00 2001 From: Christian Roessner Date: Wed, 16 Oct 2024 18:08:31 +0200 Subject: [PATCH] Fix: Filter non-established connections in netstats Add a check to skip processing of connections that are not in the "ESTABLISHED" state. This helps to prevent unnecessary computations and focuses on active connections. Signed-off-by: Christian Roessner --- server/lualib/connmgr/netstats.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/server/lualib/connmgr/netstats.go b/server/lualib/connmgr/netstats.go index 39366fd1..8005d89e 100644 --- a/server/lualib/connmgr/netstats.go +++ b/server/lualib/connmgr/netstats.go @@ -24,10 +24,11 @@ import ( "sync" "time" - config "github.com/croessner/nauthilus/server/config" + "github.com/croessner/nauthilus/server/config" "github.com/croessner/nauthilus/server/global" "github.com/croessner/nauthilus/server/log" "github.com/croessner/nauthilus/server/util" + "github.com/go-kit/log/level" psnet "github.com/shirou/gopsutil/v4/net" "github.com/yuin/gopher-lua" @@ -255,6 +256,10 @@ func (m *ConnectionManager) UpdateCounts() { for _, conn := range connections { var addr psnet.Addr + if conn.Status != "ESTABLISHED" { + continue + } + if info.Direction == "local" { addr = conn.Laddr } else {