Documentation
¶
Index ¶
- func ListAllDevices() ([]pcap.Interface, error)
- func UseAllDevices() []string
- type Connection
- type ConnectionData
- type ConnectionInfo
- type ConnectionsResult
- type DNSResolver
- type Direction
- type LocalSocket
- type Lookup
- type NetworkData
- type OpenSockets
- type Options
- type PcapClient
- type ProcessInfo
- type ProcessesResult
- type Protocol
- type RemoteAddrsResult
- type RemoteSocket
- type Segment
- type Sinker
- type Snapshot
- type Sniffer
- type SnifferLib
- type SocketFetcher
- type Stat
- type StatsManager
- type Unit
- type Utilization
- type ViewMode
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ListAllDevices ¶
func UseAllDevices ¶
func UseAllDevices() []string
Types ¶
type Connection ¶
type Connection struct {
Local LocalSocket
Remote RemoteSocket
}
type ConnectionData ¶
type ConnectionData struct {
DownloadBytes int
UploadBytes int
UploadPackets int
DownloadPackets int
ProcessName string
InterfaceName string
ProcessId int32
}
func (*ConnectionData) DivideBy ¶
func (d *ConnectionData) DivideBy(n int)
type ConnectionInfo ¶
type ConnectionsResult ¶
type ConnectionsResult struct {
Conn Connection
Data *ConnectionData
}
type DNSResolver ¶
type DNSResolver struct {
// contains filtered or unexported fields
}
func NewDnsResolver ¶
func NewDnsResolver() *DNSResolver
func (*DNSResolver) Close ¶
func (c *DNSResolver) Close()
func (*DNSResolver) Lookup ¶
func (c *DNSResolver) Lookup(ip string) string
Lookup resolve remote ip to the domains.
type LocalSocket ¶
type NetworkData ¶
type NetworkData struct {
UploadBytes int
DownloadBytes int
UploadPackets int
DownloadPackets int
ConnCount int
}
func (*NetworkData) DivideBy ¶
func (d *NetworkData) DivideBy(n int)
type OpenSockets ¶
type OpenSockets map[LocalSocket]ProcessInfo
type Options ¶
type Options struct {
// BPFFilter is the string pcap filter with the BPF syntax
// eg. "tcp and port 80"
BPFFilter string
// Interval is the interval for refresh rate in seconds
Interval int
// ViewMode represents the sniffer view mode, optional: bytes, packets, processes
ViewMode ViewMode
// DevicesPrefix represents prefixed devices to monitor
DevicesPrefix []string
// Unit of stats in processes mode, optional: B, Kb, KB, Mb, MB, Gb, GB
Unit Unit
// DisableDNSResolve decides whether if disable the DNS resolution
DisableDNSResolve bool
// AllDevices specifies whether to listen all devices or not
AllDevices bool
}
Options is the options set for the sniffer instance.
func DefaultOptions ¶
func DefaultOptions() Options
type PcapClient ¶
type PcapClient struct {
// contains filtered or unexported fields
}
func NewPcapClient ¶
func NewPcapClient(lookup Lookup, opt Options) (*PcapClient, error)
func (*PcapClient) Close ¶
func (c *PcapClient) Close()
type ProcessInfo ¶
func (ProcessInfo) ProcId ¶
func (p ProcessInfo) ProcId() int32
func (ProcessInfo) String ¶
func (p ProcessInfo) String() string
type ProcessesResult ¶
type ProcessesResult struct {
ProcessName string
Data *NetworkData
}
type RemoteAddrsResult ¶
type RemoteAddrsResult struct {
Addr string
Data *NetworkData
}
type RemoteSocket ¶
type Segment ¶
type Segment struct {
Interface string
DataLen int
Connection Connection
Direction Direction
}
type Sinker ¶
type Sinker struct {
// contains filtered or unexported fields
}
func (*Sinker) GetUtilization ¶
func (c *Sinker) GetUtilization() Utilization
type Snapshot ¶
type Snapshot struct {
Processes map[string]*NetworkData
RemoteAddrs map[string]*NetworkData
Connections map[Connection]*ConnectionData
TotalUploadBytes int
TotalDownloadBytes int
TotalUploadPackets int
TotalDownloadPackets int
TotalConnections int
}
func (*Snapshot) TopNConnections ¶
func (s *Snapshot) TopNConnections(n int, mode ViewMode) []ConnectionsResult
func (*Snapshot) TopNProcesses ¶
func (s *Snapshot) TopNProcesses(n int, mode ViewMode) []ProcessesResult
func (*Snapshot) TopNRemoteAddrs ¶
func (s *Snapshot) TopNRemoteAddrs(n int, mode ViewMode) []RemoteAddrsResult
type Sniffer ¶
type Sniffer struct {
// contains filtered or unexported fields
}
func NewSniffer ¶
func (*Sniffer) SwitchViewMode ¶
func (s *Sniffer) SwitchViewMode()
type SnifferLib ¶
type SnifferLib struct {
// contains filtered or unexported fields
}
func NewSnifferLib ¶
func NewSnifferLib() *SnifferLib
func (*SnifferLib) Close ¶
func (s *SnifferLib) Close()
func (*SnifferLib) GetStats ¶
func (s *SnifferLib) GetStats() *Snapshot
type SocketFetcher ¶
type SocketFetcher interface {
GetOpenSockets() (OpenSockets, error)
}
func GetSocketFetcher ¶
func GetSocketFetcher() SocketFetcher
type Stat ¶
type Stat struct {
OpenSockets OpenSockets
Utilization Utilization
}
type StatsManager ¶
type StatsManager struct {
// contains filtered or unexported fields
}
func NewStatsManager ¶
func NewStatsManager(opt Options) *StatsManager
func (*StatsManager) GetStats ¶
func (s *StatsManager) GetStats() interface{}
func (*StatsManager) Put ¶
func (s *StatsManager) Put(stat Stat)
type Utilization ¶
type Utilization map[Connection]*ConnectionInfo
Click to show internal directories.
Click to hide internal directories.

