BashBrunch OTN (Over The Network) Server is a session-based communication and logging server. It provides a REST API for managing isolated sessions, appending system logs, and exchanging messages through a buffered queue system.
The server manages multiple concurrent sessions. Each session is secured via an Authorization header (session key) and is identified by a session_id.
- Session Management: Create, verify, and delete isolated sessions.
- Log Persistence: Append text logs to a session and retrieve them via a reverse-order stream.
- Message Queue: Send messages to a session buffer and retrieve/pop them using a unique message key.
- Framework: FastAPI
- Server: Uvicorn
- Middleware: Custom CORS implementation (
src.cors) - Session State: In-memory dictionary storage
All requests (except the home root) require an Authorization header to authenticate the session.
POST /{session_id}/sessions: Starts a new session or verifies an existing one.GET /{session_id}/sessions: Checks if a session is active and authorized.DELETE /{session_id}/sessions: Terminates the session.
POST /{session_id}/logs: Appends raw text to the session log.GET /{session_id}/logs: Returns logs as aStreamingResponsein reverse chronological order (newest first).
POST /{session_id}/messages: Adds a message to the session buffer. The server generates a unique random key for this message.GET /{session_id}/messages: Retrieves the oldest message in the buffer. Returns the format:key content.DELETE /{session_id}/messages/{key}: Removes a specific message from the buffer if the key matches the oldest message.
- Python 3.12+
- Install dependencies:
pip install -r requirements.txt
uvicorn src.core.main:appThe server will be available at http://0.0.0.0:8000.
1. Start a Session
curl -X POST http://localhost:8000/my-session-123/sessions \
-d "my-secret-key"2. Send a Log
curl -X POST http://localhost:8000/my-session-123/logs \
-H "Authorization: my-secret-key" \
-d "System boot complete"3. Send a Message
curl -X POST http://localhost:8000/my-session-123/messages \
-H "Authorization: my-secret-key" \
-d "Hello from the user!"4. Retrieve the Message
curl -X GET http://localhost:8000/my-session-123/messages \
-H "Authorization: my-secret-key"