ipc

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package ipc defines the local Unix socket protocol used between the daemon and the command line interface.

Index

Constants

View Source
const (
	CmdDevices        = "devices"
	CmdPair           = "pair"
	CmdUnpair         = "unpair"
	CmdPing           = "ping"
	CmdBattery        = "battery"
	CmdClipboardPush  = "clipboard_push"
	CmdRunList        = "run_list"
	CmdRunExec        = "run_exec"
	CmdShare          = "share"
	CmdConnect        = "connect"
	CmdWatch          = "watch"
	CmdSftpMount      = "sftp_mount"
	CmdNotifyReply    = "notify_reply"
	CmdCallMute       = "call_mute"
	CmdFindMyPhone    = "findmyphone"
	CmdLock           = "lock"
	CmdUnlock         = "unlock"
	CmdSendSMS        = "send_sms"
	CmdSftpMountLocal = "sftp_mount_local"
)

Supported IPC command constants.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConnectPayload added in v1.0.1

type ConnectPayload struct {
	IP string `json:"ip"`
}

Request is sent from the client to the local daemon.

type DevicePayload

type DevicePayload struct {
	DeviceID string `json:"deviceId"`
	Key      string `json:"key,omitempty"`
}

DevicePayload is sent in requests requiring a device ID (like pair/unpair/ping).

type Handler

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

Handler handles incoming IPC requests.

func NewHandler

func NewHandler(devices *device.Registry, plugins *plugin.Registry, pairPlugin *pair.PairPlugin, statePath string, bus *events.Bus) *Handler

NewHandler creates a new IPC command handler.

func (*Handler) HandleRequest

func (h *Handler) HandleRequest(req Request) Response

HandleRequest processes an incoming IPC request and returns a response.

func (*Handler) Register

func (h *Handler) Register(command string, fn func(Request) Response)

Register adds a custom handler for a given command.

type NotifyReplyPayload

type NotifyReplyPayload struct {
	DeviceID string `json:"deviceId"`
	ReplyID  string `json:"replyId"`
	Message  string `json:"message"`
}

NotifyReplyPayload is used for CmdNotifyReply.

type Request

type Request struct {
	Command string          `json:"cmd"`
	Payload json.RawMessage `json:"payload,omitempty"`
}

type Response

type Response struct {
	OK    bool            `json:"ok"`
	Error string          `json:"error,omitempty"`
	Data  json.RawMessage `json:"data,omitempty"`
}

Response is sent from the daemon back to the client.

type SMSPayload

type SMSPayload struct {
	DeviceID    string `json:"deviceId"`
	PhoneNumber string `json:"phoneNumber"`
	Message     string `json:"message"`
}

SMSPayload is used for CmdSendSMS.

type Server

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

Server handles listening for JSON IPC requests over a Unix socket.

func NewServer

func NewServer(path string, handler *Handler, logger *zap.Logger) *Server

NewServer creates a new IPC server.

func (*Server) Listen

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

Listen starts listening on the Unix socket and processes incoming connections.

type SftpMountLocalPayload

type SftpMountLocalPayload struct {
	DeviceID string `json:"deviceId"`
}

SftpMountLocalPayload is used for CmdSftpMountLocal.

type SharePayload

type SharePayload struct {
	DeviceID string `json:"deviceId"`
	FilePath string `json:"filePath"`
}

SharePayload is used for CmdShare.

type WatchPayload

type WatchPayload struct {
	Events []string `json:"events,omitempty"`
}

WatchPayload is used for CmdWatch to configure event streaming.

Jump to

Keyboard shortcuts

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