|
|
@@ -4,7 +4,7 @@
|
|
|
|
|
|
[](LICENSE)
|
|
|
|
|
|
-Lightweight OpenWrt event forwarder with a real-time web dashboard.
|
|
|
+OpenWrt event forwarder with a real-time web dashboard, command queue, and persistent history.
|
|
|
Routers stream DHCP, WiFi, and WAN events over WebSocket; the Go server
|
|
|
fans them out to Redpanda and persists them to SQLite; a React/TypeScript
|
|
|
SPA gives you live visibility and command control from any browser.
|
|
|
@@ -87,7 +87,7 @@ cd client2server
|
|
|
|
|
|
# Set secrets (use any 32+ byte strings)
|
|
|
cat > .env <<EOF
|
|
|
-TOKEN=replace-with-router-shared-secret
|
|
|
+TOKEN=replace-me
|
|
|
JWT_SECRET=$(openssl rand -hex 32)
|
|
|
EOF
|
|
|
|
|
|
@@ -110,7 +110,7 @@ cd server
|
|
|
go build -o server .
|
|
|
REDPANDA_BROKERS=localhost:9092 \
|
|
|
TOKEN=replace-me \
|
|
|
- JWT_SECRET=replace-me \
|
|
|
+ JWT_SECRET=$(openssl rand -hex 32) \
|
|
|
PORT=3843 \
|
|
|
./server
|
|
|
|
|
|
@@ -144,8 +144,8 @@ ssh root@router "/etc/init.d/client2server enable && /etc/init.d/client2server s
|
|
|
### Environment Variables
|
|
|
|
|
|
```bash
|
|
|
-TOKEN=replace-with-shared-secret # Legacy router/hotplug shared token
|
|
|
-JWT_SECRET=replace-with-32+bytes # JWT signing key for dashboard auth
|
|
|
+TOKEN=replace-me # Legacy router/hotplug shared token
|
|
|
+JWT_SECRET=replace-me-32+bytes # JWT signing key for dashboard auth (32+ random bytes)
|
|
|
REDPANDA_BROKERS=redpanda:9092 # Comma-separated Redpanda addresses
|
|
|
PORT=3843 # Server listen port
|
|
|
DB_PATH=/var/lib/c2s/client2server.db # SQLite path
|
|
|
@@ -194,20 +194,24 @@ Send from server to router via WebSocket or HTTP API:
|
|
|
```bash
|
|
|
# Reboot
|
|
|
curl -X POST http://localhost:3843/api/command \
|
|
|
- -H "Authorization: Bearer TOKEN" \
|
|
|
+ -H "Authorization: Bearer <your-token-here>" \
|
|
|
-d '{"router_id":"router1","command":"reboot"}'
|
|
|
|
|
|
# UCI set
|
|
|
curl -X POST http://localhost:3843/api/command \
|
|
|
- -H "Authorization: Bearer TOKEN" \
|
|
|
+ -H "Authorization: Bearer <your-token-here>" \
|
|
|
-d '{"router_id":"router1","command":"uci_set","args":{"config":"network","section":"lan","option":"ipaddr","value":"192.168.1.1"}}'
|
|
|
|
|
|
# Shell
|
|
|
curl -X POST http://localhost:3843/api/command \
|
|
|
- -H "Authorization: Bearer TOKEN" \
|
|
|
+ -H "Authorization: Bearer <your-token-here>" \
|
|
|
-d '{"router_id":"router1","command":"shell","args":{"command":"uptime"}}'
|
|
|
```
|
|
|
|
|
|
+The token can be either the legacy `TOKEN` shared secret (used by routers and
|
|
|
+hotplug scripts) or a JWT obtained from `POST /api/auth/login` (used by the
|
|
|
+dashboard). The router doesn't need a JWT — it sends the shared `TOKEN` directly.
|
|
|
+
|
|
|
### Available Commands
|
|
|
|
|
|
| Command | Description | Arguments | Dangerous |
|