sshserver

package
v0.0.0-...-fab76b5 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2025 License: AGPL-3.0 Imports: 21 Imported by: 0

Documentation

Overview

Package sshserver provides an SSH server allowing users to connect units via a central host.

This server does a few things, requests that come in must go through the jump server. The jump server will pipe the connection and pass it into an in-memory instance of another SSH server.

This second SSH server (seen within directTCPIPHandlerClosure) will handle the the termination of the SSH connections, note, it is not listening on any ports because we are passing the piped connection to it, essentially allowing the following to work (despite only having one server listening): - `ssh -J controller:2223 ubuntu@app.controller.model`

Package sshserver is a generated GoMock package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Manifold

func Manifold(config ManifoldConfig) dependency.Manifold

Manifold returns a dependency.Manifold that will run an embedded SSH server worker. The manifold has no outputs.

func NewServerWorker

func NewServerWorker(config ServerWorkerConfig) (worker.Worker, error)

NewServerWorker returns a running embedded SSH server.

func NewServerWrapperWorker

func NewServerWrapperWorker(config ServerWrapperWorkerConfig) (worker.Worker, error)

NewServerWrapperWorker returns a new worker that runs an ssh server worker internally. This worker will listen for changes in the controller configuration and restart the server worker when the port or max concurrent connections changes.

Types

type ControllerConfigService

type ControllerConfigService interface {
	// WatchControllerConfig returns a watcher that returns keys for any changes
	// to controller config.
	WatchControllerConfig() (watcher.StringsWatcher, error)
}

ControllerConfigService is the interface that the worker uses to get the controller configuration.

func GetControllerConfigService

func GetControllerConfigService(getter dependency.Getter, name string) (ControllerConfigService, error)

GetControllerConfigService is a helper function that gets a service from the manifold.

type GetControllerConfigServiceFunc

type GetControllerConfigServiceFunc = func(getter dependency.Getter, name string) (ControllerConfigService, error)

GetControllerConfigServiceFunc is a helper function that gets a controller config service from the manifold.

type ManifoldConfig

type ManifoldConfig struct {
	// DomainServicesName is the name of the domain services worker.
	DomainServicesName string
	// NewServerWrapperWorker is the function that creates the embedded SSH server worker.
	NewServerWrapperWorker func(ServerWrapperWorkerConfig) (worker.Worker, error)
	// NewServerWorker is the function that creates a worker that has a catacomb
	// to run the server and other worker dependencies.
	NewServerWorker func(ServerWorkerConfig) (worker.Worker, error)
	// GetControllerConfigService is used to get a service from the manifold.
	GetControllerConfigService GetControllerConfigServiceFunc
	// Logger is the logger to use for the worker.
	Logger logger.Logger
}

ManifoldConfig holds the information necessary to run an embedded SSH server worker in a dependency.Engine.

func (ManifoldConfig) Validate

func (config ManifoldConfig) Validate() error

Validate validates the manifold configuration.

type MockControllerConfigService

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

MockControllerConfigService is a mock of ControllerConfigService interface.

func NewMockControllerConfigService

func NewMockControllerConfigService(ctrl *gomock.Controller) *MockControllerConfigService

NewMockControllerConfigService creates a new mock instance.

func (*MockControllerConfigService) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockControllerConfigService) WatchControllerConfig

func (m *MockControllerConfigService) WatchControllerConfig() (watcher.Watcher[[]string], error)

WatchControllerConfig mocks base method.

type MockControllerConfigServiceMockRecorder

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

MockControllerConfigServiceMockRecorder is the mock recorder for MockControllerConfigService.

func (*MockControllerConfigServiceMockRecorder) WatchControllerConfig

WatchControllerConfig indicates an expected call of WatchControllerConfig.

type MockControllerConfigServiceWatchControllerConfigCall

type MockControllerConfigServiceWatchControllerConfigCall struct {
	*gomock.Call
}

MockControllerConfigServiceWatchControllerConfigCall wrap *gomock.Call

func (*MockControllerConfigServiceWatchControllerConfigCall) Do

Do rewrite *gomock.Call.Do

func (*MockControllerConfigServiceWatchControllerConfigCall) DoAndReturn

DoAndReturn rewrite *gomock.Call.DoAndReturn

func (*MockControllerConfigServiceWatchControllerConfigCall) Return

Return rewrite *gomock.Call.Return

type ServerWorker

type ServerWorker struct {

	// Server holds the embedded server.
	Server *ssh.Server
	// contains filtered or unexported fields
}

ServerWorker is a worker that runs an ssh server.

func (*ServerWorker) Kill

func (s *ServerWorker) Kill()

Kill stops the server worker by killing the tomb. Implements worker.Worker.

func (*ServerWorker) Wait

func (s *ServerWorker) Wait() error

Wait waits for the server worker to stop. Implements worker.Worker.

type ServerWorkerConfig

type ServerWorkerConfig struct {
	Logger logger.Logger
	// Listener holds a listener to provide the server. Should you wish to run
	// the server on a pre-existing listener, you can provide it here. Otherwise,
	// leave this value nil and a listener will be spawned.
	Listener net.Listener
}

ServerWorkerConfig holds the configuration required by the server worker.

func (ServerWorkerConfig) Validate

func (c ServerWorkerConfig) Validate() error

Validate validates the workers configuration is as expected.

type ServerWrapperWorkerConfig

type ServerWrapperWorkerConfig struct {
	ControllerConfigService ControllerConfigService
	NewServerWorker         func(ServerWorkerConfig) (worker.Worker, error)
	Logger                  logger.Logger
}

ServerWrapperWorkerConfig holds the configuration required by the server wrapper worker.

func (ServerWrapperWorkerConfig) Validate

func (c ServerWrapperWorkerConfig) Validate() error

Validate validates the workers configuration is as expected.

Jump to

Keyboard shortcuts

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