Documentation
¶
Overview ¶
Package intelligence implements the HiVoid adaptive decision engine. It monitors network conditions in real-time and selects operating modes to balance security, performance, and stealth requirements.
Package intelligence — real-time network metrics collection. These are fed into the decision engine for adaptive mode switching.
Package intelligence — active network probing.
Index ¶
- type Engine
- func (e *Engine) ActiveMode() Mode
- func (e *Engine) ActiveState() State
- func (e *Engine) BestTarget() string
- func (e *Engine) ExportState() ([]byte, error)
- func (e *Engine) ImportState(data []byte) error
- func (e *Engine) Metrics() *Metrics
- func (e *Engine) OnModeChange(fn func(Mode, TuningParams))
- func (e *Engine) ProbeResults() []ProbeResult
- func (e *Engine) SaveState() error
- func (e *Engine) SetMode(mode Mode)
- func (e *Engine) SetProbeTargets(targets []string)
- func (e *Engine) SetStatePath(path string)
- func (e *Engine) Start()
- func (e *Engine) Stop()
- func (e *Engine) ThreatLevel() int
- func (e *Engine) Tuning() TuningParams
- type Metrics
- type MetricsSnapshot
- type Mode
- type ProbeResult
- type Prober
- type State
- type TuningParams
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
Engine is the HiVoid intelligence decision engine. It continuously samples network metrics and adjusts tuning parameters.
func (*Engine) ActiveMode ¶
ActiveMode returns the currently active mode.
func (*Engine) ActiveState ¶ added in v1.1.0
ActiveState returns the currently detected network state.
func (*Engine) BestTarget ¶ added in v1.1.0
BestTarget selects the healthiest server from probe results using a ranking algorithm.
func (*Engine) ExportState ¶ added in v1.1.0
func (*Engine) ImportState ¶ added in v1.1.0
func (*Engine) OnModeChange ¶
func (e *Engine) OnModeChange(fn func(Mode, TuningParams))
OnModeChange registers a callback invoked when the mode changes.
func (*Engine) ProbeResults ¶ added in v1.1.0
func (e *Engine) ProbeResults() []ProbeResult
ProbeResults returns the latest results from active probing.
func (*Engine) SaveState ¶ added in v1.1.0
SaveState writes the current engine state to the configured file.
func (*Engine) SetMode ¶ added in v0.2.0
SetMode updates the configured mode at runtime. It is safe for concurrent use.
func (*Engine) SetProbeTargets ¶ added in v1.1.0
SetProbeTargets sets the server addresses to periodically check.
func (*Engine) SetStatePath ¶ added in v1.1.0
SetStatePath configures the file path for automatic persistence.
func (*Engine) ThreatLevel ¶ added in v1.1.0
ThreatLevel returns the current threat score (0-100).
func (*Engine) Tuning ¶
func (e *Engine) Tuning() TuningParams
Tuning returns the current tuning parameters (safe for concurrent use).
type Metrics ¶
type Metrics struct {
// contains filtered or unexported fields
}
Metrics is a thread-safe collector of QUIC-level network statistics. Values are updated by the transport layer via RecordRTT / RecordLoss / RecordBytes.
func (*Metrics) RecordBytes ¶
RecordBytes records n bytes transferred for throughput calculation.
func (*Metrics) RecordPacketLost ¶
func (m *Metrics) RecordPacketLost()
RecordPacketLost increments the lost packet counter.
func (*Metrics) RecordPacketSent ¶
func (m *Metrics) RecordPacketSent()
RecordPacketSent increments the sent packet counter.
func (*Metrics) RecordRTT ¶
RecordRTT updates the RTT exponential moving average. rtt should be the measured round-trip time for a recent packet.
func (*Metrics) Snapshot ¶
func (m *Metrics) Snapshot() MetricsSnapshot
Snapshot returns a point-in-time view of all metrics. It refreshes the throughput window if needed.
type MetricsSnapshot ¶
type MetricsSnapshot struct {
RTT time.Duration
RTTStdDev time.Duration
Jitter time.Duration
PacketLoss float64 // [0, 1]
Throughput int64 // bytes/sec
SampledAt time.Time
}
MetricsSnapshot is a point-in-time view of the collected metrics.
type Mode ¶
type Mode uint8
Mode represents an operating mode for the HiVoid protocol.
const ( // ModePerformance maximizes throughput, minimal overhead. ModePerformance Mode = iota // ModeStealth enables full obfuscation to avoid traffic analysis. ModeStealth // ModeBalanced balances performance and security (default). ModeBalanced // ModeAdaptive auto-switches based on network metrics. ModeAdaptive )
type ProbeResult ¶ added in v1.1.0
ProbeResult represents the outcome of a single active probe.
type Prober ¶ added in v1.1.0
type Prober struct {
// contains filtered or unexported fields
}
Prober performs active health checks on HiVoid servers.
func (*Prober) Probe ¶ added in v1.1.0
func (p *Prober) Probe(ctx context.Context, target string) ProbeResult
Probe checks the health of a target HiVoid server using a lightweight QUIC handshake. It doesn't perform full authentication, just tests path reachability and RTT.
func (*Prober) ProbeBatch ¶ added in v1.1.0
func (p *Prober) ProbeBatch(ctx context.Context, targets []string) []ProbeResult
ProbeBatch performs concurrent probes on multiple targets. ProbeBatch checks multiple targets concurrently and returns results in the same order as input.
type State ¶ added in v1.1.0
type State uint8
State represents the detected network condition state.
type TuningParams ¶
type TuningParams struct {
// EnableObfuscation activates the obfuscation layer.
EnableObfuscation bool
// PaddingPct is the fraction of frames that get random padding [0,1].
PaddingPct float64
// MaxPaddingBytes is the maximum padding to add per frame.
MaxPaddingBytes int
// StreamConcurrency is the max number of concurrent QUIC streams.
StreamConcurrency int
// RekeyInterval controls how often keys are rotated.
RekeyInterval time.Duration
// RTOMultiplier scales the retransmission timeout.
RTOMultiplier float64
}
TuningParams holds the output parameters from engine decisions. These are applied to the transport and obfuscation layers.
func DefaultTuning ¶
func DefaultTuning() TuningParams
DefaultTuning returns sane defaults for ModeBalanced.