blind-peer 2.7.6 → 2.7.8

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.
Files changed (3) hide show
  1. package/bin.js +10 -5
  2. package/index.js +2 -2
  3. package/package.json +2 -2
package/bin.js CHANGED
@@ -8,6 +8,7 @@ const RegisterClient = require('autobase-discovery/client/register')
8
8
  const safetyCatch = require('safety-catch')
9
9
  const byteSize = require('tiny-byte-size')
10
10
  const pino = require('pino')
11
+ const b4a = require('b4a')
11
12
 
12
13
  const BlindPeer = require('.')
13
14
 
@@ -113,11 +114,10 @@ const cmd = command('blind-peer',
113
114
  )
114
115
  }
115
116
 
116
- await blindPeer.listen()
117
-
118
- logger.info(`Blind peer listening, local address is ${blindPeer.swarm.dht.localAddress().host}:${blindPeer.swarm.dht.localAddress().port}`)
119
- logger.info(`Bytes allocated: ${byteSize(blindPeer.digest.bytesAllocated)} of ${byteSize(blindPeer.maxBytes)}`)
120
-
117
+ await blindPeer.ready() // needed to be able to access the swarm object
118
+ blindPeer.swarm.on('ban', (peerInfo, err) => {
119
+ logger.warn(`Banned peer: ${b4a.toString(peerInfo.publicKey, 'hex')}.\n${err.stack}`)
120
+ })
121
121
  if (debug) {
122
122
  blindPeer.swarm.on('connection', (conn, peerInfo) => {
123
123
  const key = idEnc.normalize(peerInfo.publicKey)
@@ -126,6 +126,11 @@ const cmd = command('blind-peer',
126
126
  })
127
127
  }
128
128
 
129
+ await blindPeer.listen()
130
+
131
+ logger.info(`Blind peer listening, local address is ${blindPeer.swarm.dht.localAddress().host}:${blindPeer.swarm.dht.localAddress().port}`)
132
+ logger.info(`Bytes allocated: ${byteSize(blindPeer.digest.bytesAllocated)} of ${byteSize(blindPeer.maxBytes)}`)
133
+
129
134
  if (flags.autodiscoveryRpcKey) {
130
135
  const autodiscoveryRpcKey = idEnc.decode(flags.autodiscoveryRpcKey)
131
136
  const seed = idEnc.decode(flags.autodiscoverySeed)
package/index.js CHANGED
@@ -155,7 +155,7 @@ class BlindPeer extends ReadyResource {
155
155
  this.rocks = typeof rocks === 'string' ? new RocksDB(rocks) : rocks
156
156
  this.store = store || new Corestore(this.rocks, { active: false })
157
157
  this.swarm = swarm || null
158
- this._port = port || null
158
+ this._port = port || 0
159
159
  this.trustedPubKeys = new Set()
160
160
  for (const k of trustedPubKeys || []) this.addTrustedPubKey(k)
161
161
 
@@ -213,7 +213,7 @@ class BlindPeer extends ReadyResource {
213
213
 
214
214
  if (this.swarm === null) {
215
215
  const swarmOpts = { keyPair: this.db.swarmingKeyPair }
216
- if (this._port) swarmOpts.port = this._port
216
+ if (this._port) swarmOpts.port = typeof this._port === 'number' ? [this._port, this._port + 64] : this._port
217
217
  this.swarm = new Hyperswarm(swarmOpts)
218
218
  }
219
219
  this.swarm.on('connection', this._onconnection.bind(this))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "blind-peer",
3
- "version": "2.7.6",
3
+ "version": "2.7.8",
4
4
  "description": "Blind peers help keep hypercores available",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -20,7 +20,7 @@
20
20
  "hypercore-id-encoding": "^1.3.0",
21
21
  "hyperdb": "^4.9.4",
22
22
  "hyperschema": "^1.10.3",
23
- "hyperswarm": "^4.8.4",
23
+ "hyperswarm": "^4.13.0",
24
24
  "paparam": "^1.8.0",
25
25
  "pino": "^9.6.0",
26
26
  "protomux-rpc": "^1.7.1",