Documentation
¶
Overview ¶
Package wishlist provides a library and binary to list and connect to SSH apps.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FirstNonEmpty ¶
FirstNonEmpty returns the first non-empty string of the list.
Types ¶
type Config ¶
type Config struct { Title string `yaml:"title"` // Title of the list. Listen string `yaml:"listen"` // Address to listen on. Port int64 `yaml:"port"` // Port to start the first server on. Endpoints []*Endpoint `yaml:"endpoints"` // Endpoints to list. Hints []EndpointHint `yaml:"hints"` // Endpoints hints to apply to discovered hosts. Factory func(Endpoint) (*ssh.Server, error) `yaml:"-"` // Factory used to create the SSH server for the given endpoint. Users []User `yaml:"users"` // Users allowed to access the list. Metrics Metrics `yaml:"metrics"` // Metrics configuration. EndpointChan chan []*Endpoint `yaml:"-"` // Channel to update the endpoints. Used only in server mode. // contains filtered or unexported fields }
Config represents the wishlist configuration.
type Endpoint ¶
type Endpoint struct { Name string `yaml:"name"` // Endpoint name. Address string `yaml:"address"` // Endpoint address in the `host:port` format, if empty, will be the same address as the list, increasing the port number. User string `yaml:"user"` // User to authenticate as. ForwardAgent bool `yaml:"forward_agent"` // ForwardAgent defines whether to forward the current agent. Anologous to SSH's config ForwardAgent. RequestTTY bool `yaml:"request_tty"` // RequestTTY defines whether to request a TTY. Anologous to SSH's config RequestTTY. RemoteCommand string `yaml:"remote_command"` // RemoteCommand defines whether to request a TTY. Anologous to SSH's config RemoteCommand. Desc string `yaml:"description"` // Description describes an optional description of the item. Link Link `yaml:"link"` // Links can be used to add a link to the item description using OSC8. ProxyJump string `yaml:"proxy_jump"` // Analogous to SSH's ProxyJump SendEnv []string `yaml:"send_env"` // Analogous to SSH's SendEnv SetEnv []string `yaml:"set_env"` // Analogous to SSH's SetEnv PreferredAuthentications []string `yaml:"preferred_authentications"` // Analogous to SSH's PreferredAuthentications IdentityFiles []string `yaml:"identity_files"` // IdentityFiles is only used when in local mode. Timeout time.Duration `yaml:"connect_timeout"` // Connection timeout. Middlewares []wish.Middleware `yaml:"-"` // wish middlewares you can use in the factory method. IsMainServer bool `yaml:"is_main_server"` // IsMainServer defines whether this endpoint is the main server. DisplayUrl bool `yaml:"display_url"` // DisplayUrl defines whether to display the URL in the description. }
Endpoint represents an endpoint to list. If it has a Handler, wishlist will start an SSH server on the given address.
func (Endpoint) Authentications ¶
Authentications returns either the client preferred authentications or the default publickey,keyboard-interactive.
func (Endpoint) Environment ¶
Environment evaluates SendEnv and SetEnv into the env map that should be set into the session. Optionally you can pass a list existing environment variables (e.g. os.Environ()), and the ones allowed by SendEnv will be set as well. As on OpenSSH, envs set via SetEnv take precedence over the ones from hostenv.
func (Endpoint) ShouldListen ¶
ShouldListen returns true if we should start a server for this endpoint.
type EndpointHint ¶
type EndpointHint struct { Match string `yaml:"match"` Port string `yaml:"port"` User string `yaml:"user"` ForwardAgent *bool `yaml:"forward_agent"` RequestTTY *bool `yaml:"request_tty"` RemoteCommand string `yaml:"remote_command"` Desc string `yaml:"description"` Link Link `yaml:"link"` ProxyJump string `yaml:"proxy_jump"` SendEnv []string `yaml:"send_env"` SetEnv []string `yaml:"set_env"` PreferredAuthentications []string `yaml:"preferred_authentications"` IdentityFiles []string `yaml:"identity_files"` Timeout time.Duration `yaml:"connect_timeout"` }
EndpointHint can be used to match a discovered endpoint (through zeroconf for example) and set additional options into it.
type ItemWrapper ¶
type ItemWrapper struct {
// contains filtered or unexported fields
}
ItemWrapper wrappes an Endpoint and a set of descriptors and acts as a list.Item.
func (ItemWrapper) Description ¶
func (i ItemWrapper) Description() string
Description to abide the list.Item interface.
func (ItemWrapper) FilterValue ¶
func (i ItemWrapper) FilterValue() string
FilterValue to abide the list.Item interface.
func (ItemWrapper) Title ¶
func (i ItemWrapper) Title() string
Title to abide the list.Item interface.
type ListModel ¶
type ListModel struct {
// contains filtered or unexported fields
}
ListModel main wishlist model.
func NewListing ¶
func NewListing(title string, endpoints []*Endpoint, client SSHClient, r *lipgloss.Renderer) *ListModel
NewListing creates a new listing model for the given endpoints and SSH session. If session is nil, it is assume to be a local listing.
type Metrics ¶
type Metrics struct { Enabled bool `yaml:"enabled"` Name string `yaml:"name"` Address string `yaml:"address"` }
Metrics configuration.
type SSHClient ¶
type SSHClient interface {
For(e *Endpoint) tea.ExecCommand
}
SSHClient is a SSH client.
func NewLocalSSHClient ¶
func NewLocalSSHClient() SSHClient
NewLocalSSHClient returns a SSH Client for local usage.
type SetEndpointsMsg ¶
type SetEndpointsMsg struct {
Endpoints []*Endpoint
}
SetEndpointsMsg can be used to update the listed wishlist endpoints.