Documentation ¶
Index ¶
- Variables
- func Asset(name string) ([]byte, error)
- func AssetDir(name string) ([]string, error)
- func AssetInfo(name string) (os.FileInfo, error)
- func AssetNames() []string
- func CurrentKernelVersion() (uint32, error)
- func IsTracerSupportedByOS() (bool, error)
- func MustAsset(name string) []byte
- func RestoreAsset(dir, name string) error
- func RestoreAssets(dir, name string) error
- type BPFMapName
- type Callback
- type Config
- type ConnectionFamily
- type ConnectionStats
- func (c ConnectionStats) ByteKey(buffer *bytes.Buffer) ([]byte, error)
- func (v ConnectionStats) MarshalEasyJSON(w *jwriter.Writer)
- func (v ConnectionStats) MarshalJSON() ([]byte, error)
- func (c ConnectionStats) String() string
- func (v *ConnectionStats) UnmarshalEasyJSON(l *jlexer.Lexer)
- func (v *ConnectionStats) UnmarshalJSON(data []byte) error
- type ConnectionType
- type Connections
- type KProbeName
- type Tracer
Constants ¶
This section is empty.
Variables ¶
var (
ErrNotImplemented = errors.New("BPF-based network tracing not implemented on non-linux systems")
)
Functions ¶
func Asset ¶
Asset loads and returns the asset for the given name. It returns an error if the asset could not be found or could not be loaded.
func AssetDir ¶
AssetDir returns the file names below a certain directory embedded in the file by go-bindata. For example if you run go-bindata on data/... and data contains the following hierarchy:
data/ foo.txt img/ a.png b.png
then AssetDir("data") would return []string{"foo.txt", "img"} AssetDir("data/img") would return []string{"a.png", "b.png"} AssetDir("foo.txt") and AssetDir("notexist") would return an error AssetDir("") will return []string{"data"}.
func AssetInfo ¶
AssetInfo loads and returns the asset info for the given name. It returns an error if the asset could not be found or could not be loaded.
func CurrentKernelVersion ¶
func IsTracerSupportedByOS ¶
func MustAsset ¶
MustAsset is like Asset but panics when Asset would return an error. It simplifies safe initialization of global variables.
func RestoreAsset ¶
RestoreAsset restores an asset under the given directory
func RestoreAssets ¶
RestoreAssets restores an asset under the given directory recursively
Types ¶
type BPFMapName ¶
type BPFMapName string
const ( UDPv4Map BPFMapName = "udp_stats_ipv4" UDPv6Map BPFMapName = "udp_stats_ipv6" TCPv4Map BPFMapName = "tcp_stats_ipv4" TCPv6Map BPFMapName = "tcp_stats_ipv6" LatestTimestampMap BPFMapName = "latest_ts" TCPTracerStatusMap BPFMapName = "tcptracer_status" )
type Config ¶
type Config struct { // CollectTCPConns specifies whether the tracer should collect traffic statistics for TCP connections CollectTCPConns bool // CollectUDPConns specifies whether the tracer should collect traffic statistics for UDP connections CollectUDPConns bool // CollectIPv6Conns specifics whether the tracer should capture traffic for IPv6 TCP/UDP connections CollectIPv6Conns bool // UDPConnTimeout determines the length of traffic inactivity between two (IP, port)-pairs before declaring a UDP // connection as inactive. // Note: As UDP traffic is technically "connection-less", for tracking, we consider a UDP connection to be traffic // between a source and destination IP and port. UDPConnTimeout time.Duration // TCPConnTimeout is like UDPConnTimeout, but for TCP connections. TCP connections are cleared when // the BPF module receives a tcp_close call, but TCP connections also age out to catch cases where // tcp_close is not intercepted for some reason. TCPConnTimeout time.Duration }
func NewDefaultConfig ¶
func NewDefaultConfig() *Config
NewDefaultConfig enables traffic collection for all connection types
func (*Config) EnabledKProbes ¶
func (c *Config) EnabledKProbes() map[KProbeName]struct{}
EnabledKProbes returns a map of kprobes that are enabled per config settings
type ConnectionFamily ¶
type ConnectionFamily uint8
const ( AF_INET ConnectionFamily = 0 AF_INET6 ConnectionFamily = 1 )
type ConnectionStats ¶
type ConnectionStats struct { Pid uint32 `json:"pid"` Type ConnectionType `json:"type"` Family ConnectionFamily `json:"family"` // Source & Dest represented as a string to handle both IPv4 & IPv6 Source string `json:"source"` Dest string `json:"dest"` SPort uint16 `json:"sport"` DPort uint16 `json:"dport"` SendBytes uint64 `json:"send_bytes"` RecvBytes uint64 `json:"recv_bytes"` }
func (ConnectionStats) ByteKey ¶
func (c ConnectionStats) ByteKey(buffer *bytes.Buffer) ([]byte, error)
func (ConnectionStats) MarshalEasyJSON ¶
func (v ConnectionStats) MarshalEasyJSON(w *jwriter.Writer)
MarshalEasyJSON supports easyjson.Marshaler interface
func (ConnectionStats) MarshalJSON ¶
func (v ConnectionStats) MarshalJSON() ([]byte, error)
MarshalJSON supports json.Marshaler interface
func (ConnectionStats) String ¶
func (c ConnectionStats) String() string
func (*ConnectionStats) UnmarshalEasyJSON ¶
func (v *ConnectionStats) UnmarshalEasyJSON(l *jlexer.Lexer)
UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (*ConnectionStats) UnmarshalJSON ¶
func (v *ConnectionStats) UnmarshalJSON(data []byte) error
UnmarshalJSON supports json.Unmarshaler interface
type ConnectionType ¶
type ConnectionType uint8
const ( TCP ConnectionType = 0 UDP ConnectionType = 1 )
func (ConnectionType) String ¶
func (c ConnectionType) String() string
type Connections ¶
type Connections struct {
Conns []ConnectionStats `json:"connections"`
}
func (Connections) MarshalEasyJSON ¶
func (v Connections) MarshalEasyJSON(w *jwriter.Writer)
MarshalEasyJSON supports easyjson.Marshaler interface
func (Connections) MarshalJSON ¶
func (v Connections) MarshalJSON() ([]byte, error)
MarshalJSON supports json.Marshaler interface
func (*Connections) UnmarshalEasyJSON ¶
func (v *Connections) UnmarshalEasyJSON(l *jlexer.Lexer)
UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (*Connections) UnmarshalJSON ¶
func (v *Connections) UnmarshalJSON(data []byte) error
UnmarshalJSON supports json.Unmarshaler interface
type KProbeName ¶
type KProbeName string
const ( TCPv4Connect KProbeName = "kprobe/tcp_v4_connect" TCPv4ConnectReturn KProbeName = "kretprobe/tcp_v4_connect" TCPv6Connect KProbeName = "kprobe/tcp_v6_connect" TCPv6ConnectReturn KProbeName = "kretprobe/tcp_v6_connect" TCPSendMsg KProbeName = "kprobe/tcp_sendmsg" TCPCleanupRBuf KProbeName = "kprobe/tcp_cleanup_rbuf" TCPClose KProbeName = "kprobe/tcp_close" UDPSendMsg KProbeName = "kprobe/udp_sendmsg" UDPRecvMsg KProbeName = "kprobe/udp_recvmsg" UDPRecvMsgReturn KProbeName = "kretprobe/udp_recvmsg" )
type Tracer ¶
type Tracer struct{}
func NewEventTracer ¶
func (*Tracer) GetActiveConnections ¶
func (t *Tracer) GetActiveConnections() (*Connections, error)