trafficproxy

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Profiles = map[string]Profile{
	"3g": {
		Latency:   200 * time.Millisecond,
		Jitter:    50 * time.Millisecond,
		Bandwidth: 250 * 1024,
	},
	"edge": {
		Latency:   400 * time.Millisecond,
		Jitter:    100 * time.Millisecond,
		Bandwidth: 50 * 1024,
	},
	"slow": {
		Latency:    500 * time.Millisecond,
		Jitter:     200 * time.Millisecond,
		Bandwidth:  10 * 1024,
		PacketLoss: 0.05,
	},
}

Functions

func Start

func Start(targetPort string, profileName string) (int, func(), error)

Start spins up a local TCP proxy that introduces traffic shaping (latency, jitter, bandwidth limits) before forwarding the traffic to the destination port. Returns the allocated local port, a cleanup closure, and any error.

Types

type Profile

type Profile struct {
	Latency    time.Duration
	Jitter     time.Duration
	Bandwidth  int     // bytes per second
	PacketLoss float64 // probability 0.0 to 1.0
}

Profile maps named network profiles to actual constraints

Jump to

Keyboard shortcuts

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