pyre-cli 3.0.0 → 3.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +98 -12
- package/dist/index.js +1221 -1021
- package/package.json +1 -1
- package/src/formatters/index.ts +1 -1
- package/src/formatters/render.ts +2 -1
- package/src/index.ts +2 -2
- package/src/live/input.ts +136 -3
- package/src/live/render.ts +70 -32
- package/src/live/state.ts +22 -15
- package/src/live/types.ts +1 -1
- package/src/p2p/server.ts +50 -13
- package/src/p2p/types.ts +2 -0
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@ Mac system monitoring CLI: temps, CPU, memory, disk, battery, live dashboard, pa
|
|
|
9
9
|
|
|
10
10
|
## Features
|
|
11
11
|
|
|
12
|
-
- **P2P live data streaming** — send live system stats to another system over TCP with password authentication
|
|
12
|
+
- **P2P live data streaming** — send live system stats to another system over TCP with password authentication, TLS encryption, rate limiting, IP allow/deny lists, audit logging, and HMAC message signing
|
|
13
13
|
- **Real-time system stats** — CPU brand, cores, frequency, load, and usage
|
|
14
14
|
- **Memory monitoring** — usage, swap, and total/available
|
|
15
15
|
- **Disk space** — mounted volume usage
|
|
@@ -87,7 +87,7 @@ pyre live --interval 5 --log # Custom interval with auto-logging
|
|
|
87
87
|
|
|
88
88
|
## P2P Live Data Streaming
|
|
89
89
|
|
|
90
|
-
Send live system stats to another system over a TCP connection with password authentication.
|
|
90
|
+
Send live system stats to another system over a TCP connection with password authentication. The server streams `StatsData` snapshots to authenticated peers at the configured interval.
|
|
91
91
|
|
|
92
92
|
### Start a P2P server (host)
|
|
93
93
|
|
|
@@ -107,6 +107,75 @@ The server binds to the specified host and port, and streams live system stats t
|
|
|
107
107
|
| `--interval <seconds>` | Data refresh interval (default: `2`) |
|
|
108
108
|
| `--detailed` | Include detailed sensor readings |
|
|
109
109
|
|
|
110
|
+
### Server-Side Security Features
|
|
111
|
+
|
|
112
|
+
#### TLS Encryption
|
|
113
|
+
|
|
114
|
+
Enable TLS for encrypted connections between the server and clients:
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
pyre p2p server --p2p-cert /path/to/cert.pem --p2p-key /path/to/key.pem --p2p-password mysecret
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
| Option | Description |
|
|
121
|
+
|---|---|
|
|
122
|
+
| `--p2p-cert <file>` | TLS certificate file (PEM) for the server |
|
|
123
|
+
| `--p2p-key <file>` | TLS private key file (PEM) for the server |
|
|
124
|
+
| `--p2p-ca <file>` | TLS CA certificate file (PEM) — required by clients using `--p2p-tls` |
|
|
125
|
+
|
|
126
|
+
#### Rate Limiting
|
|
127
|
+
|
|
128
|
+
Prevent brute-force password attacks by limiting authentication attempts per IP:
|
|
129
|
+
|
|
130
|
+
```bash
|
|
131
|
+
pyre p2p server --p2p-rate-limit 10 --p2p-password mysecret
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
| Option | Description |
|
|
135
|
+
|---|---|
|
|
136
|
+
| `--p2p-rate-limit <n>` | Max auth attempts per IP per minute (default: `5`) |
|
|
137
|
+
|
|
138
|
+
#### IP Allow/Deny Lists
|
|
139
|
+
|
|
140
|
+
Restrict connections to specific IPs or block known bad actors:
|
|
141
|
+
|
|
142
|
+
```bash
|
|
143
|
+
# Allow only specific IPs
|
|
144
|
+
pyre p2p server --p2p-allow 192.168.1.100,192.168.1.101 --p2p-password mysecret
|
|
145
|
+
|
|
146
|
+
# Deny specific IPs (all others allowed)
|
|
147
|
+
pyre p2p server --p2p-deny 10.0.0.99 --p2p-password mysecret
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
| Option | Description |
|
|
151
|
+
|---|---|
|
|
152
|
+
| `--p2p-allow <ips>` | Comma-separated list of allowed IPs (empty = all) |
|
|
153
|
+
| `--p2p-deny <ips>` | Comma-separated list of denied IPs |
|
|
154
|
+
|
|
155
|
+
#### Audit Logging
|
|
156
|
+
|
|
157
|
+
Log all connection events (connects, auth successes/failures, disconnects, rate limit hits, IP blocks) to a directory:
|
|
158
|
+
|
|
159
|
+
```bash
|
|
160
|
+
pyre p2p server --p2p-audit-log /var/log/pyre --p2p-password mysecret
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
| Option | Description |
|
|
164
|
+
|---|---|
|
|
165
|
+
| `--p2p-audit-log <dir>` | Directory for P2P audit logs |
|
|
166
|
+
|
|
167
|
+
#### HMAC Message Signing
|
|
168
|
+
|
|
169
|
+
All P2P messages are signed with HMAC-SHA256 to ensure integrity and authenticity. The HMAC key is derived from the password by default, but can be overridden for rotation or interoperability:
|
|
170
|
+
|
|
171
|
+
```bash
|
|
172
|
+
pyre p2p server --p2p-hmac-key my-custom-key --p2p-password mysecret
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
| Option | Description |
|
|
176
|
+
|---|---|
|
|
177
|
+
| `--p2p-hmac-key <key>` | HMAC key for message signing (default: derived from password) |
|
|
178
|
+
|
|
110
179
|
### Connect a P2P client (peer)
|
|
111
180
|
|
|
112
181
|
On the machine that will receive data:
|
|
@@ -122,23 +191,40 @@ The client connects to the server, authenticates with the password, and displays
|
|
|
122
191
|
| `--p2p-host <host>` | Server address (default: `127.0.0.1`) |
|
|
123
192
|
| `--p2p-port <port>` | Server port (default: `9876`) |
|
|
124
193
|
| `--p2p-password <password>` | Password for authentication (required) |
|
|
194
|
+
| `--p2p-tls` | Enable TLS encryption for the connection |
|
|
195
|
+
| `--p2p-ca <file>` | TLS CA certificate file (PEM) — required when using `--p2p-tls` |
|
|
196
|
+
| `--p2p-insecure` | Skip TLS certificate verification (client only) |
|
|
197
|
+
| `--p2p-audit-log <dir>` | Directory for P2P client audit logs |
|
|
198
|
+
| `--p2p-hmac-key <key>` | HMAC key for message signing (must match server) |
|
|
125
199
|
|
|
126
200
|
### P2P Protocol
|
|
127
201
|
|
|
128
|
-
The P2P connection uses a length-prefixed JSON protocol over TCP:
|
|
202
|
+
The P2P connection uses a length-prefixed JSON protocol over TCP with HMAC-SHA256 message signing:
|
|
129
203
|
|
|
130
204
|
1. Client connects to the server
|
|
131
|
-
2.
|
|
132
|
-
3.
|
|
133
|
-
4.
|
|
134
|
-
5.
|
|
135
|
-
6.
|
|
205
|
+
2. Server sends a `challenge` message with a random nonce
|
|
206
|
+
3. Client responds with an `auth` message containing the SHA-256 hash of `password:nonce`
|
|
207
|
+
4. Server validates the hash and responds with `auth-ok` or `auth-fail`
|
|
208
|
+
5. Once authenticated, the server streams `data` messages containing `StatsData` snapshots at the configured interval
|
|
209
|
+
6. Both sides exchange `ping`/`pong` keepalive messages every 15 seconds
|
|
210
|
+
7. Either side can send a `disconnect` message to close gracefully
|
|
211
|
+
|
|
212
|
+
All messages are signed with HMAC-SHA256 using a key derived from the password, ensuring message integrity and authenticity.
|
|
213
|
+
|
|
214
|
+
### Server Controls
|
|
215
|
+
|
|
216
|
+
While the P2P server is running, type these commands on the server's stdin:
|
|
217
|
+
|
|
218
|
+
| Command | Action |
|
|
219
|
+
|---|---|
|
|
220
|
+
| `status` | Print the number of currently connected peers |
|
|
221
|
+
| `q` / `quit` / `exit` | Shut down the server gracefully |
|
|
136
222
|
|
|
137
|
-
|
|
223
|
+
Press `Ctrl+C` to shut down the server as well.
|
|
138
224
|
|
|
139
|
-
|
|
225
|
+
### P2P Client Controls
|
|
140
226
|
|
|
141
|
-
|
|
227
|
+
While connected, the client displays live system stats in a formatted table. Press `Ctrl+C` to disconnect. The client will attempt to reconnect automatically after 3 seconds if the connection is lost.
|
|
142
228
|
|
|
143
229
|
## Live Dashboard Controls
|
|
144
230
|
|
|
@@ -249,7 +335,7 @@ pyre/
|
|
|
249
335
|
│ │ ├── index.ts # Public API: P2PServer, P2PClient
|
|
250
336
|
│ │ ├── types.ts # P2P protocol type definitions
|
|
251
337
|
│ │ ├── protocol.ts # Length-prefixed JSON message framing
|
|
252
|
-
│ │ ├── server.ts # TCP server
|
|
338
|
+
│ │ ├── server.ts # TCP server: auth, TLS, rate limiting, IP filtering, audit logging, HMAC signing, data streaming
|
|
253
339
|
│ │ └── client.ts # TCP client that connects and displays live data
|
|
254
340
|
│ ├── history.ts # Rolling history buffer for sparkline data
|
|
255
341
|
│ ├── sparkline.ts # ASCII sparkline rendering
|