actions

package
v1.4.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	// Tunnel actions
	TunnelAdd    = "tunnel.add"
	TunnelRemove = "tunnel.remove"
	TunnelStart  = "tunnel.start"
	TunnelStop   = "tunnel.stop"
	TunnelShare  = "tunnel.share"
	TunnelStatus = "tunnel.status"
	TunnelLogs   = "tunnel.logs"
	TunnelEdit   = "tunnel.edit"

	// Router actions
	RouterStatus = "router.status"
	RouterMode   = "router.mode"
	RouterSwitch = "router.switch"

	// System actions
	SystemInstall   = "system.install"
	SystemUninstall = "system.uninstall"
	SystemUpdate    = "system.update"
	SystemRestart   = "system.restart"
	SystemUsers     = "system.users"
	SystemStats     = "system.stats"
	QuickWizard     = "system.wizard"

	// WARP actions
	WarpToggle = "warp.toggle"

	// Config actions
	ConfigExport = "config.export"
	ConfigImport = "config.import"
)

Action ID constants — single source of truth for all action identifiers.

Variables

View Source
var BackendOptions = []SelectOption{
	{Value: "socks", Label: "SOCKS — SOCKS5 proxy"},
	{Value: "ssh", Label: "SSH — SSH tunnel"},
	{Value: "both", Label: "Both — SOCKS5 + SSH tunnel"},
}
View Source
var ClientModeOptions = []SelectOption{
	{Value: "dnstt", Label: "DNSTT — Classic DNS tunnel client"},
	{Value: "noizdns", Label: "NoizDNS — DNS tunnel with DPI evasion"},
}

ClientModeOptions is used during `tunnel share` to pick the slipnet:// URL type.

View Source
var RouterModeOptions = []SelectOption{
	{Value: "single", Label: "Single — one active tunnel at a time"},
	{Value: "multi", Label: "Multi — domain-based routing to multiple tunnels"},
}
View Source
var TransportOptions = []SelectOption{
	{Value: "dnstt", Label: "DNSTT / NoizDNS — DNS tunnel"},
	{Value: "slipstream", Label: "Slipstream — QUIC DNS tunnel"},
	{Value: "vaydns", Label: "VayDNS — KCP DNS tunnel"},
	{Value: "naive", Label: "NaiveProxy — HTTPS proxy with Caddy"},
	{Value: "direct-ssh", Label: "SSH — Direct SSH tunnel"},
	{Value: "direct-socks5", Label: "SOCKS5 — Direct SOCKS5 proxy"},
}

Functions

func ClearScreen

func ClearScreen()

ClearScreen sends the ANSI escape to clear the terminal.

func Register

func Register(a *Action)

Register adds an action to the global registry.

Types

type Action

type Action struct {
	ID          string
	Name        string
	Description string
	Category    string
	Inputs      []InputField
	Handler     Handler
	Hidden      bool // hide from TUI menu
}

Action defines a single operation that works in both CLI and TUI modes.

func All

func All() []*Action

All returns all registered actions in registration order.

func ByCategory

func ByCategory(category string) []*Action

ByCategory returns actions grouped by category.

func Get

func Get(id string) (*Action, bool)

Get returns an action by ID.

type ActionError

type ActionError struct {
	Action  string
	Message string
	Hint    string
	Err     error
}

ActionError is an error with a user-facing hint.

func NewError

func NewError(action, message string, err error) *ActionError

NewError creates an ActionError.

func NewErrorWithHint

func NewErrorWithHint(action, message, hint string, err error) *ActionError

NewErrorWithHint creates an ActionError with a user-facing hint.

func (*ActionError) Error

func (e *ActionError) Error() string

func (*ActionError) Unwrap

func (e *ActionError) Unwrap() error

type Context

type Context struct {
	Args   map[string]string
	Output OutputWriter
	Config interface{} // *config.Config, set by caller to avoid import cycle
}

Context carries everything an action handler needs.

func (*Context) GetArg

func (c *Context) GetArg(key string) string

GetArg returns a context argument or empty string.

type Handler

type Handler func(ctx *Context) error

Handler executes an action with the given context.

type InputField

type InputField struct {
	Key             string
	Label           string
	Required        bool
	Default         string
	Options         []SelectOption // if non-empty, present as select
	Validate        func(string) error
	DependsOn       string   // only show if this key has a value
	DependsOnValues []string // if set, only show when DependsOn value is one of these
	Description     string
}

InputField describes a single input parameter for an action.

type OutputWriter

type OutputWriter interface {
	Info(msg string)
	Success(msg string)
	Warning(msg string)
	Error(msg string)
	Print(msg string)
}

OutputWriter abstracts output so actions work in both CLI and TUI.

type SelectOption

type SelectOption struct {
	Value string
	Label string
}

SelectOption is a choice in a select input.

type StdOutput

type StdOutput struct{}

StdOutput writes to stdout/stderr with ANSI colors.

func (*StdOutput) Error

func (s *StdOutput) Error(msg string)

func (*StdOutput) Info

func (s *StdOutput) Info(msg string)

func (*StdOutput) Print

func (s *StdOutput) Print(msg string)

func (*StdOutput) Success

func (s *StdOutput) Success(msg string)

func (*StdOutput) Warning

func (s *StdOutput) Warning(msg string)

Jump to

Keyboard shortcuts

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