ui

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2025 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AppName = "lazyssh"
	RepoURL = "github.com/adembc/lazyssh"

)
View Source
const (
	ForwardTypeLocal   = "Local"
	ForwardTypeRemote  = "Remote"
	ForwardTypeDynamic = "Dynamic"

	ForwardModeOnlyForward = "Only forward"
	ForwardModeForwardSSH  = "Forward + SSH"
)

============================================================================= Event Handlers (handle user input/events) =============================================================================

Variables

View Source
var IsForwarding func(alias string) bool

IsForwarding is an optional hook supplied by TUI to indicate active forwarding per alias.

View Source
var SSHFieldDefaults = map[string]string{

	"Port": "22",
	"User": "",

	"ConnectTimeout":     "",
	"ConnectionAttempts": "1",
	"IPQoS":              "af21 cs1",
	"BatchMode":          "no",
	"Compression":        "no",
	"AddressFamily":      "any",
	"RequestTTY":         "auto",
	"SessionType":        "default",

	"ProxyJump":     "",
	"ProxyCommand":  "",
	"RemoteCommand": "",

	"LocalForward":         "",
	"RemoteForward":        "",
	"DynamicForward":       "",
	"ForwardAgent":         "no",
	"ForwardX11":           "no",
	"ForwardX11Trusted":    "no",
	"ClearAllForwardings":  "no",
	"ExitOnForwardFailure": "no",
	"GatewayPorts":         "no",

	"PubkeyAuthentication":         "yes",
	"PasswordAuthentication":       "yes",
	"PreferredAuthentications":     "gssapi-with-mic,hostbased,publickey,keyboard-interactive,password",
	"IdentitiesOnly":               "no",
	"AddKeysToAgent":               "no",
	"IdentityAgent":                "SSH_AUTH_SOCK",
	"KbdInteractiveAuthentication": "yes",
	"NumberOfPasswordPrompts":      "3",
	"PubkeyAcceptedAlgorithms":     "",
	"HostbasedAcceptedAlgorithms":  "",

	"ControlMaster":  "no",
	"ControlPath":    "",
	"ControlPersist": "no",

	"ServerAliveInterval": "0",
	"ServerAliveCountMax": "3",
	"TCPKeepAlive":        "yes",

	"StrictHostKeyChecking": "ask",
	"UserKnownHostsFile":    "~/.ssh/known_hosts",
	"HostKeyAlgorithms":     "",
	"Ciphers":               "",
	"MACs":                  "",
	"CheckHostIP":           "no",
	"FingerprintHash":       "SHA256",
	"VerifyHostKeyDNS":      "no",
	"UpdateHostKeys":        "no",
	"HashKnownHosts":        "no",
	"VisualHostKey":         "no",

	"KexAlgorithms": "",

	"CanonicalizeHostname":        "no",
	"CanonicalDomains":            "",
	"CanonicalizeFallbackLocal":   "yes",
	"CanonicalizeMaxDots":         "1",
	"CanonicalizePermittedCNAMEs": "",

	"LocalCommand":       "",
	"PermitLocalCommand": "no",
	"EscapeChar":         "~",

	"SendEnv": "",
	"SetEnv":  "",

	"LogLevel": "INFO",

	"BindAddress":   "",
	"BindInterface": "",
}

SSHFieldDefaults contains the default values for all SSH configuration fields This centralizes all default values to ensure consistency across the application

Functions

func BuildSSHCommand

func BuildSSHCommand(s domain.Server) string

BuildSSHCommand constructs a ready-to-run ssh command for the given server. Format: ssh [options] [user@]host [command]

func DefaultStatusText

func DefaultStatusText() string

func GetAllCategories added in v0.3.0

func GetAllCategories() []string

GetAllCategories returns all available help categories

func GetAvailableKnownHostsFiles added in v0.3.0

func GetAvailableKnownHostsFiles() []string

GetAvailableKnownHostsFiles returns a list of available known_hosts files in common locations. It safely handles file permission issues and only returns readable files.

func GetAvailableSSHKeys added in v0.3.0

func GetAvailableSSHKeys() []string

GetAvailableSSHKeys returns a list of available SSH private key files in the user's .ssh directory. It safely handles file permission issues and only returns readable key files.

func GetFieldPlaceholder added in v0.3.0

func GetFieldPlaceholder(fieldName string) string

GetFieldPlaceholder returns an appropriate placeholder for a form field It returns either the default value, an example, or an empty string

func GetFieldValidators added in v0.3.0

func GetFieldValidators() map[string]fieldValidator

GetFieldValidators returns validation rules for SSH configuration fields

func GetFieldsByCategory added in v0.3.0

func GetFieldsByCategory(category string) []string

GetFieldsByCategory returns all fields in a specific category

func GetNetworkInterfaces added in v0.3.0

func GetNetworkInterfaces() []string

GetNetworkInterfaces returns a list of available network interface names

func GetSSHFieldDefault added in v0.3.0

func GetSSHFieldDefault(fieldName string) string

GetSSHFieldDefault returns the default value for a given SSH field Returns empty string if no default is defined

func GetSSHFieldDefaultWithFallback added in v0.3.0

func GetSSHFieldDefaultWithFallback(fieldName, fallback string) string

GetSSHFieldDefaultWithFallback returns the default value for a given SSH field with a fallback value if no default is defined

func NewStatusBar

func NewStatusBar() *tview.TextView

Types

type App added in v0.2.1

type App interface {
	Run() error
}

func NewTUI

func NewTUI(logger *zap.SugaredLogger, ss ports.ServerService, version, commit string) App

type AppHeader

type AppHeader struct {
	*tview.Flex
	// contains filtered or unexported fields
}

func NewAppHeader

func NewAppHeader(version, gitCommit, repoURL string) *AppHeader

type FieldHelp added in v0.3.0

type FieldHelp struct {
	Field       string   // Field name
	Description string   // Brief description
	Syntax      string   // Syntax format
	Examples    []string // Usage examples
	Default     string   // Default value
	Since       string   // OpenSSH version when introduced
	Category    string   // Category for grouping
}

FieldHelp contains help information for SSH config fields

func GetFieldHelp added in v0.3.0

func GetFieldHelp(fieldName string) *FieldHelp

GetFieldHelp returns help information for a specific field

type HelpDisplayMode added in v0.3.0

type HelpDisplayMode int

HelpDisplayMode defines how help is displayed

const (
	HelpModeOff     HelpDisplayMode = iota // No help shown
	HelpModeCompact                        // Single line help
	HelpModeNormal                         // Standard help panel
	HelpModeFull                           // Detailed help with all info
)
type SearchBar struct {
	*tview.InputField
	// contains filtered or unexported fields
}

func NewSearchBar

func NewSearchBar() *SearchBar

func (*SearchBar) OnEscape

func (s *SearchBar) OnEscape(fn func()) *SearchBar

func (*SearchBar) OnSearch

func (s *SearchBar) OnSearch(fn func(string)) *SearchBar

type ServerDetails

type ServerDetails struct {
	*tview.TextView
}

func NewServerDetails

func NewServerDetails() *ServerDetails

func (*ServerDetails) ShowEmpty

func (sd *ServerDetails) ShowEmpty()

func (*ServerDetails) UpdateServer

func (sd *ServerDetails) UpdateServer(server domain.Server)

type ServerForm

type ServerForm struct {
	*tview.Flex // The root container (includes header, form panel and hint bar)
	// contains filtered or unexported fields
}

func NewServerForm

func NewServerForm(mode ServerFormMode, original *domain.Server) *ServerForm

func (*ServerForm) OnCancel

func (sf *ServerForm) OnCancel(fn func()) *ServerForm

func (*ServerForm) OnSave

func (sf *ServerForm) OnSave(fn func(domain.Server, *domain.Server)) *ServerForm

func (*ServerForm) SetApp added in v0.3.0

func (sf *ServerForm) SetApp(app *tview.Application) *ServerForm

func (*ServerForm) SetVersionInfo added in v0.3.0

func (sf *ServerForm) SetVersionInfo(version, commit string) *ServerForm

type ServerFormData

type ServerFormData struct {
	Alias string
	Host  string
	User  string
	Port  string
	Key   string
	Tags  string

	// Connection and proxy settings
	ProxyJump            string
	ProxyCommand         string
	RemoteCommand        string
	RequestTTY           string
	SessionType          string
	ConnectTimeout       string
	ConnectionAttempts   string
	BindAddress          string
	BindInterface        string
	AddressFamily        string
	ExitOnForwardFailure string
	IPQoS                string
	// Hostname canonicalization
	CanonicalizeHostname        string
	CanonicalDomains            string
	CanonicalizeFallbackLocal   string
	CanonicalizeMaxDots         string
	CanonicalizePermittedCNAMEs string

	// Port forwarding
	LocalForward        string
	RemoteForward       string
	DynamicForward      string
	ClearAllForwardings string
	GatewayPorts        string

	// Authentication and key management
	// Public key
	PubkeyAuthentication string
	IdentitiesOnly       string
	// SSH Agent
	AddKeysToAgent string
	IdentityAgent  string
	// Password & Interactive
	PasswordAuthentication       string
	KbdInteractiveAuthentication string
	NumberOfPasswordPrompts      string
	// Advanced
	PreferredAuthentications string

	// Agent and X11 forwarding
	ForwardAgent      string
	ForwardX11        string
	ForwardX11Trusted string

	// Connection multiplexing
	ControlMaster  string
	ControlPath    string
	ControlPersist string

	// Connection reliability
	ServerAliveInterval string
	ServerAliveCountMax string
	Compression         string
	TCPKeepAlive        string
	BatchMode           string

	// Security settings
	StrictHostKeyChecking       string
	CheckHostIP                 string
	FingerprintHash             string
	UserKnownHostsFile          string
	HostKeyAlgorithms           string
	PubkeyAcceptedAlgorithms    string
	HostbasedAcceptedAlgorithms string
	MACs                        string
	Ciphers                     string
	KexAlgorithms               string
	VerifyHostKeyDNS            string
	UpdateHostKeys              string
	HashKnownHosts              string
	VisualHostKey               string

	// Command execution
	LocalCommand       string
	PermitLocalCommand string
	EscapeChar         string

	// Environment settings
	SendEnv string
	SetEnv  string

	// Debugging settings
	LogLevel string
}

type ServerFormMode

type ServerFormMode int
const (
	ServerFormAdd ServerFormMode = iota
	ServerFormEdit
)

type ServerList

type ServerList struct {
	*tview.List
	// contains filtered or unexported fields
}

func NewServerList

func NewServerList() *ServerList

func (*ServerList) GetSelectedServer

func (sl *ServerList) GetSelectedServer() (domain.Server, bool)

func (*ServerList) OnSelection

func (sl *ServerList) OnSelection(fn func(server domain.Server)) *ServerList

func (*ServerList) OnSelectionChange

func (sl *ServerList) OnSelectionChange(fn func(server domain.Server)) *ServerList

func (*ServerList) UpdateServers

func (sl *ServerList) UpdateServers(servers []domain.Server)

type SortMode

type SortMode int

SortMode controls how unpinned servers are ordered in the UI.

const (
	SortByAliasAsc SortMode = iota
	SortByAliasDesc
	SortByLastSeenDesc
	SortByLastSeenAsc
)

func (SortMode) Reverse

func (m SortMode) Reverse() SortMode

Reverse flips the direction within the current field.

func (SortMode) String

func (m SortMode) String() string

func (SortMode) ToggleField

func (m SortMode) ToggleField() SortMode

ToggleField switches between Alias and LastSeen while preserving direction.

type ValidationState added in v0.3.0

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

ValidationState tracks validation errors for each field

func NewValidationState added in v0.3.0

func NewValidationState() *ValidationState

NewValidationState creates a new validation state

func (*ValidationState) Clear added in v0.3.0

func (v *ValidationState) Clear()

Clear removes all validation errors

func (*ValidationState) GetAllErrors added in v0.3.0

func (v *ValidationState) GetAllErrors() []string

GetAllErrors returns all validation errors in field order

func (*ValidationState) GetError added in v0.3.0

func (v *ValidationState) GetError(field string) string

GetError gets the error for a specific field

func (*ValidationState) GetErrorCount added in v0.3.0

func (v *ValidationState) GetErrorCount() int

GetErrorCount returns the number of validation errors

func (*ValidationState) HasErrors added in v0.3.0

func (v *ValidationState) HasErrors() bool

HasErrors checks if there are any validation errors

func (*ValidationState) SetError added in v0.3.0

func (v *ValidationState) SetError(field, errMsg string)

SetError sets or clears an error for a field

Jump to

Keyboard shortcuts

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