netfault

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2026 License: AGPL-3.0 Imports: 8 Imported by: 0 modules, 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

Overview

Package netfault is a TCP proxy that a load or chaos run puts between a client and a server so it can cut, blackhole or shape the connection without touching either end.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Proxy

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

Proxy forwards TCP connections from a loopback listener to a target and can cut, blackhole or shape them.

func Listen

func Listen(target string, seed uint64) (*Proxy, error)

Listen starts a proxy on 127.0.0.1:0 forwarding to target. seed drives the jitter.

func (*Proxy) Addr

func (p *Proxy) Addr() string

Addr is the proxy's host:port.

func (*Proxy) Blackhole

func (p *Proxy) Blackhole()

Blackhole keeps connections open but forwards nothing in either direction, and accepts new connections without dialing the target, until Heal.

func (*Proxy) Close

func (p *Proxy) Close() error

Close stops the listener, closes every connection and waits for the proxy's goroutines to finish.

func (*Proxy) Cut

func (p *Proxy) Cut()

Cut closes every connection the proxy carries and refuses new ones until Heal. Data a blackhole was holding is dropped: each link is canceled before the mode changes, so nothing parked on the blackhole wakes to forward it.

func (*Proxy) Heal

func (p *Proxy) Heal()

Heal returns to pass-through: refused connections are accepted again, blackholed data flows and shaping is removed.

func (*Proxy) Shape

func (p *Proxy) Shape(delay, jitter time.Duration, bytesPerSec int)

Shape delays each forwarded chunk by delay plus or minus jitter (order preserved) and, when bytesPerSec is positive, caps each direction's throughput.

Jump to

Keyboard shortcuts

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