libp2p 0.45.0 → 0.45.1-3c925ffa
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 +27 -30
- package/dist/index.min.js +27 -27
- package/dist/src/address-manager/index.d.ts +3 -3
- package/dist/src/address-manager/index.d.ts.map +1 -1
- package/dist/src/address-manager/index.js +8 -2
- package/dist/src/address-manager/index.js.map +1 -1
- package/dist/src/autonat/index.d.ts +1 -1
- package/dist/src/autonat/index.d.ts.map +1 -1
- package/dist/src/autonat/index.js +40 -31
- package/dist/src/autonat/index.js.map +1 -1
- package/dist/src/circuit-relay/index.d.ts +1 -1
- package/dist/src/circuit-relay/index.d.ts.map +1 -1
- package/dist/src/circuit-relay/server/advert-service.d.ts +2 -2
- package/dist/src/circuit-relay/server/advert-service.d.ts.map +1 -1
- package/dist/src/circuit-relay/server/advert-service.js +7 -3
- package/dist/src/circuit-relay/server/advert-service.js.map +1 -1
- package/dist/src/circuit-relay/server/index.d.ts +8 -8
- package/dist/src/circuit-relay/server/index.d.ts.map +1 -1
- package/dist/src/circuit-relay/server/index.js +23 -10
- package/dist/src/circuit-relay/server/index.js.map +1 -1
- package/dist/src/circuit-relay/server/reservation-store.d.ts +5 -5
- package/dist/src/circuit-relay/server/reservation-store.d.ts.map +1 -1
- package/dist/src/circuit-relay/server/reservation-store.js +10 -3
- package/dist/src/circuit-relay/server/reservation-store.js.map +1 -1
- package/dist/src/circuit-relay/server/reservation-voucher.d.ts.map +1 -1
- package/dist/src/circuit-relay/server/reservation-voucher.js +5 -2
- package/dist/src/circuit-relay/server/reservation-voucher.js.map +1 -1
- package/dist/src/circuit-relay/transport/discovery.d.ts +4 -4
- package/dist/src/circuit-relay/transport/discovery.d.ts.map +1 -1
- package/dist/src/circuit-relay/transport/discovery.js +9 -3
- package/dist/src/circuit-relay/transport/discovery.js.map +1 -1
- package/dist/src/circuit-relay/transport/index.d.ts +8 -9
- package/dist/src/circuit-relay/transport/index.d.ts.map +1 -1
- package/dist/src/circuit-relay/transport/index.js +25 -15
- package/dist/src/circuit-relay/transport/index.js.map +1 -1
- package/dist/src/circuit-relay/transport/listener.d.ts +1 -1
- package/dist/src/circuit-relay/transport/listener.d.ts.map +1 -1
- package/dist/src/circuit-relay/transport/listener.js +15 -19
- package/dist/src/circuit-relay/transport/listener.js.map +1 -1
- package/dist/src/circuit-relay/transport/reservation-store.d.ts +5 -5
- package/dist/src/circuit-relay/transport/reservation-store.d.ts.map +1 -1
- package/dist/src/circuit-relay/transport/reservation-store.js +55 -49
- package/dist/src/circuit-relay/transport/reservation-store.js.map +1 -1
- package/dist/src/circuit-relay/utils.d.ts.map +1 -1
- package/dist/src/circuit-relay/utils.js +3 -3
- package/dist/src/circuit-relay/utils.js.map +1 -1
- package/dist/src/components.d.ts +6 -6
- package/dist/src/components.d.ts.map +1 -1
- package/dist/src/components.js +2 -2
- package/dist/src/components.js.map +1 -1
- package/dist/src/config/connection-gater.browser.d.ts.map +1 -1
- package/dist/src/config/connection-gater.browser.js.map +1 -1
- package/dist/src/config.d.ts +2 -2
- package/dist/src/config.d.ts.map +1 -1
- package/dist/src/config.js +4 -7
- package/dist/src/config.js.map +1 -1
- package/dist/src/connection/index.d.ts +3 -3
- package/dist/src/connection/index.d.ts.map +1 -1
- package/dist/src/connection/index.js +38 -8
- package/dist/src/connection/index.js.map +1 -1
- package/dist/src/connection-manager/auto-dial.d.ts +3 -3
- package/dist/src/connection-manager/auto-dial.d.ts.map +1 -1
- package/dist/src/connection-manager/auto-dial.js +9 -1
- package/dist/src/connection-manager/auto-dial.js.map +1 -1
- package/dist/src/connection-manager/connection-pruner.d.ts +2 -2
- package/dist/src/connection-manager/connection-pruner.d.ts.map +1 -1
- package/dist/src/connection-manager/connection-pruner.js +5 -0
- package/dist/src/connection-manager/connection-pruner.js.map +1 -1
- package/dist/src/connection-manager/dial-queue.d.ts +6 -6
- package/dist/src/connection-manager/dial-queue.d.ts.map +1 -1
- package/dist/src/connection-manager/dial-queue.js +25 -11
- package/dist/src/connection-manager/dial-queue.js.map +1 -1
- package/dist/src/connection-manager/index.d.ts +12 -12
- package/dist/src/connection-manager/index.d.ts.map +1 -1
- package/dist/src/connection-manager/index.js +21 -7
- package/dist/src/connection-manager/index.js.map +1 -1
- package/dist/src/connection-manager/utils.d.ts +2 -3
- package/dist/src/connection-manager/utils.d.ts.map +1 -1
- package/dist/src/connection-manager/utils.js +3 -3
- package/dist/src/connection-manager/utils.js.map +1 -1
- package/dist/src/content-routing/index.d.ts +2 -2
- package/dist/src/content-routing/index.d.ts.map +1 -1
- package/dist/src/content-routing/index.js +7 -4
- package/dist/src/content-routing/index.js.map +1 -1
- package/dist/src/content-routing/utils.d.ts +1 -1
- package/dist/src/content-routing/utils.d.ts.map +1 -1
- package/dist/src/fetch/index.d.ts +2 -2
- package/dist/src/fetch/index.d.ts.map +1 -1
- package/dist/src/fetch/index.js +12 -7
- package/dist/src/fetch/index.js.map +1 -1
- package/dist/src/get-peer.d.ts +1 -1
- package/dist/src/get-peer.d.ts.map +1 -1
- package/dist/src/get-peer.js +3 -3
- package/dist/src/get-peer.js.map +1 -1
- package/dist/src/identify/identify.d.ts +3 -3
- package/dist/src/identify/identify.d.ts.map +1 -1
- package/dist/src/identify/identify.js +91 -79
- package/dist/src/identify/identify.js.map +1 -1
- package/dist/src/identify/index.d.ts +5 -4
- package/dist/src/identify/index.d.ts.map +1 -1
- package/dist/src/identify/index.js +1 -1
- package/dist/src/identify/index.js.map +1 -1
- package/dist/src/index.d.ts +19 -15
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/insecure/index.js +6 -8
- package/dist/src/insecure/index.js.map +1 -1
- package/dist/src/libp2p.d.ts +11 -11
- package/dist/src/libp2p.d.ts.map +1 -1
- package/dist/src/libp2p.js +58 -59
- package/dist/src/libp2p.js.map +1 -1
- package/dist/src/peer-routing.d.ts +2 -2
- package/dist/src/peer-routing.d.ts.map +1 -1
- package/dist/src/peer-routing.js +8 -6
- package/dist/src/peer-routing.js.map +1 -1
- package/dist/src/ping/index.d.ts +2 -2
- package/dist/src/ping/index.d.ts.map +1 -1
- package/dist/src/ping/index.js +14 -8
- package/dist/src/ping/index.js.map +1 -1
- package/dist/src/pnet/crypto.js +3 -3
- package/dist/src/pnet/crypto.js.map +1 -1
- package/dist/src/pnet/index.d.ts.map +1 -1
- package/dist/src/pnet/index.js +9 -6
- package/dist/src/pnet/index.js.map +1 -1
- package/dist/src/pnet/key-generator.js +1 -1
- package/dist/src/pnet/key-generator.js.map +1 -1
- package/dist/src/pubsub/dummy-pubsub.d.ts.map +1 -1
- package/dist/src/pubsub/dummy-pubsub.js +2 -5
- package/dist/src/pubsub/dummy-pubsub.js.map +1 -1
- package/dist/src/registrar.d.ts +3 -4
- package/dist/src/registrar.d.ts.map +1 -1
- package/dist/src/registrar.js +6 -3
- package/dist/src/registrar.js.map +1 -1
- package/dist/src/transport-manager.d.ts +5 -5
- package/dist/src/transport-manager.d.ts.map +1 -1
- package/dist/src/transport-manager.js +8 -3
- package/dist/src/transport-manager.js.map +1 -1
- package/dist/src/upgrader.d.ts +8 -8
- package/dist/src/upgrader.d.ts.map +1 -1
- package/dist/src/upgrader.js +11 -6
- package/dist/src/upgrader.js.map +1 -1
- package/dist/src/upnp-nat/index.d.ts +32 -3
- package/dist/src/upnp-nat/index.d.ts.map +1 -1
- package/dist/src/upnp-nat/index.js +13 -4
- package/dist/src/upnp-nat/index.js.map +1 -1
- package/dist/src/version.d.ts +1 -1
- package/dist/src/version.d.ts.map +1 -1
- package/dist/src/version.js +1 -1
- package/dist/src/version.js.map +1 -1
- package/package.json +6 -7
- package/src/address-manager/index.ts +6 -6
- package/src/autonat/index.ts +41 -41
- package/src/circuit-relay/index.ts +1 -1
- package/src/circuit-relay/server/advert-service.ts +4 -4
- package/src/circuit-relay/server/index.ts +18 -18
- package/src/circuit-relay/server/reservation-store.ts +5 -5
- package/src/circuit-relay/server/reservation-voucher.ts +1 -1
- package/src/circuit-relay/transport/discovery.ts +7 -7
- package/src/circuit-relay/transport/index.ts +26 -24
- package/src/circuit-relay/transport/listener.ts +8 -8
- package/src/circuit-relay/transport/reservation-store.ts +10 -10
- package/src/circuit-relay/utils.ts +6 -6
- package/src/components.ts +6 -6
- package/src/config/connection-gater.browser.ts +1 -1
- package/src/config.ts +8 -12
- package/src/connection/index.ts +6 -10
- package/src/connection-manager/auto-dial.ts +5 -5
- package/src/connection-manager/connection-pruner.ts +4 -4
- package/src/connection-manager/dial-queue.ts +18 -17
- package/src/connection-manager/index.ts +18 -18
- package/src/connection-manager/utils.ts +4 -5
- package/src/content-routing/index.ts +6 -6
- package/src/content-routing/utils.ts +1 -1
- package/src/fetch/index.ts +12 -12
- package/src/get-peer.ts +4 -4
- package/src/identify/identify.ts +27 -26
- package/src/identify/index.ts +6 -6
- package/src/index.ts +15 -15
- package/src/insecure/index.ts +6 -6
- package/src/libp2p.ts +35 -35
- package/src/peer-routing.ts +9 -9
- package/src/ping/index.ts +12 -12
- package/src/pnet/crypto.ts +3 -3
- package/src/pnet/index.ts +6 -6
- package/src/pnet/key-generator.ts +1 -1
- package/src/pubsub/dummy-pubsub.ts +2 -2
- package/src/registrar.ts +5 -6
- package/src/transport-manager.ts +8 -8
- package/src/upgrader.ts +17 -17
- package/src/upnp-nat/index.ts +9 -9
- package/src/version.ts +1 -1
- package/dist/typedoc-urls.json +0 -56
package/src/autonat/index.ts
CHANGED
|
@@ -1,18 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import type { Connection } from '@libp2p/interface-connection'
|
|
3
|
-
import type { ConnectionManager } from '@libp2p/interface-connection-manager'
|
|
4
|
-
import type { PeerId } from '@libp2p/interface-peer-id'
|
|
5
|
-
import type { PeerInfo } from '@libp2p/interface-peer-info'
|
|
6
|
-
import type { PeerRouting } from '@libp2p/interface-peer-routing'
|
|
7
|
-
import type { IncomingStreamData, Registrar } from '@libp2p/interface-registrar'
|
|
8
|
-
import type { TransportManager } from '@libp2p/interface-transport'
|
|
9
|
-
import type { Startable } from '@libp2p/interfaces/startable'
|
|
1
|
+
import { setMaxListeners } from 'events'
|
|
10
2
|
import { logger } from '@libp2p/logger'
|
|
11
3
|
import { peerIdFromBytes } from '@libp2p/peer-id'
|
|
12
4
|
import { createEd25519PeerId } from '@libp2p/peer-id-factory'
|
|
13
5
|
import { multiaddr, protocols } from '@multiformats/multiaddr'
|
|
14
6
|
import { abortableDuplex } from 'abortable-iterator'
|
|
15
|
-
import {
|
|
7
|
+
import { anySignal } from 'any-signal'
|
|
16
8
|
import first from 'it-first'
|
|
17
9
|
import * as lp from 'it-length-prefixed'
|
|
18
10
|
import map from 'it-map'
|
|
@@ -25,7 +17,15 @@ import {
|
|
|
25
17
|
PROTOCOL_NAME, PROTOCOL_PREFIX, PROTOCOL_VERSION, REFRESH_INTERVAL, STARTUP_DELAY, TIMEOUT
|
|
26
18
|
} from './constants.js'
|
|
27
19
|
import { Message } from './pb/index.js'
|
|
28
|
-
import {
|
|
20
|
+
import type { AddressManager } from '@libp2p/interface-address-manager'
|
|
21
|
+
import type { Connection } from '@libp2p/interface-connection'
|
|
22
|
+
import type { ConnectionManager } from '@libp2p/interface-connection-manager'
|
|
23
|
+
import type { PeerId } from '@libp2p/interface-peer-id'
|
|
24
|
+
import type { PeerInfo } from '@libp2p/interface-peer-info'
|
|
25
|
+
import type { PeerRouting } from '@libp2p/interface-peer-routing'
|
|
26
|
+
import type { IncomingStreamData, Registrar } from '@libp2p/interface-registrar'
|
|
27
|
+
import type { TransportManager } from '@libp2p/interface-transport'
|
|
28
|
+
import type { Startable } from '@libp2p/interfaces/startable'
|
|
29
29
|
|
|
30
30
|
const log = logger('libp2p:autonat')
|
|
31
31
|
|
|
@@ -110,7 +110,7 @@ class DefaultAutoNATService implements Startable {
|
|
|
110
110
|
await this.components.registrar.handle(this.protocol, (data) => {
|
|
111
111
|
void this.handleIncomingAutonatStream(data)
|
|
112
112
|
.catch(err => {
|
|
113
|
-
log.error(err)
|
|
113
|
+
log.error('error handling incoming autonat stream', err)
|
|
114
114
|
})
|
|
115
115
|
}, {
|
|
116
116
|
maxInboundStreams: this.maxInboundStreams,
|
|
@@ -156,7 +156,7 @@ class DefaultAutoNATService implements Startable {
|
|
|
156
156
|
const buf = await first(stream)
|
|
157
157
|
|
|
158
158
|
if (buf == null) {
|
|
159
|
-
log('
|
|
159
|
+
log('no message received')
|
|
160
160
|
yield Message.encode({
|
|
161
161
|
type: Message.MessageType.DIAL_RESPONSE,
|
|
162
162
|
dialResponse: {
|
|
@@ -173,7 +173,7 @@ class DefaultAutoNATService implements Startable {
|
|
|
173
173
|
try {
|
|
174
174
|
request = Message.decode(buf)
|
|
175
175
|
} catch (err) {
|
|
176
|
-
log.error('
|
|
176
|
+
log.error('could not decode message', err)
|
|
177
177
|
|
|
178
178
|
yield Message.encode({
|
|
179
179
|
type: Message.MessageType.DIAL_RESPONSE,
|
|
@@ -189,7 +189,7 @@ class DefaultAutoNATService implements Startable {
|
|
|
189
189
|
const dialRequest = request.dial
|
|
190
190
|
|
|
191
191
|
if (dialRequest == null) {
|
|
192
|
-
log.error('
|
|
192
|
+
log.error('dial was missing from message')
|
|
193
193
|
|
|
194
194
|
yield Message.encode({
|
|
195
195
|
type: Message.MessageType.DIAL_RESPONSE,
|
|
@@ -222,7 +222,7 @@ class DefaultAutoNATService implements Startable {
|
|
|
222
222
|
try {
|
|
223
223
|
peerId = peerIdFromBytes(peer.id)
|
|
224
224
|
} catch (err) {
|
|
225
|
-
log.error('
|
|
225
|
+
log.error('invalid PeerId', err)
|
|
226
226
|
|
|
227
227
|
yield Message.encode({
|
|
228
228
|
type: Message.MessageType.DIAL_RESPONSE,
|
|
@@ -235,11 +235,11 @@ class DefaultAutoNATService implements Startable {
|
|
|
235
235
|
return
|
|
236
236
|
}
|
|
237
237
|
|
|
238
|
-
log('
|
|
238
|
+
log('incoming request from %p', peerId)
|
|
239
239
|
|
|
240
240
|
// reject any dial requests that arrive via relays
|
|
241
241
|
if (!data.connection.remotePeer.equals(peerId)) {
|
|
242
|
-
log('
|
|
242
|
+
log('target peer %p did not equal sending peer %p', peerId, data.connection.remotePeer)
|
|
243
243
|
|
|
244
244
|
yield Message.encode({
|
|
245
245
|
type: Message.MessageType.DIAL_RESPONSE,
|
|
@@ -258,7 +258,7 @@ class DefaultAutoNATService implements Startable {
|
|
|
258
258
|
.filter(ma => {
|
|
259
259
|
const isFromSameHost = ma.toOptions().host === data.connection.remoteAddr.toOptions().host
|
|
260
260
|
|
|
261
|
-
log.trace('
|
|
261
|
+
log.trace('request to dial %s was sent from %s is same host %s', ma, data.connection.remoteAddr, isFromSameHost)
|
|
262
262
|
// skip any Multiaddrs where the target node's IP does not match the sending node's IP
|
|
263
263
|
return isFromSameHost
|
|
264
264
|
})
|
|
@@ -266,7 +266,7 @@ class DefaultAutoNATService implements Startable {
|
|
|
266
266
|
const host = ma.toOptions().host
|
|
267
267
|
const isPublicIp = !(isPrivateIp(host) ?? false)
|
|
268
268
|
|
|
269
|
-
log.trace('
|
|
269
|
+
log.trace('host %s was public %s', host, isPublicIp)
|
|
270
270
|
// don't try to dial private addresses
|
|
271
271
|
return isPublicIp
|
|
272
272
|
})
|
|
@@ -274,14 +274,14 @@ class DefaultAutoNATService implements Startable {
|
|
|
274
274
|
const host = ma.toOptions().host
|
|
275
275
|
const isNotOurHost = !ourHosts.includes(host)
|
|
276
276
|
|
|
277
|
-
log.trace('
|
|
277
|
+
log.trace('host %s was not our host %s', host, isNotOurHost)
|
|
278
278
|
// don't try to dial nodes on the same host as us
|
|
279
279
|
return isNotOurHost
|
|
280
280
|
})
|
|
281
281
|
.filter(ma => {
|
|
282
282
|
const isSupportedTransport = Boolean(self.components.transportManager.transportForMultiaddr(ma))
|
|
283
283
|
|
|
284
|
-
log.trace('
|
|
284
|
+
log.trace('transport for %s is supported %s', ma, isSupportedTransport)
|
|
285
285
|
// skip any Multiaddrs that have transports we do not support
|
|
286
286
|
return isSupportedTransport
|
|
287
287
|
})
|
|
@@ -296,7 +296,7 @@ class DefaultAutoNATService implements Startable {
|
|
|
296
296
|
|
|
297
297
|
// make sure we have something to dial
|
|
298
298
|
if (multiaddrs.length === 0) {
|
|
299
|
-
log('
|
|
299
|
+
log('no valid multiaddrs for %p in message', peerId)
|
|
300
300
|
|
|
301
301
|
yield Message.encode({
|
|
302
302
|
type: Message.MessageType.DIAL_RESPONSE,
|
|
@@ -309,7 +309,7 @@ class DefaultAutoNATService implements Startable {
|
|
|
309
309
|
return
|
|
310
310
|
}
|
|
311
311
|
|
|
312
|
-
log('
|
|
312
|
+
log('dial multiaddrs %s for peer %p', multiaddrs.map(ma => ma.toString()).join(', '), peerId)
|
|
313
313
|
|
|
314
314
|
let errorMessage = ''
|
|
315
315
|
let lastMultiaddr = multiaddrs[0]
|
|
@@ -324,7 +324,7 @@ class DefaultAutoNATService implements Startable {
|
|
|
324
324
|
})
|
|
325
325
|
|
|
326
326
|
if (!connection.remoteAddr.equals(multiaddr)) {
|
|
327
|
-
log.error('
|
|
327
|
+
log.error('tried to dial %s but dialed %s', multiaddr, connection.remoteAddr)
|
|
328
328
|
throw new Error('Unexpected remote address')
|
|
329
329
|
}
|
|
330
330
|
|
|
@@ -340,7 +340,7 @@ class DefaultAutoNATService implements Startable {
|
|
|
340
340
|
|
|
341
341
|
return
|
|
342
342
|
} catch (err: any) {
|
|
343
|
-
log('
|
|
343
|
+
log('could not dial %p', peerId, err)
|
|
344
344
|
errorMessage = err.message
|
|
345
345
|
} finally {
|
|
346
346
|
if (connection != null) {
|
|
@@ -364,7 +364,7 @@ class DefaultAutoNATService implements Startable {
|
|
|
364
364
|
data.stream
|
|
365
365
|
)
|
|
366
366
|
} catch (err) {
|
|
367
|
-
log.error(err)
|
|
367
|
+
log.error('error handling incoming autonat stream', err)
|
|
368
368
|
} finally {
|
|
369
369
|
signal.clear()
|
|
370
370
|
}
|
|
@@ -373,7 +373,7 @@ class DefaultAutoNATService implements Startable {
|
|
|
373
373
|
_verifyExternalAddresses (): void {
|
|
374
374
|
void this.verifyExternalAddresses()
|
|
375
375
|
.catch(err => {
|
|
376
|
-
log.error(err)
|
|
376
|
+
log.error('error verifying external address', err)
|
|
377
377
|
})
|
|
378
378
|
}
|
|
379
379
|
|
|
@@ -398,7 +398,7 @@ class DefaultAutoNATService implements Startable {
|
|
|
398
398
|
})
|
|
399
399
|
|
|
400
400
|
if (multiaddrs.length === 0) {
|
|
401
|
-
log('
|
|
401
|
+
log('no public addresses found, not requesting verification')
|
|
402
402
|
this.verifyAddressTimeout = setTimeout(this._verifyExternalAddresses, this.refreshInterval)
|
|
403
403
|
|
|
404
404
|
return
|
|
@@ -436,7 +436,7 @@ class DefaultAutoNATService implements Startable {
|
|
|
436
436
|
|
|
437
437
|
const verifyAddress = async (peer: PeerInfo): Promise<Message.DialResponse | undefined> => {
|
|
438
438
|
try {
|
|
439
|
-
log('
|
|
439
|
+
log('asking %p to verify multiaddr', peer.id)
|
|
440
440
|
|
|
441
441
|
const connection = await self.components.connectionManager.openConnection(peer.id, {
|
|
442
442
|
signal
|
|
@@ -452,16 +452,16 @@ class DefaultAutoNATService implements Startable {
|
|
|
452
452
|
(source) => lp.encode(source),
|
|
453
453
|
source,
|
|
454
454
|
(source) => lp.decode(source),
|
|
455
|
-
async (stream) =>
|
|
455
|
+
async (stream) => first(stream)
|
|
456
456
|
)
|
|
457
457
|
if (buf == null) {
|
|
458
|
-
log('
|
|
458
|
+
log('no response received from %p', connection.remotePeer)
|
|
459
459
|
return undefined
|
|
460
460
|
}
|
|
461
461
|
const response = Message.decode(buf)
|
|
462
462
|
|
|
463
463
|
if (response.type !== Message.MessageType.DIAL_RESPONSE || response.dialResponse == null) {
|
|
464
|
-
log('
|
|
464
|
+
log('invalid autonat response from %p', connection.remotePeer)
|
|
465
465
|
return undefined
|
|
466
466
|
}
|
|
467
467
|
|
|
@@ -477,12 +477,12 @@ class DefaultAutoNATService implements Startable {
|
|
|
477
477
|
const octets = options.host.split(':')
|
|
478
478
|
segment = octets[0]
|
|
479
479
|
} else {
|
|
480
|
-
log('
|
|
480
|
+
log('remote address "%s" was not IP4 or IP6?', options.host)
|
|
481
481
|
return undefined
|
|
482
482
|
}
|
|
483
483
|
|
|
484
484
|
if (networkSegments.includes(segment)) {
|
|
485
|
-
log('
|
|
485
|
+
log('already have response from network segment %d - %s', segment, options.host)
|
|
486
486
|
return undefined
|
|
487
487
|
}
|
|
488
488
|
|
|
@@ -491,13 +491,13 @@ class DefaultAutoNATService implements Startable {
|
|
|
491
491
|
|
|
492
492
|
return response.dialResponse
|
|
493
493
|
} catch (err) {
|
|
494
|
-
log.error(err)
|
|
494
|
+
log.error('error asking remote to verify multiaddr', err)
|
|
495
495
|
}
|
|
496
496
|
}
|
|
497
497
|
|
|
498
498
|
for await (const dialResponse of parallel(map(this.components.peerRouting.getClosestPeers(randomCid, {
|
|
499
499
|
signal
|
|
500
|
-
}), (peer) => async () =>
|
|
500
|
+
}), (peer) => async () => verifyAddress(peer)), {
|
|
501
501
|
concurrency: REQUIRED_SUCCESSFUL_DIALS
|
|
502
502
|
})) {
|
|
503
503
|
try {
|
|
@@ -508,7 +508,7 @@ class DefaultAutoNATService implements Startable {
|
|
|
508
508
|
// they either told us which address worked/didn't work, or we only sent them one address
|
|
509
509
|
const addr = dialResponse.addr == null ? multiaddrs[0] : multiaddr(dialResponse.addr)
|
|
510
510
|
|
|
511
|
-
log('
|
|
511
|
+
log('autonat response for %s is %s', addr, dialResponse.status)
|
|
512
512
|
|
|
513
513
|
if (dialResponse.status === Message.ResponseStatus.E_BAD_REQUEST) {
|
|
514
514
|
// the remote could not parse our request
|
|
@@ -526,7 +526,7 @@ class DefaultAutoNATService implements Startable {
|
|
|
526
526
|
}
|
|
527
527
|
|
|
528
528
|
if (!multiaddrs.some(ma => ma.equals(addr))) {
|
|
529
|
-
log('
|
|
529
|
+
log('peer reported %s as %s but it was not in our observed address list', addr, dialResponse.status)
|
|
530
530
|
continue
|
|
531
531
|
}
|
|
532
532
|
|
|
@@ -556,7 +556,7 @@ class DefaultAutoNATService implements Startable {
|
|
|
556
556
|
return
|
|
557
557
|
}
|
|
558
558
|
} catch (err) {
|
|
559
|
-
log.error('
|
|
559
|
+
log.error('could not verify external address', err)
|
|
560
560
|
}
|
|
561
561
|
}
|
|
562
562
|
} finally {
|
|
@@ -565,7 +565,7 @@ class DefaultAutoNATService implements Startable {
|
|
|
565
565
|
}
|
|
566
566
|
}
|
|
567
567
|
|
|
568
|
-
export function autoNATService (init: AutoNATServiceInit = {}): (components: AutoNATComponents) =>
|
|
568
|
+
export function autoNATService (init: AutoNATServiceInit = {}): (components: AutoNATComponents) => unknown {
|
|
569
569
|
return (components) => {
|
|
570
570
|
return new DefaultAutoNATService(components, init)
|
|
571
571
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import type { Limit } from './pb/index.js'
|
|
1
2
|
import type { EventEmitter } from '@libp2p/interfaces/events'
|
|
2
3
|
import type { PeerMap } from '@libp2p/peer-collections'
|
|
3
|
-
import type { Limit } from './pb/index.js'
|
|
4
4
|
import type { Multiaddr } from '@multiformats/multiaddr'
|
|
5
5
|
|
|
6
6
|
export interface RelayReservation {
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
+
import { EventEmitter } from '@libp2p/interfaces/events'
|
|
1
2
|
import { logger } from '@libp2p/logger'
|
|
3
|
+
import pRetry from 'p-retry'
|
|
2
4
|
import { codes } from '../../errors.js'
|
|
3
|
-
import { namespaceToCid } from '../utils.js'
|
|
4
5
|
import {
|
|
5
6
|
DEFAULT_ADVERT_BOOT_DELAY,
|
|
6
7
|
RELAY_RENDEZVOUS_NS
|
|
7
8
|
} from '../constants.js'
|
|
8
|
-
import
|
|
9
|
+
import { namespaceToCid } from '../utils.js'
|
|
9
10
|
import type { ContentRouting } from '@libp2p/interface-content-routing'
|
|
10
|
-
import {
|
|
11
|
-
import pRetry from 'p-retry'
|
|
11
|
+
import type { Startable } from '@libp2p/interfaces/startable'
|
|
12
12
|
|
|
13
13
|
const log = logger('libp2p:circuit-relay:advert-service')
|
|
14
14
|
|
|
@@ -1,31 +1,31 @@
|
|
|
1
|
+
import { setMaxListeners } from 'events'
|
|
2
|
+
import { EventEmitter } from '@libp2p/interfaces/events'
|
|
1
3
|
import { logger } from '@libp2p/logger'
|
|
2
|
-
import {
|
|
4
|
+
import { peerIdFromBytes } from '@libp2p/peer-id'
|
|
5
|
+
import { RecordEnvelope } from '@libp2p/peer-record'
|
|
6
|
+
import { type Multiaddr, multiaddr } from '@multiformats/multiaddr'
|
|
7
|
+
import { pbStream, type ProtobufStream } from 'it-pb-stream'
|
|
8
|
+
import pDefer from 'p-defer'
|
|
3
9
|
import {
|
|
4
10
|
CIRCUIT_PROTO_CODE,
|
|
5
11
|
DEFAULT_HOP_TIMEOUT,
|
|
6
12
|
RELAY_SOURCE_TAG
|
|
7
13
|
, RELAY_V2_HOP_CODEC, RELAY_V2_STOP_CODEC
|
|
8
14
|
} from '../constants.js'
|
|
9
|
-
import type
|
|
10
|
-
import
|
|
11
|
-
import {
|
|
12
|
-
import
|
|
13
|
-
import { AdvertService, AdvertServiceComponents, AdvertServiceInit } from './advert-service.js'
|
|
14
|
-
import pDefer from 'p-defer'
|
|
15
|
-
import { pbStream, ProtobufStream } from 'it-pb-stream'
|
|
16
|
-
import { HopMessage, Reservation, Status, StopMessage } from '../pb/index.js'
|
|
17
|
-
import { Multiaddr, multiaddr } from '@multiformats/multiaddr'
|
|
18
|
-
import type { Connection, Stream } from '@libp2p/interface-connection'
|
|
19
|
-
import type { ConnectionGater } from '@libp2p/interface-connection-gater'
|
|
20
|
-
import { peerIdFromBytes } from '@libp2p/peer-id'
|
|
21
|
-
import type { PeerId } from '@libp2p/interface-peer-id'
|
|
22
|
-
import { RecordEnvelope } from '@libp2p/peer-record'
|
|
15
|
+
import { HopMessage, type Reservation, Status, StopMessage } from '../pb/index.js'
|
|
16
|
+
import { createLimitedRelay } from '../utils.js'
|
|
17
|
+
import { AdvertService, type AdvertServiceComponents, type AdvertServiceInit } from './advert-service.js'
|
|
18
|
+
import { ReservationStore, type ReservationStoreInit } from './reservation-store.js'
|
|
23
19
|
import { ReservationVoucherRecord } from './reservation-voucher.js'
|
|
20
|
+
import type { CircuitRelayService, RelayReservation } from '../index.js'
|
|
24
21
|
import type { AddressManager } from '@libp2p/interface-address-manager'
|
|
22
|
+
import type { Connection, Stream } from '@libp2p/interface-connection'
|
|
23
|
+
import type { ConnectionGater } from '@libp2p/interface-connection-gater'
|
|
25
24
|
import type { ConnectionManager } from '@libp2p/interface-connection-manager'
|
|
26
|
-
import type {
|
|
27
|
-
import {
|
|
28
|
-
import {
|
|
25
|
+
import type { PeerId } from '@libp2p/interface-peer-id'
|
|
26
|
+
import type { PeerStore } from '@libp2p/interface-peer-store'
|
|
27
|
+
import type { IncomingStreamData, Registrar } from '@libp2p/interface-registrar'
|
|
28
|
+
import type { Startable } from '@libp2p/interfaces/startable'
|
|
29
29
|
import type { PeerMap } from '@libp2p/peer-collections'
|
|
30
30
|
|
|
31
31
|
const log = logger('libp2p:circuit-relay:server')
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { Limit, Status } from '../pb/index.js'
|
|
2
|
-
import type { Multiaddr } from '@multiformats/multiaddr'
|
|
3
|
-
import type { PeerId } from '@libp2p/interface-peer-id'
|
|
4
|
-
import type { Startable } from '@libp2p/interfaces/startable'
|
|
5
1
|
import { PeerMap } from '@libp2p/peer-collections'
|
|
6
|
-
import type { RecursivePartial } from '@libp2p/interfaces'
|
|
7
2
|
import { DEFAULT_DATA_LIMIT, DEFAULT_DURATION_LIMIT, DEFAULT_MAX_RESERVATION_CLEAR_INTERVAL, DEFAULT_MAX_RESERVATION_STORE_SIZE, DEFAULT_MAX_RESERVATION_TTL } from '../constants.js'
|
|
3
|
+
import { type Limit, Status } from '../pb/index.js'
|
|
8
4
|
import type { RelayReservation } from '../index.js'
|
|
5
|
+
import type { PeerId } from '@libp2p/interface-peer-id'
|
|
6
|
+
import type { RecursivePartial } from '@libp2p/interfaces'
|
|
7
|
+
import type { Startable } from '@libp2p/interfaces/startable'
|
|
8
|
+
import type { Multiaddr } from '@multiformats/multiaddr'
|
|
9
9
|
|
|
10
10
|
export type ReservationStatus = Status.OK | Status.PERMISSION_DENIED | Status.RESERVATION_REFUSED
|
|
11
11
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { ReservationVoucher } from '../pb/index.js'
|
|
1
2
|
import type { PeerId } from '@libp2p/interface-peer-id'
|
|
2
3
|
import type { Record } from '@libp2p/interface-record'
|
|
3
|
-
import { ReservationVoucher } from '../pb/index.js'
|
|
4
4
|
|
|
5
5
|
export interface ReservationVoucherOptions {
|
|
6
6
|
relay: PeerId
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
+
import { EventEmitter } from '@libp2p/interfaces/events'
|
|
1
2
|
import { logger } from '@libp2p/logger'
|
|
2
|
-
import {
|
|
3
|
+
import { createTopology } from '@libp2p/topology'
|
|
3
4
|
import {
|
|
4
5
|
RELAY_RENDEZVOUS_NS,
|
|
5
6
|
RELAY_V2_HOP_CODEC
|
|
6
7
|
} from '../constants.js'
|
|
7
|
-
import
|
|
8
|
-
import type { PeerStore } from '@libp2p/interface-peer-store'
|
|
9
|
-
import { EventEmitter } from '@libp2p/interfaces/events'
|
|
10
|
-
import type { Startable } from '@libp2p/interfaces/startable'
|
|
8
|
+
import { namespaceToCid } from '../utils.js'
|
|
11
9
|
import type { ConnectionManager } from '@libp2p/interface-connection-manager'
|
|
12
|
-
import type { TransportManager } from '@libp2p/interface-transport'
|
|
13
10
|
import type { ContentRouting } from '@libp2p/interface-content-routing'
|
|
11
|
+
import type { PeerId } from '@libp2p/interface-peer-id'
|
|
12
|
+
import type { PeerStore } from '@libp2p/interface-peer-store'
|
|
14
13
|
import type { Registrar } from '@libp2p/interface-registrar'
|
|
15
|
-
import {
|
|
14
|
+
import type { TransportManager } from '@libp2p/interface-transport'
|
|
15
|
+
import type { Startable } from '@libp2p/interfaces/startable'
|
|
16
16
|
|
|
17
17
|
const log = logger('libp2p:circuit-relay:discover-relays')
|
|
18
18
|
|
|
@@ -1,30 +1,29 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { symbol, type Upgrader, type Listener, type Transport, type CreateListenerOptions } from '@libp2p/interface-transport'
|
|
2
|
+
import { CodeError } from '@libp2p/interfaces/errors'
|
|
2
3
|
import { logger } from '@libp2p/logger'
|
|
4
|
+
import { peerIdFromBytes, peerIdFromString } from '@libp2p/peer-id'
|
|
5
|
+
import { streamToMaConnection } from '@libp2p/utils/stream-to-ma-conn'
|
|
3
6
|
import * as mafmt from '@multiformats/mafmt'
|
|
4
7
|
import { multiaddr } from '@multiformats/multiaddr'
|
|
8
|
+
import { pbStream } from 'it-pb-stream'
|
|
5
9
|
import { codes } from '../../errors.js'
|
|
6
|
-
import {
|
|
10
|
+
import { CIRCUIT_PROTO_CODE, RELAY_V2_HOP_CODEC, RELAY_V2_STOP_CODEC } from '../constants.js'
|
|
11
|
+
import { StopMessage, HopMessage, Status } from '../pb/index.js'
|
|
12
|
+
import { RelayDiscovery, type RelayDiscoveryComponents } from './discovery.js'
|
|
7
13
|
import { createListener } from './listener.js'
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import type { AbortOptions } from '@libp2p/interfaces'
|
|
11
|
-
import type { IncomingStreamData, Registrar } from '@libp2p/interface-registrar'
|
|
12
|
-
import type { Listener, Transport, CreateListenerOptions } from '@libp2p/interface-transport'
|
|
14
|
+
import { type RelayStoreInit, ReservationStore } from './reservation-store.js'
|
|
15
|
+
import type { AddressManager } from '@libp2p/interface-address-manager'
|
|
13
16
|
import type { Connection, Stream } from '@libp2p/interface-connection'
|
|
14
17
|
import type { ConnectionGater } from '@libp2p/interface-connection-gater'
|
|
15
|
-
import type { PeerId } from '@libp2p/interface-peer-id'
|
|
16
|
-
import type { Multiaddr } from '@multiformats/multiaddr'
|
|
17
|
-
import type { PeerStore } from '@libp2p/interface-peer-store'
|
|
18
18
|
import type { ConnectionManager } from '@libp2p/interface-connection-manager'
|
|
19
|
-
import type { AddressManager } from '@libp2p/interface-address-manager'
|
|
20
|
-
import { pbStream } from 'it-pb-stream'
|
|
21
19
|
import type { ContentRouting } from '@libp2p/interface-content-routing'
|
|
22
|
-
import { CIRCUIT_PROTO_CODE, RELAY_V2_HOP_CODEC, RELAY_V2_STOP_CODEC } from '../constants.js'
|
|
23
|
-
import { RelayStoreInit, ReservationStore } from './reservation-store.js'
|
|
24
|
-
import { RelayDiscovery, RelayDiscoveryComponents } from './discovery.js'
|
|
25
|
-
import { CodeError } from '@libp2p/interfaces/errors'
|
|
26
|
-
import type { EventEmitter } from '@libp2p/interfaces/events'
|
|
27
20
|
import type { Libp2pEvents } from '@libp2p/interface-libp2p'
|
|
21
|
+
import type { PeerId } from '@libp2p/interface-peer-id'
|
|
22
|
+
import type { PeerStore } from '@libp2p/interface-peer-store'
|
|
23
|
+
import type { IncomingStreamData, Registrar } from '@libp2p/interface-registrar'
|
|
24
|
+
import type { AbortOptions } from '@libp2p/interfaces'
|
|
25
|
+
import type { EventEmitter } from '@libp2p/interfaces/events'
|
|
26
|
+
import type { Multiaddr } from '@multiformats/multiaddr'
|
|
28
27
|
|
|
29
28
|
const log = logger('libp2p:circuit-relay:transport')
|
|
30
29
|
|
|
@@ -142,13 +141,9 @@ class CircuitRelayTransport implements Transport {
|
|
|
142
141
|
this.started = false
|
|
143
142
|
}
|
|
144
143
|
|
|
145
|
-
|
|
146
|
-
return true
|
|
147
|
-
}
|
|
144
|
+
readonly [symbol] = true
|
|
148
145
|
|
|
149
|
-
|
|
150
|
-
return 'libp2p/circuit-relay-v2'
|
|
151
|
-
}
|
|
146
|
+
readonly [Symbol.toStringTag] = 'libp2p/circuit-relay-v2'
|
|
152
147
|
|
|
153
148
|
/**
|
|
154
149
|
* Dial a peer over a relay
|
|
@@ -188,8 +183,10 @@ class CircuitRelayTransport implements Transport {
|
|
|
188
183
|
disconnectOnFailure = true
|
|
189
184
|
}
|
|
190
185
|
|
|
186
|
+
let stream: Stream | undefined
|
|
187
|
+
|
|
191
188
|
try {
|
|
192
|
-
|
|
189
|
+
stream = await relayConnection.newStream([RELAY_V2_HOP_CODEC])
|
|
193
190
|
|
|
194
191
|
return await this.connectV2({
|
|
195
192
|
stream,
|
|
@@ -202,6 +199,11 @@ class CircuitRelayTransport implements Transport {
|
|
|
202
199
|
})
|
|
203
200
|
} catch (err: any) {
|
|
204
201
|
log.error(`Circuit relay dial to destination ${destinationPeer.toString()} via relay ${relayPeer.toString()} failed`, err)
|
|
202
|
+
|
|
203
|
+
if (stream != null) {
|
|
204
|
+
stream.abort(err)
|
|
205
|
+
}
|
|
206
|
+
|
|
205
207
|
disconnectOnFailure && await relayConnection.close()
|
|
206
208
|
throw err
|
|
207
209
|
}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
+
import { CodeError } from '@libp2p/interfaces/errors'
|
|
1
2
|
import { EventEmitter } from '@libp2p/interfaces/events'
|
|
2
|
-
import type { ConnectionManager } from '@libp2p/interface-connection-manager'
|
|
3
|
-
import type { Listener, ListenerEvents } from '@libp2p/interface-transport'
|
|
4
|
-
import type { Multiaddr } from '@multiformats/multiaddr'
|
|
5
|
-
import { multiaddr } from '@multiformats/multiaddr'
|
|
6
|
-
import type { ReservationStore } from './reservation-store.js'
|
|
7
|
-
import type { PeerId } from '@libp2p/interface-peer-id'
|
|
8
|
-
import { PeerMap } from '@libp2p/peer-collections'
|
|
9
3
|
import { logger } from '@libp2p/logger'
|
|
4
|
+
import { PeerMap } from '@libp2p/peer-collections'
|
|
10
5
|
import { peerIdFromString } from '@libp2p/peer-id'
|
|
6
|
+
import { multiaddr } from '@multiformats/multiaddr'
|
|
7
|
+
import type { ReservationStore } from './reservation-store.js'
|
|
11
8
|
import type { Connection } from '@libp2p/interface-connection'
|
|
12
|
-
import {
|
|
9
|
+
import type { ConnectionManager } from '@libp2p/interface-connection-manager'
|
|
10
|
+
import type { PeerId } from '@libp2p/interface-peer-id'
|
|
11
|
+
import type { Listener, ListenerEvents } from '@libp2p/interface-transport'
|
|
12
|
+
import type { Multiaddr } from '@multiformats/multiaddr'
|
|
13
13
|
|
|
14
14
|
const log = logger('libp2p:circuit-relay:transport:listener')
|
|
15
15
|
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { EventEmitter } from '@libp2p/interfaces/events'
|
|
2
|
+
import { logger } from '@libp2p/logger'
|
|
2
3
|
import { PeerMap } from '@libp2p/peer-collections'
|
|
4
|
+
import { multiaddr } from '@multiformats/multiaddr'
|
|
5
|
+
import { pbStream } from 'it-pb-stream'
|
|
3
6
|
import PQueue from 'p-queue'
|
|
4
7
|
import { DEFAULT_RESERVATION_CONCURRENCY, RELAY_TAG, RELAY_V2_HOP_CODEC } from '../constants.js'
|
|
5
|
-
import { logger } from '@libp2p/logger'
|
|
6
|
-
import { pbStream } from 'it-pb-stream'
|
|
7
|
-
import type { ConnectionManager } from '@libp2p/interface-connection-manager'
|
|
8
|
-
import type { Connection } from '@libp2p/interface-connection'
|
|
9
|
-
import type { Reservation } from '../pb/index.js'
|
|
10
8
|
import { HopMessage, Status } from '../pb/index.js'
|
|
11
9
|
import { getExpirationMilliseconds } from '../utils.js'
|
|
10
|
+
import type { Reservation } from '../pb/index.js'
|
|
11
|
+
import type { Connection } from '@libp2p/interface-connection'
|
|
12
|
+
import type { ConnectionManager } from '@libp2p/interface-connection-manager'
|
|
13
|
+
import type { Libp2pEvents } from '@libp2p/interface-libp2p'
|
|
14
|
+
import type { PeerId } from '@libp2p/interface-peer-id'
|
|
15
|
+
import type { PeerStore } from '@libp2p/interface-peer-store'
|
|
12
16
|
import type { TransportManager } from '@libp2p/interface-transport'
|
|
13
17
|
import type { Startable } from '@libp2p/interfaces/startable'
|
|
14
|
-
import { EventEmitter } from '@libp2p/interfaces/events'
|
|
15
|
-
import type { PeerStore } from '@libp2p/interface-peer-store'
|
|
16
|
-
import { multiaddr } from '@multiformats/multiaddr'
|
|
17
|
-
import type { Libp2pEvents } from '@libp2p/interface-libp2p'
|
|
18
18
|
|
|
19
19
|
const log = logger('libp2p:circuit-relay:transport:reservation-store')
|
|
20
20
|
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
+
import { logger } from '@libp2p/logger'
|
|
2
|
+
import { abortableSource } from 'abortable-iterator'
|
|
3
|
+
import { anySignal } from 'any-signal'
|
|
1
4
|
import { CID } from 'multiformats/cid'
|
|
2
5
|
import { sha256 } from 'multiformats/hashes/sha2'
|
|
3
|
-
import
|
|
4
|
-
import type { Uint8ArrayList } from 'uint8arraylist'
|
|
6
|
+
import { DEFAULT_DATA_LIMIT, DEFAULT_DURATION_LIMIT } from './constants.js'
|
|
5
7
|
import type { Limit } from './pb/index.js'
|
|
6
|
-
import { logger } from '@libp2p/logger'
|
|
7
8
|
import type { Stream } from '@libp2p/interface-connection'
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import { anySignal } from 'any-signal'
|
|
9
|
+
import type { Source } from 'it-stream-types'
|
|
10
|
+
import type { Uint8ArrayList } from 'uint8arraylist'
|
|
11
11
|
|
|
12
12
|
const log = logger('libp2p:circuit-relay:utils')
|
|
13
13
|
|
package/src/components.ts
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import { CodeError } from '@libp2p/interfaces/errors'
|
|
2
|
+
import { isStartable, type Startable } from '@libp2p/interfaces/startable'
|
|
3
|
+
import type { AddressManager } from '@libp2p/interface-address-manager'
|
|
2
4
|
import type { ConnectionProtector } from '@libp2p/interface-connection'
|
|
5
|
+
import type { ConnectionGater } from '@libp2p/interface-connection-gater'
|
|
6
|
+
import type { ConnectionManager } from '@libp2p/interface-connection-manager'
|
|
3
7
|
import type { ContentRouting } from '@libp2p/interface-content-routing'
|
|
4
|
-
import type {
|
|
5
|
-
import { isStartable, Startable } from '@libp2p/interfaces/startable'
|
|
8
|
+
import type { Libp2pEvents } from '@libp2p/interface-libp2p'
|
|
6
9
|
import type { Metrics } from '@libp2p/interface-metrics'
|
|
7
10
|
import type { PeerId } from '@libp2p/interface-peer-id'
|
|
8
11
|
import type { PeerRouting } from '@libp2p/interface-peer-routing'
|
|
9
12
|
import type { PeerStore } from '@libp2p/interface-peer-store'
|
|
10
13
|
import type { Registrar } from '@libp2p/interface-registrar'
|
|
11
14
|
import type { TransportManager, Upgrader } from '@libp2p/interface-transport'
|
|
12
|
-
import type { Datastore } from 'interface-datastore'
|
|
13
|
-
import type { ConnectionManager } from '@libp2p/interface-connection-manager'
|
|
14
|
-
import type { ConnectionGater } from '@libp2p/interface-connection-gater'
|
|
15
|
-
import type { Libp2pEvents } from '@libp2p/interface-libp2p'
|
|
16
15
|
import type { EventEmitter } from '@libp2p/interfaces/events'
|
|
16
|
+
import type { Datastore } from 'interface-datastore'
|
|
17
17
|
|
|
18
18
|
export interface Components extends Record<string, any>, Startable {
|
|
19
19
|
peerId: PeerId
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import isPrivate from 'private-ip'
|
|
1
2
|
import type { ConnectionGater } from '@libp2p/interface-connection-gater'
|
|
2
3
|
import type { Multiaddr } from '@multiformats/multiaddr'
|
|
3
|
-
import isPrivate from 'private-ip'
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Returns a connection gater that disallows dialling private addresses by
|