api

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: May 15, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package api defines the specific protocol requests and responses used between clients and servers of the “spacer” namespace creation service. These protocol elements are exchanged using the gob encoding/decoding scheme.

The api package automatically registers the individual protocol element types so that they can be especially used in receiving (polymorphous) interface values.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HaveFailed

func HaveFailed() types.GomegaMatcher

HaveFailed succeeds if the passed actual is an *ErrorResponse. In any case, actual must implement Response, otherwise Gomega will raise a failure.

Types

type ErrorResponse

type ErrorResponse struct {
	Reason string
}

ErrorResponse can be transferred in place of any other service response.

type FdsDecoder

type FdsDecoder interface{ DecodeFds(fds []int) }

type FdsEncoder

type FdsEncoder interface{ EncodeFds() (fds []int) }

type Request

type Request interface {
	// contains filtered or unexported methods
}

type Response

type Response interface {
	// contains filtered or unexported methods
}

type RoomsRequest

type RoomsRequest struct {
	// at most unix.CLONE_NEWCGROUP | unix.CLONE_NEWIPC | unix.CLONE_NEWNS |
	// unix.CLONE_NEWNET | unix.CLONE_NEWTIME | unix.CLONE_NEWUTS; but not
	// unix.CLONE_NEWUSER | unix.CLONE_NEWPID
	Spaces uint64
}

RoomsRequest requests new namespaces of the types cgroup, IPC, mnt, net, time, and UTS. It cannot be used to request PID and user namespaces, use SubspaceRequest instead.

type RoomsResponse

type RoomsResponse struct {
	Cgroup, IPC, Mnt, Net, Time, UTS int
}

RoomsResponse contains open file descriptors (>0) referencing the requested new namespaces. A zero file descriptor value indicates that no namespace of that particular type was requested and created.

Please note that the receiver takes ownership of the returned file descriptors and thus is responsible to close them when not needing them anymore.

func (*RoomsResponse) DecodeFds

func (s *RoomsResponse) DecodeFds(fds []int)

DecodeFds distributes the passed file descriptors that were received as auxiliary data with a response message back into their corresponding message fields. DecodeFds closes any passed file descriptors it cannot make any sense of.

func (*RoomsResponse) EncodeFds

func (s *RoomsResponse) EncodeFds() []int

EncodeFds returns the file descriptors contained in the response message, replacing the original message fields with zero values so the fields don't get transferred by gob. gob, not golb.

type SubspaceRequest

type SubspaceRequest struct {
	Spaces uint64 // at most unix.CLONE_NEWUSER | unix.CLONE_NEWPID
}

SubspaceRequest indicates which hierarchical namespaces to create, as the OR'ed combination of at most unix.CLONE_NEWUSER and unix.CLONE_NEWPID. The request must specify at least one of the user and pid namespaces, but is not allowed to specify any other type of namespace.

type SubspaceResponse

type SubspaceResponse struct {
	Conn  int // fd of client unix domain socket
	PIDFd int // PID fd for the serving process
	Subspaces
}

SubspaceResponse returns the connected unix domain socket to talk to a subspace spacer service instance, as well as the new user and/or PID namespaces created along with the subspacer service.

Please note that the receiver takes ownership of the returned file descriptors and thus is responsible to close them when not needing them anymore. Closing the connection fd will also terminate the connected subspace service; sub-subspace services will not be affected.

func (*SubspaceResponse) DecodeFds

func (s *SubspaceResponse) DecodeFds(fds []int)

DecodeFds distributes the passed file descriptors that were received as auxiliary data with a response message back into their corresponding message fields. DecodeFds closes any passed file descriptors it cannot make any sense of.

func (*SubspaceResponse) EncodeFds

func (s *SubspaceResponse) EncodeFds() []int

EncodeFds returns the file descriptors contained in the response message, replacing the original message fields with zero values so the fields don't get transferred by gob.

type Subspaces

type Subspaces struct {
	User int // if >0, the user namespace referencing fd.
	PID  int // if >0, the PID namespace referencing fd.
}

Subspaces contains namespace references in form of open file descriptors. The receiver of a Subspaces value takes ownership and is thus responsible to properly close them when not needing them anymore.

type UnhandlebarRequest

type UnhandlebarRequest struct{}

Jump to

Keyboard shortcuts

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