panels

package
v0.22.0 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2026 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// LeftMargin is the left margin for content inside panels
	LeftMargin = "  "

	// CONNECTIONS table column widths
	ConnIDWidth     = 38 // full UUID (36 chars) + 2 padding
	ConnStatusWidth = 12
	ConnUptimeWidth = 10
	ConnAddrsWidth  = 40

	// TRAFFIC table column widths
	TimeWidth  = 10
	ProtoWidth = 6
	SrcWidth   = 42 // full IPv6 ULA + port
	DstWidth   = 42
	SizeWidth  = 7
	FlagsWidth = 6
	DirWidth   = 4
)

Variables

View Source
var (
	// Panel styles
	HeaderStyle = lipgloss.NewStyle().
				Bold(true).
				Foreground(lipgloss.Color("87")) // cyan

	BorderStyle = lipgloss.NewStyle().
				Border(lipgloss.RoundedBorder()).
				BorderForeground(lipgloss.Color("240")).
				MarginTop(1)

	TrafficBorderStyle = lipgloss.NewStyle().
						Border(lipgloss.RoundedBorder(), true, true, false, true).
						BorderForeground(lipgloss.Color("240"))

	// Text styles
	LabelStyle = lipgloss.NewStyle().
				Foreground(lipgloss.Color("250"))

	ValueStyle = lipgloss.NewStyle().
				Foreground(lipgloss.Color("255"))

	DimStyle = lipgloss.NewStyle().
				Foreground(lipgloss.Color("243"))

	// Status styles
	HealthyStyle = lipgloss.NewStyle().
					Foreground(lipgloss.Color("82")) // green

	UnhealthyStyle = lipgloss.NewStyle().
					Foreground(lipgloss.Color("196")) // red

	// Protocol styles
	TCPStyle = lipgloss.NewStyle().
				Foreground(lipgloss.Color("39")) // blue

	UDPStyle = lipgloss.NewStyle().
				Foreground(lipgloss.Color("208")) // orange

	ICMPStyle = lipgloss.NewStyle().
				Foreground(lipgloss.Color("141")) // purple

	UnknownProtoStyle = lipgloss.NewStyle().
						Foreground(lipgloss.Color("243")) // gray

	// Direction styles
	InboundStyle = lipgloss.NewStyle().
					Foreground(lipgloss.Color("82")) // green

	OutboundStyle = lipgloss.NewStyle().
					Foreground(lipgloss.Color("226")) // yellow

	// Help style
	HelpStyle = lipgloss.NewStyle().
				Foreground(lipgloss.Color("243"))

	// Column header style
	ColumnHeaderStyle = lipgloss.NewStyle().
						Foreground(lipgloss.Color("250")).
						Bold(true)

	// Paused indicator style
	PausedStyle = lipgloss.NewStyle().
				Bold(true).
				Foreground(lipgloss.Color("226")).
				Background(lipgloss.Color("52")) // dark red
)

Functions

func CellStyle

func CellStyle(width int) lipgloss.Style

CellStyle returns a fixed-width cell style for proper column alignment. This handles ANSI escape codes correctly by using visual width.

Types

type ConnectionStatus

type ConnectionStatus struct {
	ID          string
	IsHealthy   bool
	ConnectedAt time.Time
	LocalAddrs  []string
}

ConnectionStatus contains status information about a single connection.

type HeaderPanel

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

HeaderPanel displays tunnel info and connection status.

func NewHeaderPanel

func NewHeaderPanel() HeaderPanel

NewHeaderPanel creates a new header panel.

func (HeaderPanel) Height

func (p HeaderPanel) Height() int

Height returns the height of the header panel.

func (*HeaderPanel) SetConnections

func (p *HeaderPanel) SetConnections(conns []ConnectionStatus)

SetConnections updates the connection status list.

func (*HeaderPanel) SetTunnelInfo

func (p *HeaderPanel) SetTunnelInfo(info TunnelInfo)

SetTunnelInfo updates the tunnel info.

func (*HeaderPanel) SetWidth

func (p *HeaderPanel) SetWidth(width int)

SetWidth sets the panel width.

func (HeaderPanel) View

func (p HeaderPanel) View() string

View renders the header panel.

type HelpPanel

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

HelpPanel displays the help information at the bottom.

func NewHelpPanel

func NewHelpPanel() HelpPanel

NewHelpPanel creates a new help panel.

func (HelpPanel) Height

func (p HelpPanel) Height() int

Height returns the height of the help panel.

func (*HelpPanel) SetWidth

func (p *HelpPanel) SetWidth(width int)

SetWidth sets the panel width.

func (HelpPanel) View

func (p HelpPanel) View() string

View renders the help panel.

type ProtocolFilter

type ProtocolFilter int

ProtocolFilter defines which protocols to show.

const (
	FilterAll ProtocolFilter = iota
	FilterTCP
	FilterUDP
	FilterICMP
)

type TrafficPanel

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

TrafficPanel displays live packet traffic.

func NewTrafficPanel

func NewTrafficPanel() TrafficPanel

NewTrafficPanel creates a new traffic panel.

func (*TrafficPanel) AddPacket

func (p *TrafficPanel) AddPacket(info connection.PacketInfo)

AddPacket adds a packet to the display.

func (*TrafficPanel) Clear

func (p *TrafficPanel) Clear()

Clear removes all packets.

func (*TrafficPanel) FilterName

func (p *TrafficPanel) FilterName() string

FilterName returns the name of the current filter.

func (*TrafficPanel) HideBFD

func (p *TrafficPanel) HideBFD() bool

HideBFD returns whether BFD packets are currently hidden.

func (*TrafficPanel) IsPaused

func (p *TrafficPanel) IsPaused() bool

IsPaused returns whether traffic observation is paused.

func (*TrafficPanel) ScrollDown

func (p *TrafficPanel) ScrollDown()

ScrollDown scrolls down by one line.

func (*TrafficPanel) ScrollToBottom

func (p *TrafficPanel) ScrollToBottom()

ScrollToBottom scrolls to the bottom.

func (*TrafficPanel) ScrollToTop

func (p *TrafficPanel) ScrollToTop()

ScrollToTop scrolls to the top.

func (*TrafficPanel) ScrollUp

func (p *TrafficPanel) ScrollUp()

ScrollUp scrolls up by one line.

func (*TrafficPanel) SetFilter

func (p *TrafficPanel) SetFilter(f ProtocolFilter)

SetFilter sets the protocol filter.

func (*TrafficPanel) SetPacketRate

func (p *TrafficPanel) SetPacketRate(pps int64)

SetPacketRate sets the current raw packet rate for display.

func (*TrafficPanel) SetPaused

func (p *TrafficPanel) SetPaused(paused bool, auto bool)

SetPaused sets the paused state and whether it was auto-triggered.

func (*TrafficPanel) SetSize

func (p *TrafficPanel) SetSize(width, height int)

SetSize sets the panel dimensions.

func (*TrafficPanel) ToggleBFD

func (p *TrafficPanel) ToggleBFD()

ToggleBFD toggles visibility of BFD control packets.

func (TrafficPanel) View

func (p TrafficPanel) View() string

View renders the traffic panel.

type TunnelInfo

type TunnelInfo struct {
	Name         string
	UID          string
	ServerAddr   string
	HasToken     bool
	Mode         string
	DNSAddr      string
	HealthAddr   string
	DashboardURL string // non-empty when running in cloud mode
}

TunnelInfo contains information about the tunnel.

Jump to

Keyboard shortcuts

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