Skip to content

Commit

Permalink
fix: filter peers to tcp connections (#163)
Browse files Browse the repository at this point in the history
Signed-off-by: Chris Gianelloni <[email protected]>
  • Loading branch information
wolf31o2 authored Mar 30, 2024
1 parent 049819a commit bba8a47
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 2 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (
"github.com/mikioh/tcp"
"github.com/mikioh/tcpinfo"
"github.com/rivo/tview"
netutil "github.com/shirou/gopsutil/v3/net"
"github.com/shirou/gopsutil/v3/process"
terminal "golang.org/x/term"

Expand Down Expand Up @@ -659,7 +660,7 @@ func getConnectionText(ctx context.Context) string {
return connectionText
}
// Get process in/out connections
connections, err := processMetrics.ConnectionsWithContext(ctx)
connections, err := netutil.ConnectionsPidWithContext(ctx, "tcp", processMetrics.Pid)
if err != nil {
sb.WriteString(fmt.Sprintf("Failed to get processes: %v", err))
}
Expand Down
4 changes: 3 additions & 1 deletion peers.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import (
"sync"
"time"

netutil "github.com/shirou/gopsutil/v3/net"

"github.com/blinklabs-io/nview/internal/config"
)

Expand All @@ -42,7 +44,7 @@ func filterPeers(ctx context.Context) error {
cfg := config.GetConfig()

// Get process in/out connections
connections, err := processMetrics.ConnectionsWithContext(ctx)
connections, err := netutil.ConnectionsPidWithContext(ctx, "tcp", processMetrics.Pid)
if err != nil {
return err
}
Expand Down

0 comments on commit bba8a47

Please sign in to comment.