Documentation
¶
Overview ¶
Package ipc provides a cross-platform inter-process communication layer for SENTINEL SOC Process Isolation (SEC-001).
On Linux: Unix Domain Sockets with SO_PEERCRED validation. On Windows: Named Pipes (\\.\pipe\sentinel-soc-*).
Protocol: newline-delimited JSON messages over the pipe. Each message has a Type field for routing (event, incident, ack, heartbeat).
Package ipc provides localhost IPC transport for Virtual Swarm peer synchronization using Named Pipes (Windows) or Unix Domain Sockets. Zero external dependencies — uses Go standard `net` package.
Index ¶
Constants ¶
const ( SOCMsgEvent SOCMsgType = "soc_event" // Persisted event → correlate SOCMsgIncident SOCMsgType = "soc_incident" // Created incident → respond SOCMsgAck SOCMsgType = "soc_ack" // Acknowledgement SOCMsgHeartbeat SOCMsgType = "soc_heartbeat" // Keepalive // DefaultTimeout for IPC operations. DefaultTimeout = 5 * time.Second // MaxRetries for message delivery. MaxRetries = 3 // BufferSize for pending messages when downstream is slow. BufferSize = 4096 )
const ( MsgHandshake = "handshake" MsgHandshakeAck = "handshake_ack" MsgSyncRequest = "sync_request" MsgSyncPayload = "sync_payload" )
Message types for the IPC protocol.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type BufferedSender ¶
type BufferedSender struct {
// contains filtered or unexported fields
}
BufferedSender wraps a Sender with an async buffer for non-blocking sends. If the downstream pipe is slow, messages are buffered up to BufferSize.
func NewBufferedSender ¶
func NewBufferedSender(conn net.Conn, name string) *BufferedSender
NewBufferedSender creates a buffered async sender.
func (*BufferedSender) Close ¶
func (bs *BufferedSender) Close() error
Close flushes remaining messages and shuts down.
func (*BufferedSender) Pending ¶
func (bs *BufferedSender) Pending() int
Pending returns the number of messages waiting in the buffer.
func (*BufferedSender) Send ¶
func (bs *BufferedSender) Send(msg *SOCMessage) error
Send enqueues a message for async delivery. Non-blocking if buffer isn't full.
type Listener ¶
type Listener struct {
// contains filtered or unexported fields
}
Listener accepts incoming IPC connections on a named pipe.
func Listen ¶
Listen creates a platform-specific named pipe listener. On Linux: Unix Domain Socket at /tmp/sentinel-<name>.sock On Windows: Named Pipe at \\.\pipe\sentinel-<name>
type Message ¶
type Message struct {
Type string `json:"type"`
Payload json.RawMessage `json:"payload"`
}
Message is the wire format for IPC communication.
type Receiver ¶
type Receiver struct {
// contains filtered or unexported fields
}
Receiver reads messages from an upstream IPC pipe.
func NewReceiver ¶
NewReceiver wraps a net.Conn for reading JSON messages.
func (*Receiver) Next ¶
func (r *Receiver) Next() (*SOCMessage, error)
Next reads the next message, blocking until available. Returns io.EOF when the connection is closed.
type SOCMessage ¶
type SOCMessage struct {
Type SOCMsgType `json:"type"`
ID string `json:"id,omitempty"`
Timestamp int64 `json:"ts"`
Payload json.RawMessage `json:"payload,omitempty"`
}
SOCMessage is the wire format for SOC process isolation IPC.
func NewSOCMessage ¶
func NewSOCMessage(t SOCMsgType, payload any) (*SOCMessage, error)
NewSOCMessage creates a new SOC IPC message with the given type and payload.
type SOCMsgType ¶
type SOCMsgType string
SOCMsgType identifies the SOC IPC message kind. Named differently from the Swarm transport Message to avoid conflicts.
type Sender ¶
type Sender struct {
// contains filtered or unexported fields
}
Sender writes messages to a downstream IPC pipe.
func (*Sender) Send ¶
func (s *Sender) Send(msg *SOCMessage) error
Send writes a message to the downstream pipe. Thread-safe.
func (*Sender) SendWithRetry ¶
func (s *Sender) SendWithRetry(msg *SOCMessage) error
SendWithRetry attempts to send a message with retries.
type SwarmTransport ¶
type SwarmTransport struct {
// contains filtered or unexported fields
}
SwarmTransport manages localhost IPC for peer synchronization.
func NewSwarmTransport ¶
func NewSwarmTransport(rlmDir string, reg *peer.Registry, store memory.FactStore, bus *alert.Bus) *SwarmTransport
NewSwarmTransport creates a new IPC transport.
func (*SwarmTransport) Dial ¶
func (t *SwarmTransport) Dial(ctx context.Context) (bool, error)
Dial connects to a listening peer and performs handshake + sync. Returns true if sync was successful.
func (*SwarmTransport) IsListening ¶
func (t *SwarmTransport) IsListening() bool
IsListening returns true if this transport is the active listener.