network

package
v0.0.0-...-d15df5a Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2024 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FinalIdleDuraton = 3 * time.Second
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Capture

type Capture struct {
	sync.Mutex

	Stats CaptureStats
	// contains filtered or unexported fields
}

func NewCapture

func NewCapture(cfg CaptureConfig) *Capture

func (*Capture) GetL4TrafficCount

func (c *Capture) GetL4TrafficCount(ft FiveTuple) uint64

func (*Capture) GetTrafficCount

func (c *Capture) GetTrafficCount(ft FiveTuple) uint64

func (*Capture) Start

func (c *Capture) Start() error

func (*Capture) Stop

func (c *Capture) Stop() error

type CaptureConfig

type CaptureConfig struct {
	Iface     string
	PCAPPath  string
	Snaplen   int
	TargetNS  *NetNS
	LayerType string
}

func (*CaptureConfig) SetDefaults

func (cfg *CaptureConfig) SetDefaults()

type CaptureStats

type CaptureStats struct {
	Count      int64
	Bytes      int64
	Start      time.Time
	Errors     int64
	Truncated  int64
	LayerTypes map[gopacket.LayerType]int64
}

type FiveTuple

type FiveTuple string

func Make5Tuple

func Make5Tuple(srcIP net.IP, srcPort int, dstIP net.IP, dstPort int, proto layers.IPProtocol) FiveTuple

type NetNS

type NetNS struct {
	ns.NetNS
	Name string
	// contains filtered or unexported fields
}

func NewNS

func NewNS(name string) (*NetNS, error)

func (*NetNS) AddAddress

func (netns *NetNS) AddAddress(linkName string, address *net.IPNet) error

func (*NetNS) AddCleanup

func (netns *NetNS) AddCleanup(toCall func())

func (*NetNS) AddRoute

func (netns *NetNS) AddRoute(dst *net.IPNet, gw net.IP) error

func (*NetNS) Close

func (netns *NetNS) Close() error

func (*NetNS) DelNetem

func (netns *NetNS) DelNetem(linkName string) (bool, error)

func (*NetNS) DialContext

func (netns *NetNS) DialContext(ctx context.Context, network, address string) (net.Conn, error)

func (*NetNS) DialUDP

func (netns *NetNS) DialUDP(ctx context.Context, laddr, raddr *net.UDPAddr) (*net.UDPConn, error)

func (*NetNS) Do

func (netns *NetNS) Do(toCall func() error) error

func (*NetNS) Handle

func (netns *NetNS) Handle() nns.NsHandle

func (*NetNS) ListenTCP

func (netns *NetNS) ListenTCP(ctx context.Context, address string) (net.Listener, error)

func (*NetNS) ListenUDP

func (netns *NetNS) ListenUDP(ctx context.Context, laddr *net.UDPAddr) (*net.UDPConn, error)

func (*NetNS) SetIPv6

func (netns *NetNS) SetIPv6()

func (*NetNS) SetLinkUp

func (netns *NetNS) SetLinkUp(linkName string) error

func (*NetNS) SetNetem

func (netns *NetNS) SetNetem(linkName string, attrs NetemAttrs) error

type NetemAttrs

type NetemAttrs netlink.NetemQdiscAttrs

Jump to

Keyboard shortcuts

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