Skip to content

Commit a07e882

Browse files
committed
plugins: READMEs
1 parent 4a45bc1 commit a07e882

5 files changed

Lines changed: 120 additions & 0 deletions

File tree

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# lws-cert-dist-client
2+
3+
This is the client-side protocol plugin for the certificate distribution system. It allows unprivileged client processes to securely request and update their TLS certificates (fullchain and private key) from a central `lws-cert-dist-server`.
4+
5+
## Features
6+
7+
- Securely fetches and updates TLS certificates for specified subdomains.
8+
- Spawns a privileged stub process (`--lws-stub=distribution-client`) when running as root to manage local file system writes and UDS communication.
9+
- Implements a UDS (Unix Domain Socket) IPC mechanism (`lws-cert-dist-stub`) for secure communication between the unprivileged process and the privileged stub.
10+
- Atomic symlink updates when new certificates are received.
11+
12+
## Configuration PVOs (Per-VHost Options)
13+
14+
| Name | Meaning | Default |
15+
|---|---|---|
16+
| `base-dir` | The base directory where certificates will be stored. | `/etc/lwsws-pki` |
17+
| `server-url` | The WebSocket URL of the central distribution server. | `wss://distribution-server.local` |
18+
| `subdomains` | A list of subdomains to request certificates for. | N/A |
19+
20+
## Usage
21+
22+
When enabled, the plugin checks if it is running as root and if subdomains are configured. If so, it spawns a privileged stub process to handle file system operations and sets up a UDS server. Unprivileged clients connect to this UDS server, which forwards JSON payloads containing the `subdomain`, `fullchain`, and `privkey` received from the central distribution server.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# lws-cert-dist-server
2+
3+
This is the server-side protocol plugin for the certificate distribution system. It securely distributes TLS certificates (fullchain and private key) to authorized clients based on Mutual TLS (mTLS) authentication.
4+
5+
## Features
6+
7+
- Distributes certificates directly to verified clients over a secure WebSocket connection.
8+
- Relies on Mutual TLS (mTLS) to authenticate clients. The Common Name (CN) of the client certificate is used to identify the subdomain.
9+
- Actively watches the local Public Key Infrastructure (PKI) directory (if `LWS_WITH_DIR` is enabled) and automatically pushes updated certificates to connected clients when changes occur on disk.
10+
11+
## Configuration PVOs (Per-VHost Options)
12+
13+
| Name | Meaning | Default |
14+
|---|---|---|
15+
| `pki-root` | The root directory where domain certificates are stored. | `/var/dnssec/domains/` |
16+
17+
## Usage
18+
19+
When a client connects, the plugin extracts the Common Name (CN) from the client's TLS certificate to identify the requesting subdomain. It then validates that a distribution client certificate exists on the server for that subdomain at `pki-root/<domain>/dist-client/distribution-client-<subdomain>.crt`.
20+
If authorized, it reads the `fullchain.pem` and `privkey.pem` for the domain, encodes them in a JSON payload, and sends them to the client. If file system watching is enabled (`LWS_WITH_DIR`), the server automatically triggers updates to connected clients whenever the respective `fullchain.pem` or `privkey.pem` files are modified.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# lws-oauth-preauth
2+
3+
This plugin provides a WebSocket-based waiting room for devices that have not yet been paired/authorized via RFC 8628 (OAuth 2.0 Device Authorization Grant). It acts as an intermediary signaling channel where pre-authenticated admin clients can securely identify and interact with unauthenticated devices before full pairing.
4+
5+
## Features
6+
7+
- Maintains a list of connected unauthenticated "devices" and authorized "listeners" (admins).
8+
- Validates authorized admin listeners via JWT (JSON Web Tokens) provided via an HTTP cookie.
9+
- Allows admins to discover unauthenticated devices currently waiting for pairing.
10+
- Facilitates sending "identify" commands to specific devices, often used to trigger a physical indication (like a blinking LED) so the admin can verify physical possession of the device before authorizing it.
11+
12+
## Configuration PVOs (Per-VHost Options)
13+
14+
| Name | Meaning | Default |
15+
|---|---|---|
16+
| `cookie-name` | The name of the HTTP cookie that carries the JWT for admin validation. | `auth_session` |
17+
| `jwt-jwk` | The JSON Web Key (JWK) string used to verify the JWT signature. Can be the literal JSON or a path to a file depending on LWS configuration. | N/A |
18+
19+
## Operation
20+
21+
- **Devices**: Devices connect to this protocol over WebSocket and send JSON payloads containing their identifying information (`name`, `serial`, `user_code`).
22+
- **Listeners (Admins)**: Admins connect to the same protocol, providing their JWT cookie. If validation succeeds, they are registered as a listener.
23+
- **Broadcast**: When a device connects or disconnects, the plugin broadcasts its state to all connected listeners.
24+
- **Identification**: A listener can send `{"cmd": "identify", "serial": "<device-serial>"}`. The plugin will route this `identify` command down to the target device, allowing it to perform a physical identification action (e.g., blink an LED).
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# lws-smtp-client
2+
3+
This is a protocol plugin providing a simple SMTP client API. It allows other components and plugins to asynchronously queue and send emails via a local or remote SMTP server.
4+
5+
## Features
6+
7+
- Non-blocking, event-loop integrated SMTP client.
8+
- Provides a C API (`lws_smtp_client_ops_t`) exposed via the protocol's user pointer, allowing other plugins/C code to trigger emails dynamically.
9+
- Implements a basic SMTP state machine (Connecting, Greeting, Helo, Mail From, Rcpt To, Data, Body, Quit).
10+
11+
## Usage via C API
12+
13+
You can lookup the protocol and access its operations to send emails from within libwebsockets:
14+
15+
```c
16+
const struct lws_protocols *pp = lws_vhost_name_to_protocol(vh, "lws-smtp-client");
17+
if (pp) {
18+
lws_smtp_client_ops_t *ops = (lws_smtp_client_ops_t *)pp->user;
19+
20+
lws_smtp_email_t email;
21+
email.from = "sender@example.com";
22+
email.to = "receiver@example.com";
23+
email.subject = "Test Email";
24+
email.body = "This is a test email sent via lws-smtp-client.";
25+
26+
ops->send_email(cx, vh, &email);
27+
}
28+
```
29+
30+
The plugin internally queues the email and asynchronously negotiates the SMTP transaction. By default, it connects to an SMTP server at `127.0.0.1:25`.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# lws-webrtc
2+
3+
This plugin implements a shared WebRTC signaling and media transport layer within libwebsockets. It handles the WebSocket signaling, DTLS (Datagram Transport Layer Security) negotiation, SRTP (Secure Real-time Transport Protocol) keying, and RTP packetization for both audio and video streams.
4+
5+
## Features
6+
7+
- **Signaling**: Parses and generates SDP (Session Description Protocol) offer/answer exchanges over a secure WebSocket connection.
8+
- **ICE Handling**: Processes STUN (Session Traversal Utilities for NAT) binding requests to establish connectivity without full ICE-agent complexity (acts as an ICE-lite server).
9+
- **Security**: Sets up DTLS handshakes and extracts SRTP keys to encrypt outgoing RTP media flows.
10+
- **Media Delivery**: Provides a C API (`lws_webrtc_send_video`, `lws_webrtc_send_audio`) to inject raw H.264/AV1 NAL units and Opus frames into the WebRTC session.
11+
- **Packetization**: Automatically fragments H.264/AV1 bitstreams and wraps them in RTP packets suitable for browsers.
12+
- **Feedback**: Receives and processes RTCP (RTP Control Protocol) feedback, particularly NACKs and PLIs (Picture Loss Indications), to maintain stream health.
13+
14+
## Usage
15+
16+
This protocol is usually utilized as an underlying infrastructure plugin for higher-level media handlers (like `protocol_lws_rtc_camera` or `protocol_lws_webrtc_mixer`), which feed the raw media frames into `lws_webrtc`.
17+
18+
It provides operations via `lws_vhost_name_to_protocol(vh, "lws-webrtc")->user`, exposing functions like:
19+
- `lws_webrtc_send_video()`
20+
- `lws_webrtc_send_audio()`
21+
- `lws_webrtc_send_text()`
22+
- Session iteration and telemetry functions.
23+
24+
When a client connects to the `lws-webrtc` WebSocket endpoint, the server responds with an SDP offer containing the supported codecs (H.264, AV1, Opus) and negotiates the WebRTC UDP data path transparently.

0 commit comments

Comments
 (0)