pyre-cli 3.8.0 → 3.9.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 +11 -2
- package/package.json +1 -1
- package/src/p2p/client.ts +5 -1
- package/src/p2p/server.ts +8 -1
package/dist/index.js
CHANGED
|
@@ -2238,8 +2238,12 @@ var P2PServer = class {
|
|
|
2238
2238
|
}
|
|
2239
2239
|
}
|
|
2240
2240
|
sendSigned(peer, message) {
|
|
2241
|
-
if (!peer.socket.
|
|
2241
|
+
if (peer.socket.destroyed || !peer.socket.writable) {
|
|
2242
|
+
return;
|
|
2243
|
+
}
|
|
2244
|
+
try {
|
|
2242
2245
|
peer.socket.write(message);
|
|
2246
|
+
} catch {
|
|
2243
2247
|
}
|
|
2244
2248
|
}
|
|
2245
2249
|
startDataStream(peer) {
|
|
@@ -2272,6 +2276,8 @@ var P2PServer = class {
|
|
|
2272
2276
|
this.log(chalk6.yellow(`Peer connection reset: ${peer.socket.remoteAddress}`));
|
|
2273
2277
|
this.audit(peer.ip, "ERROR", "Connection reset");
|
|
2274
2278
|
this.emitPeerEvent("error", `connection reset: ${peer.socket.remoteAddress}`);
|
|
2279
|
+
} else if (code === "EPIPE") {
|
|
2280
|
+
this.audit(peer.ip, "ERROR", "Broken pipe");
|
|
2275
2281
|
} else {
|
|
2276
2282
|
this.log(chalk6.red(`Peer error: ${err.message}`));
|
|
2277
2283
|
this.audit(peer.ip, "ERROR", err.message);
|
|
@@ -2480,7 +2486,10 @@ var P2PClient = class {
|
|
|
2480
2486
|
}
|
|
2481
2487
|
sendSigned(message) {
|
|
2482
2488
|
if (this.socket && !this.socket.destroyed) {
|
|
2483
|
-
|
|
2489
|
+
try {
|
|
2490
|
+
this.socket.write(message);
|
|
2491
|
+
} catch {
|
|
2492
|
+
}
|
|
2484
2493
|
}
|
|
2485
2494
|
}
|
|
2486
2495
|
startPing() {
|
package/package.json
CHANGED
package/src/p2p/client.ts
CHANGED
|
@@ -207,7 +207,11 @@ export class P2PClient {
|
|
|
207
207
|
|
|
208
208
|
private sendSigned(message: Buffer): void {
|
|
209
209
|
if (this.socket && !this.socket.destroyed) {
|
|
210
|
-
|
|
210
|
+
try {
|
|
211
|
+
this.socket.write(message);
|
|
212
|
+
} catch {
|
|
213
|
+
// ignore write errors; socket likely closed
|
|
214
|
+
}
|
|
211
215
|
}
|
|
212
216
|
}
|
|
213
217
|
|
package/src/p2p/server.ts
CHANGED
|
@@ -350,8 +350,13 @@ export class P2PServer {
|
|
|
350
350
|
}
|
|
351
351
|
|
|
352
352
|
private sendSigned(peer: Peer, message: Buffer): void {
|
|
353
|
-
if (!peer.socket.
|
|
353
|
+
if (peer.socket.destroyed || !peer.socket.writable) {
|
|
354
|
+
return;
|
|
355
|
+
}
|
|
356
|
+
try {
|
|
354
357
|
peer.socket.write(message);
|
|
358
|
+
} catch {
|
|
359
|
+
// ignore write errors; peer likely disconnected
|
|
355
360
|
}
|
|
356
361
|
}
|
|
357
362
|
|
|
@@ -390,6 +395,8 @@ export class P2PServer {
|
|
|
390
395
|
this.log(chalk.yellow(`Peer connection reset: ${peer.socket.remoteAddress}`));
|
|
391
396
|
this.audit(peer.ip, 'ERROR', 'Connection reset');
|
|
392
397
|
this.emitPeerEvent('error', `connection reset: ${peer.socket.remoteAddress}`);
|
|
398
|
+
} else if (code === 'EPIPE') {
|
|
399
|
+
this.audit(peer.ip, 'ERROR', 'Broken pipe');
|
|
393
400
|
} else {
|
|
394
401
|
this.log(chalk.red(`Peer error: ${err.message}`));
|
|
395
402
|
this.audit(peer.ip, 'ERROR', err.message);
|