connstate

package module
v0.1.11 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 10, 2023 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidPID               = errors.New("invalid PID")
	ErrFailedToGetPIDFromCgroup = errors.New("failed to get PID from cgroup")
	ErrNotImplementYet          = errors.New("not implement yet")
)

Functions

func EnterNetNS added in v0.1.11

func EnterNetNS(newNs, curNs netns.NsHandle) (func(), error)

EnterNetNS sets execution of the code following this call to the network namespace newNs, then moves the thread back to curNs if open, otherwise to the current netns at the time the function was invoked In case of success, the caller is expected to execute the returned function at the end of the code that needs to be executed in the network namespace. Example:

func jobAt(...) error {
     d, err := EnterNetNS(...)
     if err != nil { return err}
     defer d()
     < code which needs to be executed in specific netns>
 }

Shadow from netns package

func GetReadableState

func GetReadableState(state uint8) string

func IsSystemdCgroupPath added in v0.1.9

func IsSystemdCgroupPath(containerdCgroupPath string) (segments []string, isSystemdCgroupStyle bool)

Types

type ConnectionState

type ConnectionState struct {
	Container
	NetNSID string
	IPv4    TCPStates
	IPv6    TCPStates
}

type ConnectionStatistics added in v0.1.3

type ConnectionStatistics struct {
	Container
	NetNSID string
	IPv4    TCPStatistics
	IPv6    TCPStatistics
}

type Container

type Container struct {
	ID       string
	PID      int
	Hostname string
	// Stores extension data
	Annotations map[string]string
}

type ContainerDriver

type ContainerDriver interface {
	ListContainer(context.Context) ([]Container, error)
}

type ContainerFilter added in v0.1.6

type ContainerFilter func(Container) (pass bool)

Return false if wanna bypass

type ContainerdDriver

type ContainerdDriver struct {
	// contains filtered or unexported fields
}

func NewContainerdDriver

func NewContainerdDriver(client *containerd.Client, opts ...OptionsFunc) (*ContainerdDriver, error)

func (*ContainerdDriver) ListContainer

func (d *ContainerdDriver) ListContainer(ctx context.Context) ([]Container, error)

type Options

type Options struct {
	// contains filtered or unexported fields
}

func NewDefaultOptions

func NewDefaultOptions() *Options

type OptionsFunc

type OptionsFunc func(*Options) error

func WithEnvCollectionFilter

func WithEnvCollectionFilter(filter func(string) bool) OptionsFunc

func WithFixedCgroupRoot

func WithFixedCgroupRoot(path string) OptionsFunc

type TCPState

type TCPState struct {
	Socket  netlink.Socket
	TXBytes uint64
	RXBytes uint64
}

type TCPStates

type TCPStates []TCPState

type TCPStatistics added in v0.1.3

type TCPStatistics struct {
	// contains filtered or unexported fields
}

func NewTCPStatistics added in v0.1.7

func NewTCPStatistics() *TCPStatistics

func (TCPStatistics) AllocatedPortCount added in v0.1.7

func (s TCPStatistics) AllocatedPortCount() int

func (TCPStatistics) CountByState added in v0.1.7

func (s TCPStatistics) CountByState() map[uint8]uint64

func (*TCPStatistics) Record added in v0.1.7

func (s *TCPStatistics) Record(socket *netlink.Socket)

type Tracker

type Tracker struct {
	// contains filtered or unexported fields
}

func NewTracker

func NewTracker(driver ContainerDriver, families []uint8) (*Tracker, error)

func (*Tracker) GetConnectionState

func (t *Tracker) GetConnectionState(container Container) (*ConnectionState, error)

func (*Tracker) GetConnectionStatistics added in v0.1.3

func (t *Tracker) GetConnectionStatistics(container Container) (*ConnectionStatistics, error)

func (*Tracker) ListAllConnectionState

func (t *Tracker) ListAllConnectionState(ctx context.Context, filter ContainerFilter) ([]ConnectionState, error)

func (*Tracker) ListAllConnectionStatistics added in v0.1.3

func (t *Tracker) ListAllConnectionStatistics(ctx context.Context, filter ContainerFilter) ([]ConnectionStatistics, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL