inoxprocess

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2024 License: MIT Imports: 37 Imported by: 0

README

Inox Process Package

Documentation

Index

Constants

View Source
const (
	HEARTBEAT_INTERVAL          = 100 * time.Millisecond
	MAX_RECONNECT_ATTEMPT_COUNT = 10
	LOCAL_WS_HANDSHAKE_TIMEOUT  = time.Second
	INIT_PROCESS_PID            = 1
)
View Source
const (
	CONTROL_SERVER_LOG_SRC    = "control-server"
	PROCESS_TOKEN_HEADER      = "Process-Token"
	PROCESS_TOKEN_BYTE_LENGTH = 32

	CONTROLLED_SUBCMD = "controlled"

	//maximum time the control server will wait for the controlled process to connect.
	MAX_CONTROLLED_PROCESS_CONNECTION_WAITING_TIME = time.Second
)
View Source
const (
	GRACEFUL_CANCELLATION_TIMEOUT = 5 * time.Second
)

Variables

View Source
var (
	ErrControlLoopEnd           = errors.New("control loop end")
	ErrTooManyReconnectAttempts = errors.New("too many reconnect attemps")
	ErrOrphanProcess            = errors.New("orphan process")
)
View Source
var (
	PROCESS_TOKEN_ENCODED_BYTE_LENGTH = hex.EncodedLen(PROCESS_TOKEN_BYTE_LENGTH)
	ErrProcessDidNotConnect           = errors.New("controlled process did not connect to the control server")
	ErrProcessAlreadyConnected        = errors.New("controlled process is already connected to the control server")
)
View Source
var (
	ErrAlreadyExecuting = errors.New("already executing")
)

Functions

func DecodeMessage

func DecodeMessage(p []byte, ptr any) error

func EncodeMessage

func EncodeMessage(msg Message) ([]byte, error)

func MustEncodeMessage

func MustEncodeMessage(msg Message) []byte

func RegisterTypesInGob

func RegisterTypesInGob()

func RestrictProcessAccess

func RestrictProcessAccess(ctx *core.Context, config ProcessRestrictionConfig)

RestrictProcessAccess uses Landlock to restrict what files the process has access to. The function does nothing on non-Linux systems. Landlock: - https://landlock.io/ - https://www.man7.org/linux/man-pages/man7/landlock.7.html

Types

type AckMsg

type AckMsg struct {
	AcknowledgedMessage ulid.ULID
}

type AllStoppedEvent

type AllStoppedEvent struct {
}

type ControlClient

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

func ConnectToProcessControlServer

func ConnectToProcessControlServer(ctx *core.Context, u *url.URL, token ControlledProcessToken) (*ControlClient, error)

func (*ControlClient) Conn

func (*ControlClient) StartControl

func (c *ControlClient) StartControl() error

type ControlServer

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

A ControlServer creates and controls Inox processes, each created process connects to the control server with a WebSocket.

func NewControlServer

func NewControlServer(ctx *core.Context, config ControlServerConfig) (*ControlServer, error)

NewControlServer creates a ControlServer, the Start method should be called to start it.

func (*ControlServer) CreateControlledProcess

func (s *ControlServer) CreateControlledProcess(grantedPerms, forbiddenPerms []core.Permission) (*ControlledProcess, error)

CreateClientProcess create an Inox process that connects to the server.

func (*ControlServer) Start

func (s *ControlServer) Start() error

Start starts the HTTP server, it returns when the server is closed.

type ControlServerConfig

type ControlServerConfig struct {
	Port           uint16
	InoxBinaryPath string
}

func (ControlServerConfig) Check

func (c ControlServerConfig) Check() error

type ControlledProcess

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

A ControlledProcess is an Inox process controlled by the control server, it is not necessarily running on the same machine.

func (*ControlledProcess) Stop

func (p *ControlledProcess) Stop(ctx *core.Context)

Stop gracefully stops the process or directly kills it, Stop does not wait for the process to exit.

type ControlledProcessToken

type ControlledProcessToken string

func ControlledProcessTokenFrom

func ControlledProcessTokenFrom(s string) (ControlledProcessToken, bool)

func MakeControlledProcessToken

func MakeControlledProcessToken() ControlledProcessToken

type ExternalFilesystem

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

A ExternalFilesystem is a filesystem provided by another process.

func (*ExternalFilesystem) Absolute

func (fls *ExternalFilesystem) Absolute(path string) (string, error)

func (*ExternalFilesystem) Chroot

func (*ExternalFilesystem) Chroot(path string) (billy.Filesystem, error)

func (*ExternalFilesystem) Create

func (*ExternalFilesystem) Create(filename string) (billy.File, error)

Create implements afs.Filesystem.

func (*ExternalFilesystem) Join

func (*ExternalFilesystem) Join(elem ...string) string

Join implements afs.Filesystem.

func (*ExternalFilesystem) Lstat

func (*ExternalFilesystem) Lstat(filename string) (fs.FileInfo, error)

Lstat implements afs.Filesystem.

func (*ExternalFilesystem) MkdirAll

func (*ExternalFilesystem) MkdirAll(filename string, perm fs.FileMode) error

MkdirAll implements afs.Filesystem.

func (*ExternalFilesystem) Open

func (*ExternalFilesystem) Open(filename string) (billy.File, error)

Open implements afs.Filesystem.

func (*ExternalFilesystem) OpenFile

func (*ExternalFilesystem) OpenFile(filename string, flag int, perm fs.FileMode) (billy.File, error)

OpenFile implements afs.Filesystem.

func (*ExternalFilesystem) ReadDir

func (*ExternalFilesystem) ReadDir(path string) ([]fs.FileInfo, error)

ReadDir implements afs.Filesystem.

func (*ExternalFilesystem) Readlink(link string) (string, error)

Readlink implements afs.Filesystem.

func (*ExternalFilesystem) Remove

func (*ExternalFilesystem) Remove(filename string) error

Remove implements afs.Filesystem.

func (*ExternalFilesystem) Rename

func (*ExternalFilesystem) Rename(oldpath string, newpath string) error

Rename implements afs.Filesystem.

func (*ExternalFilesystem) Root

func (*ExternalFilesystem) Root() string

Root implements afs.Filesystem.

func (*ExternalFilesystem) Stat

func (*ExternalFilesystem) Stat(filename string) (fs.FileInfo, error)

Stat implements afs.Filesystem.

func (*ExternalFilesystem) Symlink(target string, link string) error

Symlink implements afs.Filesystem.

func (*ExternalFilesystem) TempFile

func (*ExternalFilesystem) TempFile(dir string, prefix string) (billy.File, error)

TempFile implements afs.Filesystem.

type LaunchAppResponse

type LaunchAppResponse struct {
	Request ulid.ULID
	Error   error //can be empty
}

type LaunchApplicationRequest

type LaunchApplicationRequest struct {
	AppDir string
}

type Message

type Message struct {
	ULID  ulid.ULID
	Inner any
}

type ProcessRestrictionConfig

type ProcessRestrictionConfig struct {
	AllowBrowserAccess bool
	BrowserBinPath     string
	ForceAllowDNS      bool
}

type StopAllRequest

type StopAllRequest struct {
}

type StopAllResponse

type StopAllResponse struct {
	AlreadyStopped bool
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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