cli

package
v0.0.0-...-fe4cb11 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxLogLines          = 1000
	MinLogHeight         = 5
	MaxLogHeight         = 30
	DefaultLogHeight     = 12
	MinTunnelsHeight     = 8
	MaxTunnelsHeight     = 20
	DefaultTunnelsHeight = 10 // ← 添加这个常量
	DefaultTotalHeight   = 40
	MinTotalHeight       = 24
	MaxTotalHeight       = 200
)
View Source
const (
	BannerFixedHeight        = 5 // 4行横幅 + 1空行
	StatusFixedHeight        = 8 // 状态面板实际高度
	DividerFixedHeight       = 2 // 分隔线 + 换行
	HelpFixedHeight          = 1 // 帮助栏
	SectionHeaderFixedHeight = 2 // 每个区域标题(标题 + 换行)
)

固定元素高度常量

Variables

This section is empty.

Functions

func AddLog

func AddLog(format string, args ...interface{})

func SetGlobalProgram

func SetGlobalProgram(p *tea.Program)

func UpdateConnState

func UpdateConnState(isClose bool)

func UpdateConnections

func UpdateConnections(addr string, port int, localAddr string, protocol string, isClose bool)

func UpdateLatency

func UpdateLatency(ms int64)

func UpdateRemoteAddress

func UpdateRemoteAddress(addr string)

func UpdateStatus

func UpdateStatus(status string)

Types

type AddressUpdateMsg

type AddressUpdateMsg struct {
	Address string
}

type ConnStateUpdateMsg

type ConnStateUpdateMsg struct {
	IsClose bool
}

type ConnUpdateMsg

type ConnUpdateMsg struct {
	Address   string
	Port      int
	LocalAddr string
	Protocol  string
	IsClose   bool
}

type FocusChangeMsg

type FocusChangeMsg struct {
	View string
}

type FormattedCLIWriteSyncer

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

FormattedCLIWriteSyncer writes level-tagged, styled log lines to the TUI.

func NewFormattedCLIWriteSyncer

func NewFormattedCLIWriteSyncer(level zapcore.Level, prefix string) *FormattedCLIWriteSyncer

func (*FormattedCLIWriteSyncer) Sync

func (w *FormattedCLIWriteSyncer) Sync() error

func (*FormattedCLIWriteSyncer) Write

func (w *FormattedCLIWriteSyncer) Write(p []byte) (n int, err error)

type LatencyUpdateMsg

type LatencyUpdateMsg struct {
	Latency int64
}

type LogMsg

type LogMsg string

type LogsView

type LogsView struct {
	Logs     []string
	Viewport viewport.Model
	Width    int
	Height   int
	Ready    bool
	MaxLines int
	// contains filtered or unexported fields
}

func NewLogsView

func NewLogsView() *LogsView

func (*LogsView) GetHeight

func (v *LogsView) GetHeight() int

func (*LogsView) GetMaxHeight

func (v *LogsView) GetMaxHeight() int

func (*LogsView) GetMinHeight

func (v *LogsView) GetMinHeight() int

func (*LogsView) GetTitle

func (v *LogsView) GetTitle() string

func (*LogsView) HandleKeyMsg

func (v *LogsView) HandleKeyMsg(msg tea.KeyMsg) bool

func (*LogsView) Init

func (v *LogsView) Init() tea.Cmd

func (*LogsView) SetHeight

func (v *LogsView) SetHeight(height int)

func (*LogsView) Update

func (v *LogsView) Update(msg tea.Msg) (View, tea.Cmd)

func (*LogsView) View

func (v *LogsView) View(width int) string

type ResizeMsg

type ResizeMsg struct {
	View      string
	Direction string
}

type SetTotalHeightMsg

type SetTotalHeightMsg struct {
	Height int
}

type StatusUpdateMsg

type StatusUpdateMsg struct {
	Status string
}

type SyncMap

type SyncMap[K comparable, V any] struct {
	// contains filtered or unexported fields
}

SyncMap is a simple thread-safe map

func NewSyncMap

func NewSyncMap[K comparable, V any]() *SyncMap[K, V]

func (*SyncMap[K, V]) Clear

func (m *SyncMap[K, V]) Clear()

func (*SyncMap[K, V]) Len

func (m *SyncMap[K, V]) Len() int

func (*SyncMap[K, V]) Load

func (m *SyncMap[K, V]) Load(key K) (V, bool)

func (*SyncMap[K, V]) Range

func (m *SyncMap[K, V]) Range(f func(key K, value V) bool)

func (*SyncMap[K, V]) Store

func (m *SyncMap[K, V]) Store(key K, value V)

func (*SyncMap[K, V]) Values

func (m *SyncMap[K, V]) Values() []V

type TUIModel

type TUIModel struct {
	// State data
	RemoteAddress string
	Status        string
	Latency       int64

	// Views
	TunnelsView *TunnelsView
	LogsView    *LogsView
	ActiveView  string

	// Layout related
	Width         int
	Height        int
	ContentHeight int

	// Fixed heights
	BannerHeight        int
	StatusHeight        int
	DividerHeight       int
	HelpHeight          int
	SectionHeaderHeight int
	MainView            tea.View
	// contains filtered or unexported fields
}

func NewTUIModel

func NewTUIModel(remoteAddress string) *TUIModel

NewTUIModel creates a new TUI model with default height

func (*TUIModel) Init

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

Init initializes the model

func (*TUIModel) SetTotalHeight

func (m *TUIModel) SetTotalHeight(height int)

SetTotalHeight sets the total height of the interface

func (*TUIModel) Update

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

func (*TUIModel) View

func (m *TUIModel) View() tea.View

View returns the rendered string

type TunnelCon

type TunnelCon struct {
	Addr      string
	Port      string
	LocalAddr string
	Protocol  string
	State     string
}

TunnelCon represents tunnel connection information

type TunnelsView

type TunnelsView struct {
	ConnectionTable table.Model
	Connections     *SyncMap[string, *TunnelCon]
	Width           int
	Height          int
	// contains filtered or unexported fields
}

func NewTunnelsView

func NewTunnelsView() *TunnelsView

func (*TunnelsView) GetHeight

func (v *TunnelsView) GetHeight() int

func (*TunnelsView) GetMaxHeight

func (v *TunnelsView) GetMaxHeight() int

func (*TunnelsView) GetMinHeight

func (v *TunnelsView) GetMinHeight() int

func (*TunnelsView) GetTitle

func (v *TunnelsView) GetTitle() string

func (*TunnelsView) HandleKeyMsg

func (v *TunnelsView) HandleKeyMsg(msg tea.KeyMsg) bool

func (*TunnelsView) Init

func (v *TunnelsView) Init() tea.Cmd

func (*TunnelsView) SetHeight

func (v *TunnelsView) SetHeight(height int)

func (*TunnelsView) Update

func (v *TunnelsView) Update(msg tea.Msg) (View, tea.Cmd)

func (*TunnelsView) View

func (v *TunnelsView) View(width int) string

type View

type View interface {
	Init() tea.Cmd
	Update(msg tea.Msg) (View, tea.Cmd)
	View(width int) string
	GetHeight() int
	SetHeight(height int)
	GetMinHeight() int
	GetMaxHeight() int
	GetTitle() string
	HandleKeyMsg(msg tea.KeyMsg) bool
}

type WriteSyncer

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

WriteSyncer implements zapcore.WriteSyncer and routes output to the TUI log panel.

func NewCLIWriteSyncer

func NewCLIWriteSyncer(level string) *WriteSyncer

NewCLIWriteSyncer creates a new CLI write syncer.

func (*WriteSyncer) Sync

func (w *WriteSyncer) Sync() error

func (*WriteSyncer) Write

func (w *WriteSyncer) Write(p []byte) (n int, err error)

Jump to

Keyboard shortcuts

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