Controller¶
The controller module provides a set of HTTP and WebSocket endpoints for monitoring and managing the TCPMux server in real time.
Fields¶
enabled(bool, optional): Iftrue, the controller module will be activated. The server will listen on the specified address for API and WebSocket connections. Defaults tofalse.listen(string, optional): The address and port for the controller to listen on (e.g.,localhost:9000). This field is required ifenabledistrue.
Endpoints¶
REST API¶
-
GET /connections- Description: Retrieves a list of all currently active TCP connections being handled by the server.
- Response: A JSON array of objects, where each object represents a connection with details like ID, remote address, bytes transferred, and matched rule name.
-
POST /connections/:id/close- Description: Closes a specific active connection. The
:idparameter should be replaced with the unique connection ID obtained from the/connectionsendpoint. - Response: A JSON object confirming the closure or an error message if the connection is not found.
- Description: Closes a specific active connection. The
-
GET /logs- Description: Returns the full content of the log file configured in the
loggingsection. The content type istext/plain. - Response: The raw text content of the log file.
- Description: Returns the full content of the log file configured in the
WebSocket¶
-
GET /ws/connections- Description: Establishes a WebSocket connection to receive a real-time stream of active connections. The server broadcasts a complete list of connections every second.
- Protocol: WebSocket
- Data Format: A JSON array of connection objects, identical to the
/connectionsendpoint response, streamed at a fixed interval.
-
GET /ws/logs- Description: Establishes a WebSocket connection to stream new log entries as they are written to the log file.
- Protocol: WebSocket
- Data Format: A stream of individual log entries, each as a new line of text, following the format (
consoleorjson) specified in the logging configuration.
Example: