network

package
v0.5.3 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2026 License: MIT Imports: 21 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Apply

func Apply(ctx context.Context, opts WinOpts) error

func CleanupQosPolicies

func CleanupQosPolicies()

CleanupQosPolicies removes leftover Steadybit QoS policies. It only looks for them when they may exist, as it holds the lock that network attacks wait for.

func Revert

func Revert(ctx context.Context, opts WinOpts) error

Types

type BlackholeOpts

type BlackholeOpts struct {
	Filter
	Duration time.Duration
}

func (*BlackholeOpts) QoSPolicies added in v0.5.0

func (o *BlackholeOpts) QoSPolicies() []QosPolicy

func (*BlackholeOpts) String

func (o *BlackholeOpts) String() string

func (*BlackholeOpts) WinDivert added in v0.5.0

func (o *BlackholeOpts) WinDivert() *WinDivertOpts

type CorruptPackagesOpts

type CorruptPackagesOpts struct {
	Filter
	Corruption uint
	Duration   time.Duration
}

func (*CorruptPackagesOpts) QoSPolicies added in v0.5.0

func (o *CorruptPackagesOpts) QoSPolicies() []QosPolicy

func (*CorruptPackagesOpts) String

func (o *CorruptPackagesOpts) String() string

func (*CorruptPackagesOpts) WinDivert added in v0.5.0

func (o *CorruptPackagesOpts) WinDivert() *WinDivertOpts

type DelayOpts

type DelayOpts struct {
	Filter
	Delay    time.Duration
	Duration time.Duration
	Jitter   bool
}

func (*DelayOpts) QoSPolicies added in v0.5.0

func (o *DelayOpts) QoSPolicies() []QosPolicy

func (*DelayOpts) String

func (o *DelayOpts) String() string

func (*DelayOpts) WinDivert added in v0.5.0

func (o *DelayOpts) WinDivert() *WinDivertOpts

type Direction

type Direction string
var (
	DirectionIncoming Direction = "Incoming"
	DirectionOutgoing Direction = "Outgoing"
	DirectionAll      Direction = "All"
)

type Family

type Family string
const (
	FamilyV4 Family = "inet"
	FamilyV6 Family = "inet6"
)

type Filter

type Filter struct {
	Include          []akn.NetWithPortRange
	Exclude          []akn.NetWithPortRange
	InterfaceIndexes []int
	Direction        Direction
	// ExcludeLoopback leaves loopback traffic (127.0.0.0/8, ::1) untouched.
	// WinDivert captures loopback packets, so they are affected unless excluded.
	ExcludeLoopback bool
}

type LimitBandwidthOpts

type LimitBandwidthOpts struct {
	// Bandwidth names the limit in the policy names, e.g. "1024KB" for 1024kbit.
	Bandwidth     string
	BitsPerSecond uint64
	IncludeCidrs  []net.IPNet
	PortRange     network.PortRange
}

func (*LimitBandwidthOpts) QoSPolicies added in v0.5.0

func (o *LimitBandwidthOpts) QoSPolicies() []QosPolicy

func (*LimitBandwidthOpts) String

func (o *LimitBandwidthOpts) String() string

func (*LimitBandwidthOpts) WinDivert added in v0.5.0

func (o *LimitBandwidthOpts) WinDivert() *WinDivertOpts

type Mode

type Mode string
const (
	ModeAdd    Mode = "add"
	ModeDelete Mode = "del"
)

type PackageLossOpts

type PackageLossOpts struct {
	Filter
	Loss     uint
	Duration time.Duration
}

func (*PackageLossOpts) QoSPolicies added in v0.5.0

func (o *PackageLossOpts) QoSPolicies() []QosPolicy

func (*PackageLossOpts) String

func (o *PackageLossOpts) String() string

func (*PackageLossOpts) WinDivert added in v0.5.0

func (o *PackageLossOpts) WinDivert() *WinDivertOpts

type QosPolicy added in v0.5.0

type QosPolicy struct {
	Name          string
	BitsPerSecond uint64
	DstPrefix     string
	// DstPortFrom and DstPortTo are zero when the policy applies to all ports.
	DstPortFrom uint16
	DstPortTo   uint16
}

type WinDivertMode added in v0.5.0

type WinDivertMode string
const (
	WinDivertModeDelay   WinDivertMode = "delay"
	WinDivertModeDrop    WinDivertMode = "drop"
	WinDivertModeCorrupt WinDivertMode = "corrupt"
)

type WinDivertOpts added in v0.5.0

type WinDivertOpts struct {
	Filter   Filter
	Mode     WinDivertMode
	Duration time.Duration
	// Delay and Jitter apply to WinDivertModeDelay, Percentage to WinDivertModeDrop and WinDivertModeCorrupt.
	Delay      time.Duration
	Jitter     bool
	Percentage uint
	FlushDNS   bool
}

type WinOpts

type WinOpts interface {
	// QoSPolicies returns the QoS policies for attacks implemented with Windows QoS, nil otherwise.
	QoSPolicies() []QosPolicy
	// WinDivert returns the wdna.exe run for attacks implemented with WinDivert, nil otherwise.
	WinDivert() *WinDivertOpts
	String() string
}

Jump to

Keyboard shortcuts

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