Documentation
¶
Overview ¶
Package control defines the authenticated local microvmd control plane and its bounded, versioned guest handshake.
Index ¶
- Constants
- Variables
- func GuestControlOption(socketPath string) (gomicrovm.Option, error)
- func ServeBoundRegisteredMultiplex(ctx context.Context, stream io.ReadWriteCloser, resolve BoundHandlerResolver, ...) error
- func ServeMultiplex(ctx context.Context, stream io.ReadWriteCloser, expected Binding, ...) error
- func ServeRegisteredMultiplex(ctx context.Context, stream io.ReadWriteCloser, verifier *CapabilityVerifier, ...) error
- type Agreement
- type Binding
- type BoundHandlerResolver
- type Capabilities
- type Capability
- type CapabilityIssuer
- type CapabilityVerifier
- type Client
- func (c *Client) Agreement() Agreement
- func (c *Client) Call(ctx context.Context, service ServiceName, method string, request, response any) error
- func (c *Client) Close() error
- func (c *Client) IsBoundTo(binding Binding) bool
- func (c *Client) Stream(ctx context.Context, service ServiceName, method string, request any, ...) error
- type Codec
- type Handler
- type PeerAuthenticator
- type RegisteredHandlerResolver
- type RemoteError
- type Service
- type ServiceConfig
- type ServiceName
Constants ¶
const ( // ProtocolVersion is the only guest protocol version accepted by this release. ProtocolVersion uint16 = 1 // DefaultMaxMessageBytes is the hard upper bound negotiated for protocol messages. DefaultMaxMessageBytes uint32 = 1 << 20 )
const GuestControlPort uint32 = 10777
GuestControlPort is the reserved versioned guest-control vsock port.
Variables ¶
var ( // ErrUnauthenticatedPeer means the Unix peer is not the configured daemon account. ErrUnauthenticatedPeer = errors.New("microvm control peer is not authenticated") // ErrBindingMismatch means an operation does not match its registered owner/session/ref/generation. ErrBindingMismatch = errors.New("microvm control binding mismatch") )
var ( // ErrCapabilityMismatch reports a missing mandatory guest capability. ErrCapabilityMismatch = errors.New("microvm guest capability mismatch") // ErrMessageBound reports a missing or invalid negotiated message bound. ErrMessageBound = errors.New("microvm guest message bound is missing") // ErrProtocolVersion reports an incompatible guest protocol version. ErrProtocolVersion = errors.New("microvm guest protocol version mismatch") // ErrFrameTooLarge reports a frame larger than the codec's immutable bound. ErrFrameTooLarge = errors.New("microvm protocol frame exceeds bound") // ErrMalformedFrame reports invalid bounded protocol framing or JSON. ErrMalformedFrame = errors.New("malformed microvm protocol frame") )
var ( // ErrUnauthenticatedCapability reports an invalid, stale, replayed, or wrongly bound guest capability. ErrUnauthenticatedCapability = errors.New("microvm guest capability is not authenticated") )
Functions ¶
func GuestControlOption ¶
GuestControlOption wires the guest control channel through go-microvm's vsock-to-Unix-domain-socket primitive. SSH and host-local fallbacks are not part of the control protocol.
func ServeBoundRegisteredMultiplex ¶
func ServeBoundRegisteredMultiplex(ctx context.Context, stream io.ReadWriteCloser, resolve BoundHandlerResolver, maxMessageBytes uint32) error
ServeBoundRegisteredMultiplex serves repository data without the generic transferable-capability replay table. The resolver must consume the registration incarnation exactly once.
func ServeMultiplex ¶
func ServeMultiplex(ctx context.Context, stream io.ReadWriteCloser, expected Binding, verifier *CapabilityVerifier, handlers map[ServiceName]Handler, maxMessageBytes uint32) error
ServeMultiplex authenticates one capability, negotiates services, and dispatches request IDs.
func ServeRegisteredMultiplex ¶
func ServeRegisteredMultiplex(ctx context.Context, stream io.ReadWriteCloser, verifier *CapabilityVerifier, resolve RegisteredHandlerResolver, maxMessageBytes uint32) error
ServeRegisteredMultiplex authenticates a logical binding before selecting any assigned-root handler. Each connection remains bound to that exact tuple.
Types ¶
type Agreement ¶
type Agreement struct {
Version uint16 `json:"version"`
Capabilities Capabilities `json:"capabilities"`
MaxMessageBytes uint32 `json:"max_message_bytes"`
}
Agreement is the capability set and bound selected for a connection.
type Binding ¶
type Binding struct {
Owner string `json:"owner"`
SessionID string `json:"session_id"`
EnvironmentID string `json:"environment_id"`
Ref string `json:"ref"`
Generation uint32 `json:"generation"`
// AssignedRoot is the guest-visible root authenticated for repository-logical
// environments. Protocol inputs without it are not valid logical bindings.
AssignedRoot string `json:"assigned_root,omitempty"`
}
Binding identifies one immutable environment generation. Its fields are identifiers, not credentials; authorization additionally requires an authenticated Unix peer.
type BoundHandlerResolver ¶
type BoundHandlerResolver func(Binding, string) (map[ServiceName]Handler, bool)
BoundHandlerResolver consumes one registration incarnation while resolving a repository binding on an already mutually authenticated boot channel.
type Capabilities ¶
type Capabilities []Capability
Capabilities is a deterministic capability list.
func RequiredCapabilities ¶
func RequiredCapabilities() Capabilities
RequiredCapabilities returns a fresh list of all mandatory version-1 capabilities.
func (Capabilities) Without ¶
func (c Capabilities) Without(capability Capability) Capabilities
Without returns a copy excluding capability.
type Capability ¶
type Capability string
Capability is a guest service property required before any operation is sent.
const ( // CapabilityFilesystem requires version-aware guest filesystem operations. CapabilityFilesystem Capability = "filesystem" // CapabilityStreaming requires ordered output streaming. CapabilityStreaming Capability = "streaming" // CapabilityCancellation requires guest process-group cancellation. CapabilityCancellation Capability = "cancellation" // CapabilityGenerationBinding requires every operation to bind one generation. CapabilityGenerationBinding Capability = "generation-binding" // CapabilityMessageBound requires a negotiated maximum message size. CapabilityMessageBound Capability = "message-bound" )
type CapabilityIssuer ¶
type CapabilityIssuer struct {
// contains filtered or unexported fields
}
CapabilityIssuer mints transferable, generation-bound guest capabilities. It contains only an independently provisioned signing key and shares no registry with the guest.
func NewCapabilityIssuer ¶
func NewCapabilityIssuer(key []byte) (*CapabilityIssuer, error)
NewCapabilityIssuer constructs an issuer from independently provisioned key material.
type CapabilityVerifier ¶
type CapabilityVerifier struct {
// contains filtered or unexported fields
}
CapabilityVerifier verifies capabilities using its own key copy and rejects nonce replay locally.
func NewCapabilityVerifier ¶
func NewCapabilityVerifier(key []byte) (*CapabilityVerifier, error)
NewCapabilityVerifier constructs a guest-side verifier from provisioned key material.
func (*CapabilityVerifier) Forget ¶
func (v *CapabilityVerifier) Forget(binding Binding)
Forget removes replay state belonging to one unregistered logical binding. It does not affect capabilities consumed by sibling environments.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client multiplexes concurrent workspace and exec requests over one authenticated stream.
func OpenBoundClient ¶
func OpenBoundClient(ctx context.Context, stream io.ReadWriteCloser, binding Binding, credential string, services []ServiceName, maxMessageBytes uint32) (*Client, error)
OpenBoundClient opens a multiplex client on an already mutually authenticated repository channel. credential is a registration incarnation, not a bearer credential: the surrounding channel authentication supplies peer authority.
func OpenClient ¶
func OpenClient(ctx context.Context, stream io.ReadWriteCloser, binding Binding, capability string, services []ServiceName, maxMessageBytes uint32) (*Client, error)
OpenClient authenticates one host stream and negotiates all requested services once.
func (*Client) Agreement ¶
Agreement returns a copy of the services/capabilities negotiated by the production handshake.
func (*Client) Call ¶
func (c *Client) Call(ctx context.Context, service ServiceName, method string, request, response any) error
Call performs one unary multiplexed request.
type Codec ¶
type Codec struct {
// contains filtered or unexported fields
}
Codec reads and writes unsigned 32-bit big-endian length-prefixed JSON frames.
type PeerAuthenticator ¶
PeerAuthenticator extracts kernel-authenticated credentials from a local connection.
type RegisteredHandlerResolver ¶
type RegisteredHandlerResolver func(Binding) (map[ServiceName]Handler, bool)
RegisteredHandlerResolver resolves one complete logical binding to its assigned-root handlers.
type RemoteError ¶
type RemoteError struct{ Code string }
RemoteError is a bounded service error code returned by the guest.
func (*RemoteError) Error ¶
func (e *RemoteError) Error() string
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service authorizes local control operations against kernel peer credentials and the complete immutable environment binding.
func NewService ¶
func NewService(cfg ServiceConfig) (*Service, error)
NewService constructs a local control service. Bindings are copied.
func (*Service) Authenticate ¶
Authenticate verifies the Unix peer before any caller-controlled identifier is read.
type ServiceConfig ¶
type ServiceConfig struct {
AccountUID uint32
Bindings []Binding
PeerAuthenticator PeerAuthenticator
}
ServiceConfig configures the private local microvmd control service.
type ServiceName ¶
type ServiceName string
ServiceName identifies a negotiated guest data-plane service.
const ( // ServiceWorkspace selects version-aware filesystem operations. ServiceWorkspace ServiceName = "workspace" // ServiceExec selects bounded command execution and output streaming. ServiceExec ServiceName = "exec" )
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package controltest provides deterministic offline control-protocol fakes.
|
Package controltest provides deterministic offline control-protocol fakes. |