agentssh

package
v2.6.0 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2023 License: AGPL-3.0 Imports: 36 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// MagicSessionErrorCode indicates that something went wrong with the session, rather than the
	// command just returning a nonzero exit code, and is chosen as an arbitrary, high number
	// unlikely to shadow other exit codes, which are typically 1, 2, 3, etc.
	MagicSessionErrorCode = 229

	// MagicSessionTypeEnvironmentVariable is used to track the purpose behind an SSH connection.
	// This is stripped from any commands being executed, and is counted towards connection stats.
	MagicSessionTypeEnvironmentVariable = "CODER_SSH_SESSION_TYPE"
	// MagicSessionTypeVSCode is set in the SSH config by the VS Code extension to identify itself.
	MagicSessionTypeVSCode = "vscode"
	// MagicSessionTypeJetBrains is set in the SSH config by the JetBrains
	// extension to identify itself.
	MagicSessionTypeJetBrains = "jetbrains"
	// MagicProcessCmdlineJetBrains is a string in a process's command line that
	// uniquely identifies it as JetBrains software.
	MagicProcessCmdlineJetBrains = "idea.vendor.name=JetBrains"
)

Variables

This section is empty.

Functions

func Bicopy

func Bicopy(ctx context.Context, c1, c2 io.ReadWriteCloser)

Bicopy copies all of the data between the two connections and will close them after one or both of them are done writing. If the context is canceled, both of the connections will be closed.

func NewJetbrainsChannelWatcher added in v2.5.0

func NewJetbrainsChannelWatcher(ctx ssh.Context, logger slog.Logger, newChannel gossh.NewChannel, counter *atomic.Int64) gossh.NewChannel

Types

type ChannelOnClose added in v2.5.0

type ChannelOnClose struct {
	gossh.Channel
	// contains filtered or unexported fields
}

func (*ChannelOnClose) Close added in v2.5.0

func (c *ChannelOnClose) Close() error

type ConnStats

type ConnStats struct {
	Sessions  int64
	VSCode    int64
	JetBrains int64
}

type JetbrainsChannelWatcher added in v2.5.0

type JetbrainsChannelWatcher struct {
	gossh.NewChannel
	// contains filtered or unexported fields
}

JetbrainsChannelWatcher is used to track JetBrains port forwarded (Gateway) channels. If the port forward is something other than JetBrains, this struct is a noop.

func (*JetbrainsChannelWatcher) Accept added in v2.5.0

func (w *JetbrainsChannelWatcher) Accept() (gossh.Channel, <-chan *gossh.Request, error)

type Server

type Server struct {
	Env           map[string]string
	AgentToken    func() string
	Manifest      *atomic.Pointer[agentsdk.Manifest]
	ServiceBanner *atomic.Pointer[codersdk.ServiceBannerConfig]
	// contains filtered or unexported fields
}

func NewServer

func NewServer(ctx context.Context, logger slog.Logger, prometheusRegistry *prometheus.Registry, fs afero.Fs, maxTimeout time.Duration, x11SocketDir string) (*Server, error)

func (*Server) Close

func (s *Server) Close() error

Close the server and all active connections. Server can be re-used after Close is done.

func (*Server) ConnStats

func (s *Server) ConnStats() ConnStats

func (*Server) CreateCommand

func (s *Server) CreateCommand(ctx context.Context, script string, env []string) (*pty.Cmd, error)

CreateCommand processes raw command input with OpenSSH-like behavior. If the script provided is empty, it will default to the users shell. This injects environment variables specified by the user at launch too.

func (*Server) Serve

func (s *Server) Serve(l net.Listener) (retErr error)

func (*Server) Shutdown

func (*Server) Shutdown(_ context.Context) error

Shutdown gracefully closes all active SSH connections and stops accepting new connections.

Shutdown is not implemented.

Jump to

Keyboard shortcuts

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