presets

package
v0.3.9 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2026 License: GPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultPresets

func DefaultPresets() map[string]Preset

DefaultPresets returns the built-in optimized presets

func ValidatePreset added in v0.3.5

func ValidatePreset(preset Preset) error

ValidatePreset validates a preset configuration

Types

type CustomPresetRegistry added in v0.3.5

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

CustomPresetRegistry holds user-defined custom presets

func NewCustomPresetRegistry added in v0.3.5

func NewCustomPresetRegistry() *CustomPresetRegistry

NewCustomPresetRegistry creates a new custom preset registry

func (*CustomPresetRegistry) AddPreset added in v0.3.5

func (r *CustomPresetRegistry) AddPreset(name string, preset Preset)

AddPreset adds a custom preset to the registry

func (*CustomPresetRegistry) GetAllPresets added in v0.3.5

func (r *CustomPresetRegistry) GetAllPresets() map[string]Preset

GetAllPresets returns all custom presets

func (*CustomPresetRegistry) GetPreset added in v0.3.5

func (r *CustomPresetRegistry) GetPreset(name string) (Preset, bool)

GetPreset returns a preset by name from custom registry

type Preset

type Preset struct {
	Name                string           `yaml:"name" json:"name"`
	Type                PresetType       `yaml:"type" json:"type"`
	PacketSize          RangeInt         `yaml:"packet_size" json:"packet_size"`                     // Packet size in bytes
	PacketsPerSecond    RangeInt         `yaml:"packets_per_sec" json:"packets_per_sec"`             // PPS rate
	UploadDownloadRatio float64          `yaml:"upload_download_ratio" json:"upload_download_ratio"` // e.g. 0.5 for 1:2
	SessionDuration     RangeDuration    `yaml:"session_duration" json:"session_duration"`           // Time before switching
	Patterns            []TrafficPattern `yaml:"patterns,omitempty" json:"patterns,omitempty"`       // Specific traffic patterns
}

Preset defines a complete behavior profile for mimicking a service

func DetectPreset

func DetectPreset(domain string, customRegistry *CustomPresetRegistry) Preset

DetectPreset finds the best preset for a domain Priority: 1) Custom presets by domain, 2) Default presets by domain, 3) web_generic

func DetectPresetByService added in v0.3.5

func DetectPresetByService(serviceName string, customRegistry *CustomPresetRegistry) Preset

DetectPresetByService detects preset by service name

type PresetType

type PresetType string

PresetType defines the category of the preset

const (
	TypeSocial    PresetType = "social"
	TypeVideo     PresetType = "video"
	TypeMessenger PresetType = "messenger"
	TypeWeb       PresetType = "web"
	TypeGaming    PresetType = "gaming"
	TypeVoIP      PresetType = "voip"
	TypeCustom    PresetType = "custom"
)

type RangeDuration

type RangeDuration struct {
	Min time.Duration `yaml:"min" json:"min"`
	Max time.Duration `yaml:"max" json:"max"`
}

RangeDuration represents a min-max duration range

func (RangeDuration) String added in v0.3.5

func (r RangeDuration) String() string

type RangeInt

type RangeInt struct {
	Min int `yaml:"min" json:"min"`
	Max int `yaml:"max" json:"max"`
}

RangeInt represents a min-max integer range

func GetOptimalPPS added in v0.3.5

func GetOptimalPPS(latencyMs int) RangeInt

GetOptimalPPS returns optimal packets per second for a given latency

func GetOptimalPacketSize added in v0.3.5

func GetOptimalPacketSize(bandwidthMbps float64) RangeInt

GetOptimalPacketSize returns optimal packet size for a given bandwidth

func (RangeInt) String

func (r RangeInt) String() string

type TrafficPattern

type TrafficPattern struct {
	Type     string        `yaml:"type" json:"type"`         // e.g., "burst", "constant", "idle"
	Duration RangeDuration `yaml:"duration" json:"duration"` // How long this pattern lasts
	Interval RangeDuration `yaml:"interval" json:"interval"` // Time between repetitions
}

TrafficPattern defines a specific behavior within a preset (e.g., "burst")

Jump to

Keyboard shortcuts

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