TransportConfig#
All transport configuration is bundled into a TransportConfig dataclass that is passed to the constructor:
| |
| Field | Type | Default | Description |
|---|---|---|---|
host | str | "0.0.0.0" | Bind address |
port | int | 443 | Bind port |
tls_enabled | bool | False | Whether to enable TLS |
tls_cert_file | str | None | None | Path to PEM certificate file |
tls_key_file | str | None | None | Path to PEM private key file |
options | dict[str, Any] | {} | Transport-specific extra options |
Transport Interface#
| |
The plugin_type() classmethod is already implemented by TransportBase and returns "transport". You only need to override plugin_name().
Key Concepts#
Message Callback#
The on_message callback is provided at construction time and connects the transport to the message pipeline. When data arrives from an agent:
- Derive a
client_idstring identifying the remote connection (e.g."192.168.1.10:54321") - Call
on_message(client_id, data)with the client identifier and raw bytes - The pipeline processes the data (magic routing, crypto, codec, handler)
The callback returns None. To send response data back to the agent, the pipeline calls send(client_id, data) on the transport, which queues the response for delivery.
Sending Responses#
Use send(client_id, data) to queue response bytes for a specific client. How the data reaches the agent depends on the transport:
- HTTP – queued data is returned in the body of the client’s next POST response.
- TCP – queued data is sent as a length-prefixed message after the current request is processed.
Port Management#
The transport must release its port when stop() is called. The listener manager calls stop() on shutdown and when an operator explicitly stops a listener.
TLS Support#
TLS settings are part of TransportConfig:
tls_enabled– whether TLS is requestedtls_cert_file– path to PEM certificatetls_key_file– path to PEM private key
The transport decides how to apply TLS. If tls_enabled is true but no certificate files are specified, the built-in transports generate self-signed certificates automatically.
Built-in Transports#
| Name | Protocol | Description |
|---|---|---|
http | HTTP/HTTPS | HTTP-based agent communication via POST check-ins |
tcp | Raw TCP | Direct TCP socket communication with length-prefixed messages |
Deployment#
Place the file in plugins/transports/my_transport.py. It is discovered on the next server start or plugin refresh.