Documentation ¶
Overview ¶
Package netstat provides primitives for getting socket information on a Linux based operating system.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var TimerActives = [...]string{
"Off",
"On",
"KeepAlive",
"TimeWait",
"ProbeTimer",
}
Functions ¶
func NoopFilter ¶
func NoopFilter(*SockTabEntry) bool
NoopFilter - a test function returning true for all elements
Types ¶
type AcceptFn ¶
type AcceptFn func(*SockTabEntry) bool
AcceptFn is used to filter socket entries. The value returned indicates whether the element is to be appended to the socket list.
type EnableFeatures ¶
type EnableFeatures struct { // TCP sockets and connections TCP bool // TCP6 (ipv6) sockets and connections TCP6 bool // UDP sockets and connections UDP bool // UDP6 (ipv6) sockets and connections UDP6 bool // UDP-Lite sockets and connections UDPLite bool // UDP-Lite6 (ipv6) sockets and connections UDPLite6 bool // Raw sockets and connections Raw bool // Raw6 (ipv6) sockets and connections Raw6 bool // Processes and Programs using sockets PID bool // Disable host network namespace NoHostNetwork bool // All network namespaces AllNetNs bool // Network namespace names using sockets and connections NetNsName []string // Network namespace PIDs using sockets and connections NetNsPids []uint32 }
type SkState ¶
type SkState uint8
SkState type represents socket connection state
type SockEndpoint ¶
SockEndpoint represents an ip:port pair
func (*SockEndpoint) String ¶
func (s *SockEndpoint) String() string
type SockTabEntry ¶
type SockTabEntry struct { // Layer4 protocol, tcp, tcp6, udp or udp6 Transport string // Local IPv4 address + Port LocalEndpoint *SockEndpoint // Remote IPv4 address + Port RemoteEndpoint *SockEndpoint // connection state State SkState // transmit-queue TxQueue uint64 // receive-queue RxQueue uint64 // timer_active Tr TimerActive // number of jiffies until timer expires TimerWhen uint64 // number of unrecovered RTO Retransmission Timeouts Retrnsmt uint64 // user ID UID uint32 // unanswered 0-window probes Timeout uint64 // inode Inode uint64 // socket reference count Ref uint64 // location of socket in memory Pointer uint64 Process *common.Process NetNS string }
SockTabEntry type represents each line of the /proc/net/[tcp|udp] Kernel >=5.15
func Netstat ¶
func Netstat(ctx context.Context, feature EnableFeatures, fn AcceptFn) ([]SockTabEntry, error)
Netstat - collect information about network port status
type TimerActive ¶
type TimerActive uint8
TimerActive represents the state of the socket timer
const ( Off TimerActive = 0x00 On TimerActive = 0x01 KeepAlive TimerActive = 0x02 TimeWaitTimer TimerActive = 0x03 // Unsure how to call this ProbeTimer TimerActive = 0x04 // Unsure how to call this )
socket timer states
func (TimerActive) String ¶
func (t TimerActive) String() string
Click to show internal directories.
Click to hide internal directories.