server

package
v0.10.3 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2026 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidSSHUsername       = errors.New("invalid ssh username")
	ErrUnauthorizedSSHPublicKey = errors.New("ssh public key is not authorized")
	ErrSandboxAccessDenied      = errors.New("sandbox access denied")
	ErrSandboxUnavailable       = errors.New("sandbox unavailable")
	ErrSandboxWakingUp          = errors.New("sandbox is waking up")
)

Functions

func ParseSSHUsername

func ParseSSHUsername(username string) (string, error)

ParseSSHUsername extracts the sandbox ID from the SSH username. V1 only supports <sandbox_id> or <sandbox_id>+main.

Types

type Authenticator

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

Authenticator resolves the uploaded SSH public key to a user and asks the regional routing layer to authorize and resolve the sandbox runtime target.

func NewAuthenticator

func NewAuthenticator(repo identityStore, resolver sandboxResolver, resumeTimeout, pollInterval time.Duration, logger *zap.Logger) *Authenticator

NewAuthenticator creates a new SSH authenticator.

func (*Authenticator) Authenticate

func (a *Authenticator) Authenticate(ctx context.Context, username string, key ssh.PublicKey) (*SessionTarget, error)

Authenticate resolves the SSH public key to a user, authorizes the sandbox, and waits for the regional routing layer to report a reachable procd target.

type Option added in v0.8.0

type Option func(*Server)

Option configures optional ssh-gateway server behavior.

func WithMetrics added in v0.8.0

func WithMetrics(metrics *obsmetrics.SSHGatewayMetrics) Option

WithMetrics enables ssh-gateway service metrics on the server.

type RegionalSandboxResolver

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

RegionalSandboxResolver resolves sandbox runtime targets through the regional-gateway internal SSH routing surface.

func NewRegionalSandboxResolver

func NewRegionalSandboxResolver(baseURL string, internalAuthGen *internalauth.Generator, logger *zap.Logger, timeout time.Duration) *RegionalSandboxResolver

func (*RegionalSandboxResolver) ResolveSandbox

func (r *RegionalSandboxResolver) ResolveSandbox(ctx context.Context, sandboxID string, grants []sharedssh.AuthorizedGrant) (*sharedssh.ResolvedTarget, error)

func (*RegionalSandboxResolver) SetHTTPClient added in v0.3.0

func (r *RegionalSandboxResolver) SetHTTPClient(httpClient *http.Client)

SetHTTPClient replaces the resolver HTTP client.

type Server

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

Server serves SSH connections and bridges sessions to procd contexts.

func NewServer

func NewServer(cfg *config.SSHGatewayConfig, authorizer SessionAuthorizer, dataPlaneAuthGen *internalauth.Generator, logger *zap.Logger, opts ...Option) (*Server, error)

NewServer creates a new ssh-gateway server.

func (*Server) Serve

func (s *Server) Serve(ctx context.Context, listener net.Listener) error

Serve accepts SSH connections on the supplied listener until the context is canceled.

func (*Server) SetHTTPClient added in v0.3.0

func (s *Server) SetHTTPClient(httpClient *http.Client)

SetHTTPClient replaces the HTTP client used for procd requests.

func (*Server) Start

func (s *Server) Start(ctx context.Context) error

Start listens on the configured port and begins serving SSH connections.

type SessionAuthorizer

type SessionAuthorizer interface {
	Authenticate(ctx context.Context, username string, key ssh.PublicKey) (*SessionTarget, error)
}

SessionAuthorizer authenticates an SSH public key and resolves the sandbox target.

type SessionTarget

type SessionTarget struct {
	Username  string
	SandboxID string
	UserID    string
	TeamID    string
	ProcdURL  string
}

SessionTarget carries the resolved sandbox and identity information for one SSH connection.

Jump to

Keyboard shortcuts

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