tui

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	CText   = lipgloss.Color("#c0caf5")
	CDim    = lipgloss.Color("#565f89")
	CBorder = lipgloss.Color("#3b4261")

	CCyan   = lipgloss.Color("#7dcfff")
	CGreen  = lipgloss.Color("#9ece6a")
	CYellow = lipgloss.Color("#e0af68")
	CRed    = lipgloss.Color("#f7768e")
	CPurple = lipgloss.Color("#bb9af7")
	CBlue   = lipgloss.Color("#7aa2f7")
	COrange = lipgloss.Color("#ff9e64")
	CTeal   = lipgloss.Color("#73daca")

	// Upload / Download accent
	CUpload   = lipgloss.Color("#ff79c6")
	CDownload = lipgloss.Color("#00ff87")

	// 4-tier threshold
	COk       = lipgloss.Color("#00ff87")
	CWarn     = lipgloss.Color("#ffd700")
	CAlert    = lipgloss.Color("#ffaf5f")
	CCritical = lipgloss.Color("#ff5555")

	CMuted = lipgloss.Color("#6c6c6c")
	CInfo  = lipgloss.Color("#5fafff")

	// Row background alternating
	CRowA = lipgloss.Color("#1A1B26")
	CRowB = lipgloss.Color("#161623")
	CSel  = lipgloss.Color("#2D4F67")
)
View Source
var PanelIcons = map[string]string{
	"System":  "◈",
	"Traffic": "◆",
	"Rules":   "☰",
	"Detail":  "◉",
	"Help":    "?",
}

Functions

func Run

func Run(ctx context.Context, stdout io.Writer, addr string, token ...string) error

func ThresholdColor

func ThresholdColor(pct float64) lipgloss.Color

Types

type Client

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

func NewClient

func NewClient(baseURL string, token ...string) *Client

func (*Client) Health

func (c *Client) Health(ctx context.Context) (*HealthResponse, error)

func (*Client) Reload

func (c *Client) Reload(ctx context.Context) (*ReloadResponse, error)

func (*Client) Rules

func (c *Client) Rules(ctx context.Context) (*RulesResponse, error)

func (*Client) Stats

func (c *Client) Stats(ctx context.Context) (*StatsResponse, error)

type HealthResponse

type HealthResponse struct {
	OK           bool  `json:"ok"`
	RunningRules int   `json:"running_rules"`
	Time         int64 `json:"time"`
}

type Model

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

func (Model) Init

func (m Model) Init() tea.Cmd

func (Model) Update

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

func (Model) View

func (m Model) View() string

type ReloadResponse

type ReloadResponse struct {
	ConfigPath      string `json:"config_path"`
	AdminListenAddr string `json:"admin_listen_addr"`
	RuleCount       int    `json:"rule_count"`
}

type RuleInfo

type RuleInfo struct {
	RuleID     string `json:"rule_id"`
	Name       string `json:"name"`
	Protocol   string `json:"protocol"`
	ListenAddr string `json:"listen_addr"`
	ListenPort int    `json:"listen_port"`
	TargetAddr string `json:"target_addr"`
	TargetPort int    `json:"target_port"`
	Enabled    bool   `json:"enabled"`
	SpeedLimit int64  `json:"speed_limit"`
	MaxConn    int    `json:"max_conn"`
	Remark     string `json:"remark,omitempty"`
}

type RulesResponse

type RulesResponse struct {
	Items []RuleInfo `json:"items"`
}

type StatsResponse

type StatsResponse struct {
	Items []TrafficSnapshot `json:"items"`
}

type TrafficSnapshot

type TrafficSnapshot struct {
	RuleID        string `json:"rule_id"`
	UploadBytes   int64  `json:"upload_bytes"`
	DownloadBytes int64  `json:"download_bytes"`
	Conns         int64  `json:"conns"`
	UpdatedTime   int64  `json:"updated_time"`
}

Jump to

Keyboard shortcuts

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