Documentation
¶
Index ¶
- Constants
- Variables
- func DisconnectClient(opts *remote.SSHOpts) error
- func EnsureConnection(ctx context.Context, connName string) error
- func GetAllConnStatus() []wshrpc.ConnStatus
- func GetConnectionsFromConfig() ([]string, error)
- func GetConnectionsFromInternalConfig() []string
- func GetConnectionsList() ([]string, error)
- func GetNumSSHHasConnected() int
- func IsConnected(connName string) (bool, error)
- func IsLocalConnName(connName string) bool
- func IsWshVersionUpToDate(logCtx context.Context, wshVersionLine string) (bool, string, string, error)
- func IsWslConnName(connName string) bool
- func WithLockRtn[T any](conn *SSHConn, fn func() T) T
- type ConnMonitor
- type SSHConn
- func (conn *SSHConn) ClearWshError()
- func (conn *SSHConn) Close() error
- func (conn *SSHConn) Connect(ctx context.Context, connFlags *wconfig.ConnKeywords) error
- func (conn *SSHConn) Debugf(ctx context.Context, format string, args ...any)
- func (conn *SSHConn) DeriveConnStatus() wshrpc.ConnStatus
- func (conn *SSHConn) FireConnChangeEvent()
- func (conn *SSHConn) GetClient() *ssh.Client
- func (conn *SSHConn) GetConfigShellPath() string
- func (conn *SSHConn) GetConnHealthStatus() string
- func (conn *SSHConn) GetDomainSocketName() string
- func (conn *SSHConn) GetEnvironmentMaps(ctx context.Context) (map[string]string, map[string]string, error)
- func (conn *SSHConn) GetMonitor() *ConnMonitor
- func (conn *SSHConn) GetName() string
- func (conn *SSHConn) GetStatus() string
- func (conn *SSHConn) Infof(ctx context.Context, format string, args ...any)
- func (conn *SSHConn) InstallWsh(ctx context.Context, osArchStr string) error
- func (conn *SSHConn) OpenDomainSocketListener(ctx context.Context) error
- func (conn *SSHConn) SetConnHealthStatus(client *ssh.Client, status string)
- func (conn *SSHConn) SetWshError(err error)
- func (conn *SSHConn) StartConnServer(ctx context.Context, afterUpdate bool, useRouterMode bool) (bool, string, string, error)
- func (conn *SSHConn) UpdateWsh(ctx context.Context, clientDisplayName string, remoteInfo *wshrpc.RemoteInfo) error
- func (conn *SSHConn) WaitForConnect(ctx context.Context) error
- func (conn *SSHConn) WithLock(fn func())
- type WshCheckResult
- type WshInstallOpts
Constants ¶
const ( Status_Init = "init" Status_Connecting = "connecting" Status_Connected = "connected" Status_Disconnected = "disconnected" Status_Error = "error" )
const ( NoWshCode_Disabled = "disabled" NoWshCode_PermissionError = "permission-error" NoWshCode_UserDeclined = "user-declined" NoWshCode_DomainSocketError = "domainsocket-error" NoWshCode_ConnServerStartError = "connserver-start-error" NoWshCode_InstallError = "install-error" NoWshCode_PostInstallStartError = "postinstall-start-error" NoWshCode_InstallVerifyError = "install-verify-error" )
const ( ConnHealthStatus_Good = "good" ConnHealthStatus_Degraded = "degraded" ConnHealthStatus_Stalled = "stalled" )
const DefaultConnectionTimeout = 60 * time.Second
Variables ¶
Functions ¶
func DisconnectClient ¶
func EnsureConnection ¶
Convenience function for ensuring a connection is established
func GetAllConnStatus ¶
func GetAllConnStatus() []wshrpc.ConnStatus
func GetConnectionsFromInternalConfig ¶ added in v0.10.0
func GetConnectionsFromInternalConfig() []string
func GetConnectionsList ¶
func GetNumSSHHasConnected ¶ added in v0.9.3
func GetNumSSHHasConnected() int
func IsConnected ¶ added in v0.14.0
func IsLocalConnName ¶ added in v0.13.1
func IsWshVersionUpToDate ¶ added in v0.11.0
func IsWshVersionUpToDate(logCtx context.Context, wshVersionLine string) (bool, string, string, error)
expects the output of `wsh version` which looks like `wsh v0.10.4` or "not-installed os [arch]" returns (up-to-date, semver, osArchStr, error) if not up to date, or error, version might be ""
func IsWslConnName ¶ added in v0.14.0
func WithLockRtn ¶ added in v0.11.0
Types ¶
type ConnMonitor ¶ added in v0.14.0
type ConnMonitor struct {
Conn *SSHConn // always non-nil, set at creation
Client *ssh.Client // always non-nil, set at creation
LastActivityTime atomic.Int64
LastInputTime atomic.Int64
KeepAliveSentTime atomic.Int64
KeepAliveInFlight bool
// contains filtered or unexported fields
}
Lock ordering: conn.lock > cm.lock (conn.lock is outer, cm.lock is inner) CRITICAL: Methods that hold cm.lock must NEVER call into SSHConn (deadlock - violates ordering). Methods called from SSHConn while conn.lock is held should avoid acquiring cm.lock (keep locking simple).
func MakeConnMonitor ¶ added in v0.14.0
func MakeConnMonitor(conn *SSHConn, client *ssh.Client) *ConnMonitor
func (*ConnMonitor) Close ¶ added in v0.14.0
func (cm *ConnMonitor) Close()
func (*ConnMonitor) NotifyInput ¶ added in v0.14.0
func (cm *ConnMonitor) NotifyInput()
func (*ConnMonitor) SendKeepAlive ¶ added in v0.14.0
func (cm *ConnMonitor) SendKeepAlive() error
func (*ConnMonitor) UpdateLastActivityTime ¶ added in v0.14.0
func (cm *ConnMonitor) UpdateLastActivityTime()
type SSHConn ¶
type SSHConn struct {
Status string
ConnHealthStatus string
WshEnabled *atomic.Bool
Opts *remote.SSHOpts
Client *ssh.Client
DomainSockName string // if "", then no domain socket
DomainSockListener net.Listener
ConnController *ssh.Session
Error string
WshError string
NoWshReason string
WshVersion string
LastConnectTime int64
ActiveConnNum int
Monitor *ConnMonitor // will not be nil
// contains filtered or unexported fields
}
func MaybeGetConn ¶ added in v0.14.0
does NOT connect, can return nil
func (*SSHConn) ClearWshError ¶ added in v0.11.0
func (conn *SSHConn) ClearWshError()
func (*SSHConn) DeriveConnStatus ¶
func (conn *SSHConn) DeriveConnStatus() wshrpc.ConnStatus
func (*SSHConn) FireConnChangeEvent ¶
func (conn *SSHConn) FireConnChangeEvent()
func (*SSHConn) GetConfigShellPath ¶ added in v0.11.0
func (*SSHConn) GetConnHealthStatus ¶ added in v0.14.0
func (*SSHConn) GetDomainSocketName ¶
func (*SSHConn) GetEnvironmentMaps ¶ added in v0.14.0
func (conn *SSHConn) GetEnvironmentMaps(ctx context.Context) (map[string]string, map[string]string, error)
for testing only -- trying to determine the env difference when attaching or not attaching a pty to an ssh session
func (*SSHConn) GetMonitor ¶ added in v0.14.0
func (conn *SSHConn) GetMonitor() *ConnMonitor
func (*SSHConn) InstallWsh ¶ added in v0.11.0
func (*SSHConn) OpenDomainSocketListener ¶
func (*SSHConn) SetConnHealthStatus ¶ added in v0.14.0
func (*SSHConn) SetWshError ¶ added in v0.11.0
func (*SSHConn) StartConnServer ¶
func (conn *SSHConn) StartConnServer(ctx context.Context, afterUpdate bool, useRouterMode bool) (bool, string, string, error)
returns (needsInstall, clientVersion, osArchStr, error) if wsh is not installed, the clientVersion will be "not-installed", and it will also return an osArchStr if clientVersion is set, then no osArchStr will be returned if useRouterMode is true, will start connserver with --router-domainsocket flag