tcpconn

package
v0.3.11 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2024 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Overview

Package tcpconn contains a TCP connection disruptor.

Index

Constants

This section is empty.

Variables

View Source
var ErrDurationTooShort = errors.New("duration must be at least 1 second")

ErrDurationTooShort is returned when the supplied duration is smaller than 1s.

Functions

This section is empty.

Types

type Disruptor

type Disruptor struct {
	Iptables iptables.Iptables
	Dropper  Dropper
	Filter   Filter
}

Disruptor applies TCP Connection disruptions by dropping connections according to a Dropper. A filter decides which connections are considered for dropping.

func (Disruptor) Apply

func (d Disruptor) Apply(ctx context.Context, duration time.Duration) error

Apply starts the disruption by subjecting connections that match the configured Filter to the Dropper.

type Dropper

type Dropper interface {
	Drop(packetBytes []byte) bool
}

Dropper is an interface implemented by objects that decide whether a packet should be dropped (rejected).

type Filter

type Filter struct {
	// Port is the target port to match which connections will be intercepted.
	Port uint
}

Filter holds the matchers used to know which traffic should be intercepted.

type TCPConnectionDropper

type TCPConnectionDropper struct {
	DropRate float64
}

TCPConnectionDropper is a dropper that drops a defined percentage of TCP the connections it sees.

func (TCPConnectionDropper) Drop

func (tcd TCPConnectionDropper) Drop(packetBytes []byte) bool

Drop decides whether a packet should be dropped by taking the modulus of hash of the connection it belongs to and comparing it to a threshold derived from DropRate.

Jump to

Keyboard shortcuts

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