pyre-cli 3.11.0 → 4.12.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/dist/index.js CHANGED
@@ -2301,10 +2301,7 @@ var P2PServer = class {
2301
2301
  this.sendSigned(peer, signMessage("disconnect", { reason }, this.hmacKey));
2302
2302
  } catch {
2303
2303
  }
2304
- try {
2305
- peer.socket.end();
2306
- } catch {
2307
- }
2304
+ peer.socket.destroy();
2308
2305
  }
2309
2306
  cleanupPeer(peer) {
2310
2307
  if (peer.intervalHandle) {
@@ -2362,11 +2359,12 @@ var P2PClient = class {
2362
2359
  console.log(chalk7.yellow("Warning: could not open audit log"));
2363
2360
  }
2364
2361
  }
2362
+ const host = sanitizeHost(this.options.host);
2365
2363
  return new Promise((resolve, reject) => {
2366
2364
  const useTLS = !!this.options.tls;
2367
2365
  if (useTLS) {
2368
2366
  const tlsOptions = {
2369
- host: this.options.host,
2367
+ host,
2370
2368
  port: this.options.port,
2371
2369
  rejectUnauthorized: !this.options.tlsInsecure
2372
2370
  };
@@ -2381,7 +2379,7 @@ var P2PClient = class {
2381
2379
  } else {
2382
2380
  this.socket = new net2.Socket();
2383
2381
  this.socket.setTimeout(1e4);
2384
- this.socket.connect(this.options.port, this.options.host, () => {
2382
+ this.socket.connect(this.options.port, host, () => {
2385
2383
  this.running = true;
2386
2384
  this.status("Connected");
2387
2385
  resolve();
@@ -2553,6 +2551,9 @@ var P2PClient = class {
2553
2551
  `);
2554
2552
  }
2555
2553
  };
2554
+ function sanitizeHost(host) {
2555
+ return host.trim().replace(/%$/, "");
2556
+ }
2556
2557
  function deriveHMACKey2(password) {
2557
2558
  return crypto3.createHash("sha256").update(password).digest("hex").slice(0, 32);
2558
2559
  }
@@ -3218,6 +3219,9 @@ function isExportMode() {
3218
3219
  function stripAnsi(s) {
3219
3220
  return s.replace(/\x1b\[[0-9;]*m/g, "");
3220
3221
  }
3222
+ function sanitizeHost2(host) {
3223
+ return host.trim().replace(/%$/, "");
3224
+ }
3221
3225
  async function main() {
3222
3226
  const cmd = program.args[0];
3223
3227
  if (cmd === "live" || !isExportMode() && !opts.once && cmd !== "p2p") {
@@ -3341,7 +3345,7 @@ async function runP2PServer() {
3341
3345
  });
3342
3346
  }
3343
3347
  async function runP2PConnect() {
3344
- const host = opts.p2pHost || "127.0.0.1";
3348
+ const host = sanitizeHost2(opts.p2pHost || "127.0.0.1");
3345
3349
  const port = parseInt(opts.p2pPort, 10) || 9876;
3346
3350
  const password = opts.p2pPassword || "";
3347
3351
  const useTLS = !!opts.p2pTls;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pyre-cli",
3
- "version": "3.11.0",
3
+ "version": "4.12.0",
4
4
  "description": "CLI Mac monitoring tool: temps, system stats, live dashboard, packet monitor, battery predictor, export",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
package/src/index.ts CHANGED
@@ -65,6 +65,10 @@ function stripAnsi(s: string): string {
65
65
  return s.replace(/\x1b\[[0-9;]*m/g, '');
66
66
  }
67
67
 
68
+ function sanitizeHost(host: string): string {
69
+ return host.trim().replace(/%$/, '');
70
+ }
71
+
68
72
  async function main() {
69
73
  const cmd = program.args[0];
70
74
 
@@ -205,7 +209,7 @@ async function runP2PServer(): Promise<void> {
205
209
  }
206
210
 
207
211
  async function runP2PConnect(): Promise<void> {
208
- const host = opts.p2pHost || '127.0.0.1';
212
+ const host = sanitizeHost(opts.p2pHost || '127.0.0.1');
209
213
  const port = parseInt(opts.p2pPort, 10) || 9876;
210
214
  const password = opts.p2pPassword || '';
211
215
  const useTLS = !!opts.p2pTls;
package/src/p2p/client.ts CHANGED
@@ -50,12 +50,14 @@ export class P2PClient {
50
50
  }
51
51
  }
52
52
 
53
+ const host = sanitizeHost(this.options.host);
54
+
53
55
  return new Promise((resolve, reject) => {
54
56
  const useTLS = !!this.options.tls;
55
57
 
56
58
  if (useTLS) {
57
59
  const tlsOptions: tls.ConnectionOptions = {
58
- host: this.options.host,
60
+ host,
59
61
  port: this.options.port,
60
62
  rejectUnauthorized: !this.options.tlsInsecure,
61
63
  };
@@ -70,7 +72,7 @@ export class P2PClient {
70
72
  } else {
71
73
  this.socket = new net.Socket();
72
74
  this.socket.setTimeout(10000);
73
- this.socket.connect(this.options.port, this.options.host, () => {
75
+ this.socket.connect(this.options.port, host, () => {
74
76
  this.running = true;
75
77
  this.status('Connected');
76
78
  resolve();
@@ -266,6 +268,10 @@ export class P2PClient {
266
268
  }
267
269
  }
268
270
 
271
+ function sanitizeHost(host: string): string {
272
+ return host.trim().replace(/%$/, '');
273
+ }
274
+
269
275
  function deriveHMACKey(password: string): string {
270
276
  return crypto.createHash('sha256').update(password).digest('hex').slice(0, 32);
271
277
  }
package/src/p2p/server.ts CHANGED
@@ -421,11 +421,7 @@ export class P2PServer {
421
421
  } catch {
422
422
  // socket may already be closed
423
423
  }
424
- try {
425
- peer.socket.end();
426
- } catch {
427
- // ignore end errors
428
- }
424
+ peer.socket.destroy();
429
425
  }
430
426
 
431
427
  private cleanupPeer(peer: Peer): void {