ping

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package ping provides TUI model for ping diagnostic tool

Package ping provides ping diagnostic functionality

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatPingStatistics

func FormatPingStatistics(stats PingStatistics) string

FormatPingStatistics formats ping statistics for display

Types

type LatencyGraph

type LatencyGraph struct {
	Values    []time.Duration
	MaxValues int
	MaxRTT    time.Duration
	MinRTT    time.Duration
	Width     int
	Height    int
}

LatencyGraph represents a simple ASCII graph of latency over time

type LiveStatistics

type LiveStatistics struct {
	PacketsSent     int           `json:"packets_sent"`
	PacketsReceived int           `json:"packets_received"`
	PacketLoss      float64       `json:"packet_loss_percent"`
	MinRTT          time.Duration `json:"min_rtt"`
	MaxRTT          time.Duration `json:"max_rtt"`
	AvgRTT          time.Duration `json:"avg_rtt"`
	LastRTT         time.Duration `json:"last_rtt"`
	Jitter          time.Duration `json:"jitter"`
	ElapsedTime     time.Duration `json:"elapsed_time"`
}

LiveStatistics tracks real-time ping statistics

type Model

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

Model represents the ping tool TUI model

func NewModel

func NewModel(tool *Tool) *Model

NewModel creates a new ping model

func (*Model) Blur

func (m *Model) Blur()

Blur blurs the model

func (*Model) Focus

func (m *Model) Focus()

Focus focuses the model

func (*Model) Init

func (m *Model) Init() tea.Cmd

Init initializes the model

func (*Model) SetSize

func (m *Model) SetSize(width, height int)

SetSize sets the model dimensions

func (*Model) SetTheme

func (m *Model) SetTheme(theme domain.Theme)

SetTheme sets the model theme

func (*Model) Update

func (m *Model) Update(msg tea.Msg) (tea.Model, tea.Cmd)

Update handles messages and updates the model

func (*Model) View

func (m *Model) View() string

View renders the model

type ModelState

type ModelState int

ModelState represents the current state of the model

const (
	StateInput ModelState = iota
	StateRunning
	StateResult
	StateError
)

type PacketLossIndicator

type PacketLossIndicator struct {
	RecentResults []bool // true = success, false = loss
	MaxResults    int
	LossCount     int
	TotalCount    int
}

PacketLossIndicator shows packet loss visualization

type PingStatistics

type PingStatistics struct {
	PacketsSent     int           `json:"packets_sent"`
	PacketsReceived int           `json:"packets_received"`
	PacketLoss      float64       `json:"packet_loss_percent"`
	MinRTT          time.Duration `json:"min_rtt"`
	MaxRTT          time.Duration `json:"max_rtt"`
	AvgRTT          time.Duration `json:"avg_rtt"`
	StdDevRTT       time.Duration `json:"stddev_rtt"`
	TotalTime       time.Duration `json:"total_time"`
}

PingStatistics contains calculated ping statistics

type Tool

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

Tool implements the DiagnosticTool interface for ping operations

func NewTool

func NewTool(client domain.NetworkClient, logger domain.Logger) *Tool

NewTool creates a new ping diagnostic tool

func (*Tool) Description

func (t *Tool) Description() string

Description returns the tool description

func (*Tool) Execute

func (t *Tool) Execute(ctx context.Context, params domain.Parameters) (domain.Result, error)

Execute performs the ping operation

func (*Tool) GetModel

func (t *Tool) GetModel() tea.Model

GetModel returns the Bubble Tea model for the ping tool

func (*Tool) Name

func (t *Tool) Name() string

Name returns the tool name

func (*Tool) Validate

func (t *Tool) Validate(params domain.Parameters) error

Validate validates the parameters for ping operations

Jump to

Keyboard shortcuts

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