pyre-cli 2.0.0 → 3.1.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 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
@@ -41,7 +41,6 @@ curl -fsSL https://raw.githubusercontent.com/somalip/pyre/main/install.sh | bash
41
41
  ### Homebrew
42
42
 
43
43
  ```bash
44
- brew tap somalip/tap
45
44
  brew install pyre
46
45
  ```
47
46
 
@@ -88,7 +87,7 @@ pyre live --interval 5 --log # Custom interval with auto-logging
88
87
 
89
88
  ## P2P Live Data Streaming
90
89
 
91
- 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.
92
91
 
93
92
  ### Start a P2P server (host)
94
93
 
@@ -108,6 +107,75 @@ The server binds to the specified host and port, and streams live system stats t
108
107
  | `--interval <seconds>` | Data refresh interval (default: `2`) |
109
108
  | `--detailed` | Include detailed sensor readings |
110
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
+
111
179
  ### Connect a P2P client (peer)
112
180
 
113
181
  On the machine that will receive data:
@@ -123,23 +191,40 @@ The client connects to the server, authenticates with the password, and displays
123
191
  | `--p2p-host <host>` | Server address (default: `127.0.0.1`) |
124
192
  | `--p2p-port <port>` | Server port (default: `9876`) |
125
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) |
126
199
 
127
200
  ### P2P Protocol
128
201
 
129
- 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:
130
203
 
131
204
  1. Client connects to the server
132
- 2. Client sends an `auth` message with the password
133
- 3. Server validates the password and responds with `auth-ok` or `auth-fail`
134
- 4. Once authenticated, the server streams `data` messages containing `StatsData` snapshots at the configured interval
135
- 5. Both sides exchange `ping`/`pong` keepalive messages every 15 seconds
136
- 6. Either side can send a `disconnect` message to close gracefully
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 |
137
222
 
138
- ### P2P Controls
223
+ Press `Ctrl+C` to shut down the server as well.
139
224
 
140
- While connected, the client displays live system stats in a formatted table. Press `Ctrl+C` to disconnect.
225
+ ### P2P Client Controls
141
226
 
142
- On the server, type `status` to see the number of connected peers, or `q`/`quit`/`exit` to shut down.
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.
143
228
 
144
229
  ## Live Dashboard Controls
145
230
 
@@ -250,7 +335,7 @@ pyre/
250
335
  │ │ ├── index.ts # Public API: P2PServer, P2PClient
251
336
  │ │ ├── types.ts # P2P protocol type definitions
252
337
  │ │ ├── protocol.ts # Length-prefixed JSON message framing
253
- │ │ ├── server.ts # TCP server that authenticates and streams stats
338
+ │ │ ├── server.ts # TCP server: auth, TLS, rate limiting, IP filtering, audit logging, HMAC signing, data streaming
254
339
  │ │ └── client.ts # TCP client that connects and displays live data
255
340
  │ ├── history.ts # Rolling history buffer for sparkline data
256
341
  │ ├── sparkline.ts # ASCII sparkline rendering