+15
-4
@@ -45,2 +45,3 @@ const DHT = require('dht-rpc') | ||
| this._lastRandomPunch = 0 | ||
| this._connectable = true | ||
| this._randomPunchInterval = opts.randomPunchInterval || 20000 // min 20s between random punches... | ||
@@ -80,15 +81,25 @@ this._randomPunches = 0 | ||
| async resume () { | ||
| await super.resume() | ||
| async resume ({ log = noop } = {}) { | ||
| await super.resume({ log }) | ||
| const resuming = [] | ||
| for (const server of this.listening) resuming.push(server.resume()) | ||
| log('Resuming hyperdht servers') | ||
| await Promise.allSettled(resuming) | ||
| log('Done, hyperdht fully resumed') | ||
| } | ||
| async suspend () { | ||
| async suspend ({ log = noop } = {}) { | ||
| this._connectable = false // just so nothing gets connected during suspension | ||
| const suspending = [] | ||
| for (const server of this.listening) suspending.push(server.suspend()) | ||
| log('Suspending all hyperdht servers') | ||
| await Promise.allSettled(suspending) | ||
| await super.suspend() | ||
| log('Done, clearing all raw streams') | ||
| await this._rawStreams.clear() | ||
| log('Done, suspending dht-rpc') | ||
| await super.suspend({ log }) | ||
| log('Done, clearing raw streams again') | ||
| await this._rawStreams.clear() | ||
| log('Done, hyperdht fully suspended') | ||
| this._connectable = true | ||
| } | ||
@@ -95,0 +106,0 @@ |
+1
-1
@@ -49,3 +49,3 @@ const NoiseSecretStream = require('@hyperswarm/secret-stream') | ||
| // in case a socket is made during suspended state, destroy it immediately | ||
| if (dht.suspended) { | ||
| if (dht.suspended || !dht._connectable) { | ||
| encryptedSocket.destroy(SUSPENDED()) | ||
@@ -52,0 +52,0 @@ return encryptedSocket |
+7
-1
| { | ||
| "name": "hyperdht", | ||
| "version": "6.20.1", | ||
| "version": "6.20.2", | ||
| "description": "The DHT powering Hyperswarm", | ||
@@ -21,2 +21,6 @@ "main": "index.js", | ||
| "default": "events" | ||
| }, | ||
| "child_process": { | ||
| "bare": "bare-node-child-process", | ||
| "default": "child_process" | ||
| } | ||
@@ -46,2 +50,3 @@ }, | ||
| "devDependencies": { | ||
| "bare-node-child-process": "^1.0.1", | ||
| "brittle": "^3.0.0", | ||
@@ -54,2 +59,3 @@ "graceful-goodbye": "^1.3.0", | ||
| "test": "standard && node test/all.js", | ||
| "test:bare": "bare test/all.js", | ||
| "test:generate": "brittle -r test/all.js test/*.js", | ||
@@ -56,0 +62,0 @@ "lint": "standard", |
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
142600
0.5%3940
0.28%5
25%