Documentation
¶
Index ¶
- func ExtractPort(addr string) int
- func FormatContainerColumn(ci *ContainerInfo, pm *PortMapping, maxWidth int) string
- type Application
- type Connection
- type ConnectionKey
- type ConnectionState
- type ContainerInfo
- type NetIOStats
- type NetworkSnapshot
- type PortMapping
- type Protocol
- type SelectionID
- type VirtualContainer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExtractPort ¶
ExtractPort extracts port number from an address string like "127.0.0.1:8080". Returns 0 if the address doesn't contain a valid port.
func FormatContainerColumn ¶ added in v0.1.11
func FormatContainerColumn(ci *ContainerInfo, pm *PortMapping, maxWidth int) string
FormatContainerColumn returns display string for the Container column. Format: "name (image) hostPort→containerPort". Truncates to maxWidth runes with "…".
Types ¶
type Application ¶
type Application struct {
Name string // Process name (e.g., Chrome)
Exe string // Full path to executable (e.g., /usr/bin/chrome)
PIDs []int32 // All PIDs running this app
Connections []Connection // All connections across all PIDs
EstablishedCount int // Number of ESTABLISHED connections
ListenCount int // Number of LISTEN connections
}
Application represents a grouped set of connections by app name.
func (*Application) ConnectionCount ¶
func (a *Application) ConnectionCount() int
ConnectionCount returns the number of connections for this application.
type Connection ¶
type Connection struct {
PID int32 // Process ID owning this connection
Protocol Protocol // TCP or UDP
LocalAddr string // e.g., 127.0.0.1:52341
RemoteAddr string // e.g., 142.250.80.46:443 or * for listening
State ConnectionState // e.g., ESTABLISHED, LISTEN, - for UDP
Container *ContainerInfo // Docker container info (nil for non-Docker)
PortMapping *PortMapping // Docker port mapping (nil if no mapping)
}
Connection represents a single network connection.
type ConnectionKey ¶
ConnectionKey uniquely identifies a connection.
type ConnectionState ¶
type ConnectionState string
ConnectionState represents a TCP connection state.
const ( StateEstablished ConnectionState = "ESTABLISHED" StateListen ConnectionState = "LISTEN" StateTimeWait ConnectionState = "TIME_WAIT" StateCloseWait ConnectionState = "CLOSE_WAIT" StateNone ConnectionState = "-" )
type ContainerInfo ¶ added in v0.1.11
type ContainerInfo struct {
Name string // Container name (e.g., "nginx-proxy")
Image string // Image tag (e.g., "nginx:latest")
ID string // Short container ID
}
ContainerInfo holds Docker container metadata for a connection.
type NetIOStats ¶
type NetIOStats struct {
BytesSent uint64 // Total bytes sent
BytesRecv uint64 // Total bytes received
UpdatedAt time.Time // When these stats were last updated
}
NetIOStats represents network I/O statistics for a process.
type NetworkSnapshot ¶
type NetworkSnapshot struct {
Applications []Application
Timestamp time.Time
SkippedCount int // Number of connections skipped due to unknown process
}
NetworkSnapshot represents all network data at a point in time.
func (*NetworkSnapshot) SortByConnectionCount ¶
func (s *NetworkSnapshot) SortByConnectionCount()
SortByConnectionCount sorts applications by number of connections (descending).
func (*NetworkSnapshot) TotalConnections ¶
func (s *NetworkSnapshot) TotalConnections() int
TotalConnections returns the total number of connections across all apps.
type PortMapping ¶ added in v0.1.11
type PortMapping struct {
HostPort int // Port on the host (e.g., 8080)
ContainerPort int // Port inside the container (e.g., 80)
Protocol string // "tcp" or "udp"
}
PortMapping represents a Docker container port binding.
type SelectionID ¶
type SelectionID struct {
ProcessName string
ConnectionKey *ConnectionKey
}
SelectionID identifies a selected item (process or connection).
func SelectionIDFromConnection ¶
func SelectionIDFromConnection(processName, localAddr, remoteAddr string) SelectionID
SelectionIDFromConnection creates a SelectionID for a connection.
func SelectionIDFromProcess ¶
func SelectionIDFromProcess(name string) SelectionID
SelectionIDFromProcess creates a SelectionID for a process.
type VirtualContainer ¶ added in v0.1.12
type VirtualContainer struct {
Info ContainerInfo
PortMappings []PortMapping
}
VirtualContainer represents a Docker container as a virtual process row.