Skip to content

Commit

Permalink
Fix: Filter non-established connections in netstats
Browse files Browse the repository at this point in the history
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 <c@roessner.co>
  • Loading branch information
Christian Roessner committed Oct 16, 2024
1 parent 1926e8e commit 2d39594
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion server/lualib/connmgr/netstats.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 2d39594

Please sign in to comment.