tui

package
v0.21.0 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2026 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultKeyMap = keyMap{
	Quit:       key.NewBinding(key.WithKeys("q", "ctrl+c"), key.WithHelp("q", "quit")),
	ScrollUp:   key.NewBinding(key.WithKeys("k", "up"), key.WithHelp("k/↑", "up")),
	ScrollDown: key.NewBinding(key.WithKeys("j", "down"), key.WithHelp("j/↓", "down")),
	Top:        key.NewBinding(key.WithKeys("g"), key.WithHelp("g", "top")),
	Bottom:     key.NewBinding(key.WithKeys("G"), key.WithHelp("G", "bottom")),
	FilterTCP:  key.NewBinding(key.WithKeys("t"), key.WithHelp("t", "TCP")),
	FilterUDP:  key.NewBinding(key.WithKeys("u"), key.WithHelp("u", "UDP")),
	FilterICMP: key.NewBinding(key.WithKeys("i"), key.WithHelp("i", "ICMP")),
	FilterAll:  key.NewBinding(key.WithKeys("a"), key.WithHelp("a", "all")),
	ToggleBFD:  key.NewBinding(key.WithKeys("p"), key.WithHelp("p", "toggle pings")),
	Suspend:    key.NewBinding(key.WithKeys("s"), key.WithHelp("s", "pause")),
	Clear:      key.NewBinding(key.WithKeys("c"), key.WithHelp("c", "clear")),
}

Functions

func Run

func Run(ctx context.Context, packetsCh <-chan connection.PacketInfo, observer *TUIPacketObserver, statusProvider StatusProvider) error

Run starts the TUI with the given packet channel and status provider. It blocks until the TUI is closed (user presses 'q' or Ctrl+C).

Types

type ConnectionStatus

type ConnectionStatus = panels.ConnectionStatus

type ConnectionStatusMsg

type ConnectionStatusMsg struct {
	Connections []ConnectionStatus
}

ConnectionStatusMsg is sent when connection status is updated.

type Model

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

Model is the main Bubble Tea model for the TUI.

func NewModel

func NewModel(packetsCh <-chan connection.PacketInfo, observer *TUIPacketObserver, statusProvider StatusProvider) Model

NewModel creates a new TUI model.

func (Model) Init

func (m Model) Init() tea.Cmd

Init initializes the model.

func (Model) Update

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

Update handles messages.

func (Model) View

func (m Model) View() string

View renders the model.

type PacketMsg

type PacketMsg struct {
	Info connection.PacketInfo
}

PacketMsg is sent when a new packet is observed.

type StatusProvider

type StatusProvider interface {
	GetTunnelInfo() TunnelInfo
	GetConnections() []ConnectionStatus
}

StatusProvider provides tunnel and connection status.

type TUIPacketObserver

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

TUIPacketObserver implements connection.PacketObserver and sends packets to a channel.

func NewPacketObserver

func NewPacketObserver(ch chan<- connection.PacketInfo) *TUIPacketObserver

NewPacketObserver creates a new TUI packet observer with rate limiting.

func (*TUIPacketObserver) CheckAutoSuspend

func (o *TUIPacketObserver) CheckAutoSuspend(window time.Duration) (pps int64, didAutoSuspend bool)

CheckAutoSuspend reads and resets the packet counter, computes rate, and auto-suspends if the rate exceeds the threshold. Should be called periodically (e.g. every 500ms from the TUI tick).

func (*TUIPacketObserver) CountPacket

func (o *TUIPacketObserver) CountPacket()

CountPacket increments the packet counter without processing. Called by splice.go when suspended, to track rate.

func (*TUIPacketObserver) IsAutoSuspended

func (o *TUIPacketObserver) IsAutoSuspended() bool

IsAutoSuspended returns whether suspension was triggered automatically.

func (*TUIPacketObserver) IsSuspended

func (o *TUIPacketObserver) IsSuspended() bool

IsSuspended returns whether the observer is suspended.

func (*TUIPacketObserver) OnPacket

func (o *TUIPacketObserver) OnPacket(info connection.PacketInfo)

OnPacket is called when a packet is observed.

func (*TUIPacketObserver) Resume

func (o *TUIPacketObserver) Resume()

Resume resumes packet observation.

func (*TUIPacketObserver) Suspend

func (o *TUIPacketObserver) Suspend()

Suspend stops packet observation.

type TickMsg

type TickMsg time.Time

TickMsg is sent periodically to update status.

type TunnelInfo

type TunnelInfo = panels.TunnelInfo

Re-export types from panels for convenience

type TunnelInfoMsg

type TunnelInfoMsg struct {
	Info TunnelInfo
}

TunnelInfoMsg is sent when tunnel info is updated.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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