Documentation
¶
Index ¶
- func AppendAndroidBinds(args []string) []string
- func BuildProotBaseArgs(rootfs string, uid, gid int) []string
- func DetectKernelRelease() string
- func FindProotBinary() string
- func IsAvailable() bool
- func IsTermuxProot() bool
- func ShouldUseProot() bool
- type ContainerEvent
- type EventBus
- type EventSubscriber
- type EventType
- type IPCClient
- func (c *IPCClient) Close() error
- func (c *IPCClient) Config(hidden []string, ports []PortMap) error
- func (c *IPCClient) Connect(ctx context.Context) error
- func (c *IPCClient) Exec(ctx context.Context, id string, cmd []string, env []string, cwd string) (<-chan ContainerEvent, error)
- func (c *IPCClient) Health() (*Response, error)
- func (c *IPCClient) IsConnected() bool
- func (c *IPCClient) Shutdown() error
- func (c *IPCClient) Signal(id string, sig string) error
- func (c *IPCClient) SocketPath() string
- func (c *IPCClient) Subscribe(id string, fn EventSubscriber)
- func (c *IPCClient) Unsubscribe(id string)
- type Manager
- type MessageType
- type PortMap
- type Request
- func NewConfigRequest(hidden []string, ports []PortMap) *Request
- func NewExecRequest(id string, cmd []string, env []string, cwd string) *Request
- func NewHealthRequest() *Request
- func NewShutdownRequest() *Request
- func NewSignalRequest(id string, sig string) *Request
- func NewSubscribeRequest(id string) *Request
- func NewUnsubscribeRequest(id string) *Request
- type Response
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AppendAndroidBinds ¶
AppendAndroidBinds appends Android-specific bind mounts to proot args.
func BuildProotBaseArgs ¶
BuildProotBaseArgs returns the common proot arguments for all execution methods. If uid/gid are >= 0, adds -i flag to impersonate that user inside proot.
func DetectKernelRelease ¶
func DetectKernelRelease() string
DetectKernelRelease reads the actual kernel release from /proc.
func FindProotBinary ¶
func FindProotBinary() string
FindProotBinary locates the best available proot binary and verifies it exists. Searches for doki-proot first, then falls back to system proot. Returns the empty string when no usable proot binary is found, so callers can surface a clear error instead of "executable not found" at exec.Cmd time.
func IsAvailable ¶
func IsAvailable() bool
IsAvailable checks if proot (or doki-proot) is available on the system.
func IsTermuxProot ¶
func IsTermuxProot() bool
IsTermuxProot checks if the proot binary is the Termux-specific build.
func ShouldUseProot ¶
func ShouldUseProot() bool
ShouldUseProot returns true when proot should be the preferred execution mode. Typically on Android/Termux where user namespaces are not available.
Types ¶
type ContainerEvent ¶
ContainerEvent represents an event from a container.
type EventBus ¶
type EventBus struct {
// contains filtered or unexported fields
}
EventBus manages event subscriptions for containers.
func (*EventBus) Publish ¶
func (b *EventBus) Publish(event ContainerEvent)
Publish sends an event to all subscribers of the container.
func (*EventBus) Subscribe ¶
func (b *EventBus) Subscribe(containerID string, fn EventSubscriber)
Subscribe registers a subscriber for a container's events.
func (*EventBus) SubscriberCount ¶
SubscriberCount returns the number of subscribers for a container.
func (*EventBus) Unsubscribe ¶
Unsubscribe removes all subscribers for a container.
type EventSubscriber ¶
type EventSubscriber func(event ContainerEvent)
EventSubscriber receives container events.
type IPCClient ¶
type IPCClient struct {
// contains filtered or unexported fields
}
IPCClient communicates with the doki-proot daemon via Unix socket.
func NewIPCClient ¶
NewIPCClient creates a new IPC client.
func (*IPCClient) Connect ¶
Connect connects to the daemon socket. If the socket doesn't exist, attempts to start the daemon.
func (*IPCClient) Exec ¶
func (c *IPCClient) Exec(ctx context.Context, id string, cmd []string, env []string, cwd string) (<-chan ContainerEvent, error)
Exec sends an exec command to the daemon and returns a channel of events.
func (*IPCClient) IsConnected ¶
IsConnected returns true if connected to daemon.
func (*IPCClient) SocketPath ¶
SocketPath returns the socket path.
func (*IPCClient) Subscribe ¶
func (c *IPCClient) Subscribe(id string, fn EventSubscriber)
Subscribe subscribes to events for a container.
func (*IPCClient) Unsubscribe ¶
Unsubscribe unsubscribes from events for a container.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager provides proot-based container support for Android kernels that lack full user namespace support.
func NewManager ¶
NewManager creates a new proot manager.
type MessageType ¶
type MessageType string
MessageType is the type of IPC message.
const ( // Requests (Doki → doki-proot) TypeExec MessageType = "exec" TypeConfig MessageType = "config" TypeSignal MessageType = "signal" TypeHealth MessageType = "health" TypeShutdown MessageType = "shutdown" TypeSubscribe MessageType = "subscribe" TypeUnsubscribe MessageType = "unsubscribe" // Responses (doki-proot → Doki) TypeStdout MessageType = "stdout" TypeStderr MessageType = "stderr" TypeExit MessageType = "exit" TypeReady MessageType = "ready" TypeError MessageType = "error" TypeExecError MessageType = "exec_error" TypeConfigAck MessageType = "config_ack" TypeSignalAck MessageType = "signal_ack" TypeHealthResp MessageType = "health" TypeShutdownAck MessageType = "shutdown_ack" TypeSubscribeAck MessageType = "subscribe_ack" TypeUnsubscribeAck MessageType = "unsubscribe_ack" TypeLog MessageType = "log" )
type PortMap ¶
type PortMap struct {
GuestBind int `json:"guest_bind"`
HostBind int `json:"host_bind"`
Proto string `json:"proto"`
}
PortMap is a guest→host port mapping.
type Request ¶
type Request struct {
Type MessageType `json:"type"`
ID string `json:"id,omitempty"`
Cmd []string `json:"cmd,omitempty"`
Env []string `json:"env,omitempty"`
Cwd string `json:"cwd,omitempty"`
Sig string `json:"sig,omitempty"`
Hidden []string `json:"hidden_files,omitempty"`
PortMap []PortMap `json:"port_map,omitempty"`
}
Request is a message sent to the doki-proot daemon.
func NewConfigRequest ¶
NewConfigRequest creates a config request.
func NewExecRequest ¶
NewExecRequest creates an exec request.
func NewHealthRequest ¶
func NewHealthRequest() *Request
NewHealthRequest creates a health check request.
func NewShutdownRequest ¶
func NewShutdownRequest() *Request
NewShutdownRequest creates a shutdown request.
func NewSignalRequest ¶
NewSignalRequest creates a signal request.
func NewSubscribeRequest ¶
NewSubscribeRequest creates a subscribe request.
func NewUnsubscribeRequest ¶
NewUnsubscribeRequest creates an unsubscribe request.
type Response ¶
type Response struct {
Type MessageType `json:"type"`
ID string `json:"id,omitempty"`
Data string `json:"data,omitempty"`
Code int `json:"code,omitempty"`
Status string `json:"status,omitempty"`
PID int `json:"pid,omitempty"`
Socket string `json:"socket,omitempty"`
Msg string `json:"msg,omitempty"`
}
Response is a message received from the doki-proot daemon.
func UnmarshalResponse ¶
UnmarshalResponse deserializes a response from JSON bytes.