libp2p 0.45.0 → 0.45.1
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 +13 -4
- 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.js +1 -1
- package/dist/typedoc-urls.json +2 -0
- package/package.json +6 -7
- package/src/address-manager/index.ts +6 -6
- package/src/autonat/index.ts +14 -14
- 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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "libp2p",
|
|
3
|
-
"version": "0.45.
|
|
3
|
+
"version": "0.45.1",
|
|
4
4
|
"description": "JavaScript implementation of libp2p, a modular peer to peer network stack",
|
|
5
5
|
"license": "Apache-2.0 OR MIT",
|
|
6
6
|
"homepage": "https://github.com/libp2p/js-libp2p#readme",
|
|
@@ -134,7 +134,7 @@
|
|
|
134
134
|
"@libp2p/interface-peer-id": "^2.0.1",
|
|
135
135
|
"@libp2p/interface-peer-info": "^1.0.3",
|
|
136
136
|
"@libp2p/interface-peer-routing": "^1.1.0",
|
|
137
|
-
"@libp2p/interface-peer-store": "^2.0.
|
|
137
|
+
"@libp2p/interface-peer-store": "^2.0.3",
|
|
138
138
|
"@libp2p/interface-pubsub": "^4.0.0",
|
|
139
139
|
"@libp2p/interface-record": "^2.0.6",
|
|
140
140
|
"@libp2p/interface-registrar": "^2.0.3",
|
|
@@ -148,7 +148,7 @@
|
|
|
148
148
|
"@libp2p/peer-id": "^2.0.0",
|
|
149
149
|
"@libp2p/peer-id-factory": "^2.0.0",
|
|
150
150
|
"@libp2p/peer-record": "^5.0.0",
|
|
151
|
-
"@libp2p/peer-store": "^8.
|
|
151
|
+
"@libp2p/peer-store": "^8.1.0",
|
|
152
152
|
"@libp2p/topology": "^4.0.1",
|
|
153
153
|
"@libp2p/tracked-map": "^3.0.0",
|
|
154
154
|
"@libp2p/utils": "^3.0.10",
|
|
@@ -179,15 +179,14 @@
|
|
|
179
179
|
"private-ip": "^3.0.0",
|
|
180
180
|
"protons-runtime": "^5.0.0",
|
|
181
181
|
"rate-limiter-flexible": "^2.3.11",
|
|
182
|
-
"set-delayed-interval": "^1.0.0",
|
|
183
182
|
"uint8arraylist": "^2.3.2",
|
|
184
183
|
"uint8arrays": "^4.0.2",
|
|
185
184
|
"wherearewe": "^2.0.0",
|
|
186
185
|
"xsalsa20": "^1.1.0"
|
|
187
186
|
},
|
|
188
187
|
"devDependencies": {
|
|
189
|
-
"@chainsafe/libp2p-gossipsub": "^
|
|
190
|
-
"@chainsafe/libp2p-noise": "^
|
|
188
|
+
"@chainsafe/libp2p-gossipsub": "^8.0.0",
|
|
189
|
+
"@chainsafe/libp2p-noise": "^12.0.0",
|
|
191
190
|
"@chainsafe/libp2p-yamux": "^4.0.1",
|
|
192
191
|
"@libp2p/bootstrap": "^8.0.0",
|
|
193
192
|
"@libp2p/daemon-client": "^6.0.2",
|
|
@@ -206,7 +205,7 @@
|
|
|
206
205
|
"@libp2p/websockets": "^6.0.1",
|
|
207
206
|
"@types/varint": "^6.0.0",
|
|
208
207
|
"@types/xsalsa20": "^1.1.0",
|
|
209
|
-
"aegir": "^
|
|
208
|
+
"aegir": "^39.0.5",
|
|
210
209
|
"cborg": "^1.8.1",
|
|
211
210
|
"delay": "^5.0.0",
|
|
212
211
|
"execa": "^7.0.0",
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { multiaddr } from '@multiformats/multiaddr'
|
|
1
|
+
import { logger } from '@libp2p/logger'
|
|
3
2
|
import { peerIdFromString } from '@libp2p/peer-id'
|
|
3
|
+
import { multiaddr } from '@multiformats/multiaddr'
|
|
4
|
+
import { debounce } from './utils.js'
|
|
5
|
+
import type { Libp2pEvents } from '@libp2p/interface-libp2p'
|
|
4
6
|
import type { PeerId } from '@libp2p/interface-peer-id'
|
|
5
|
-
import type { TransportManager } from '@libp2p/interface-transport'
|
|
6
7
|
import type { PeerStore } from '@libp2p/interface-peer-store'
|
|
7
|
-
import {
|
|
8
|
+
import type { TransportManager } from '@libp2p/interface-transport'
|
|
8
9
|
import type { EventEmitter } from '@libp2p/interfaces/dist/src/events'
|
|
9
|
-
import type {
|
|
10
|
-
import { debounce } from './utils.js'
|
|
10
|
+
import type { Multiaddr } from '@multiformats/multiaddr'
|
|
11
11
|
|
|
12
12
|
const log = logger('libp2p:address-manager')
|
|
13
13
|
|
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
|
|
|
@@ -452,7 +452,7 @@ 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
458
|
log('No response received from %s', connection.remotePeer)
|
|
@@ -497,7 +497,7 @@ class DefaultAutoNATService implements Startable {
|
|
|
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 {
|
|
@@ -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
|
package/src/config.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import mergeOptions from 'merge-options'
|
|
2
|
-
import { dnsaddrResolver } from '@multiformats/multiaddr/resolvers'
|
|
3
|
-
import { publicAddressesFirst } from '@libp2p/utils/address-sort'
|
|
4
1
|
import { FaultTolerance } from '@libp2p/interface-transport'
|
|
5
|
-
import type { Multiaddr } from '@multiformats/multiaddr'
|
|
6
|
-
import type { Libp2pInit } from './index.js'
|
|
7
|
-
import { codes, messages } from './errors.js'
|
|
8
2
|
import { CodeError } from '@libp2p/interfaces/errors'
|
|
9
|
-
import
|
|
3
|
+
import { publicAddressesFirst } from '@libp2p/utils/address-sort'
|
|
4
|
+
import { dnsaddrResolver } from '@multiformats/multiaddr/resolvers'
|
|
5
|
+
import mergeOptions from 'merge-options'
|
|
6
|
+
import { codes, messages } from './errors.js'
|
|
7
|
+
import type { Libp2pInit } from './index.js'
|
|
10
8
|
import type { ServiceMap } from '@libp2p/interface-libp2p'
|
|
9
|
+
import type { RecursivePartial } from '@libp2p/interfaces'
|
|
10
|
+
import type { Multiaddr } from '@multiformats/multiaddr'
|
|
11
11
|
|
|
12
12
|
const DefaultConfig: Partial<Libp2pInit> = {
|
|
13
13
|
addresses: {
|
|
@@ -27,17 +27,13 @@ const DefaultConfig: Partial<Libp2pInit> = {
|
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
export function validateConfig <T extends ServiceMap =
|
|
30
|
+
export function validateConfig <T extends ServiceMap = Record<string, unknown>> (opts: RecursivePartial<Libp2pInit<T>>): Libp2pInit<T> {
|
|
31
31
|
const resultingOptions: Libp2pInit<T> = mergeOptions(DefaultConfig, opts)
|
|
32
32
|
|
|
33
33
|
if (resultingOptions.transports == null || resultingOptions.transports.length < 1) {
|
|
34
34
|
throw new CodeError(messages.ERR_TRANSPORTS_REQUIRED, codes.ERR_TRANSPORTS_REQUIRED)
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
if (resultingOptions.connectionEncryption == null || resultingOptions.connectionEncryption.length === 0) {
|
|
38
|
-
throw new CodeError(messages.CONN_ENCRYPTION_REQUIRED, codes.CONN_ENCRYPTION_REQUIRED)
|
|
39
|
-
}
|
|
40
|
-
|
|
41
37
|
if (resultingOptions.connectionProtector === null && globalThis.process?.env?.LIBP2P_FORCE_PNET != null) { // eslint-disable-line no-undef
|
|
42
38
|
throw new CodeError(messages.ERR_PROTECTOR_REQUIRED, codes.ERR_PROTECTOR_REQUIRED)
|
|
43
39
|
}
|
package/src/connection/index.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import type { Multiaddr } from '@multiformats/multiaddr'
|
|
2
|
-
import { CodeError } from '@libp2p/interfaces/errors'
|
|
3
|
-
import { OPEN, CLOSING, CLOSED } from '@libp2p/interface-connection/status'
|
|
4
1
|
import { symbol } from '@libp2p/interface-connection'
|
|
2
|
+
import { OPEN, CLOSING, CLOSED } from '@libp2p/interface-connection/status'
|
|
3
|
+
import { CodeError } from '@libp2p/interfaces/errors'
|
|
4
|
+
import { logger } from '@libp2p/logger'
|
|
5
5
|
import type { Connection, ConnectionStat, Stream } from '@libp2p/interface-connection'
|
|
6
6
|
import type { PeerId } from '@libp2p/interface-peer-id'
|
|
7
|
-
import { logger } from '@libp2p/logger'
|
|
8
7
|
import type { AbortOptions } from '@libp2p/interfaces'
|
|
8
|
+
import type { Multiaddr } from '@multiformats/multiaddr'
|
|
9
9
|
|
|
10
10
|
const log = logger('libp2p:connection')
|
|
11
11
|
|
|
@@ -87,13 +87,9 @@ export class ConnectionImpl implements Connection {
|
|
|
87
87
|
this._closing = false
|
|
88
88
|
}
|
|
89
89
|
|
|
90
|
-
|
|
91
|
-
return 'Connection'
|
|
92
|
-
}
|
|
90
|
+
readonly [Symbol.toStringTag] = 'Connection'
|
|
93
91
|
|
|
94
|
-
|
|
95
|
-
return true
|
|
96
|
-
}
|
|
92
|
+
readonly [symbol] = true
|
|
97
93
|
|
|
98
94
|
/**
|
|
99
95
|
* Get all the streams of the muxer
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { logger } from '@libp2p/logger'
|
|
2
|
-
import type { PeerStore } from '@libp2p/interface-peer-store'
|
|
3
|
-
import type { ConnectionManager } from '@libp2p/interface-connection-manager'
|
|
4
2
|
import { PeerMap, PeerSet } from '@libp2p/peer-collections'
|
|
5
3
|
import PQueue from 'p-queue'
|
|
6
4
|
import { AUTO_DIAL_CONCURRENCY, AUTO_DIAL_INTERVAL, AUTO_DIAL_PRIORITY, MIN_CONNECTIONS } from './constants.js'
|
|
7
|
-
import type {
|
|
8
|
-
import type { EventEmitter } from '@libp2p/interfaces/events'
|
|
5
|
+
import type { ConnectionManager } from '@libp2p/interface-connection-manager'
|
|
9
6
|
import type { Libp2pEvents } from '@libp2p/interface-libp2p'
|
|
7
|
+
import type { PeerStore } from '@libp2p/interface-peer-store'
|
|
8
|
+
import type { EventEmitter } from '@libp2p/interfaces/events'
|
|
9
|
+
import type { Startable } from '@libp2p/interfaces/startable'
|
|
10
10
|
|
|
11
11
|
const log = logger('libp2p:connection-manager:auto-dial')
|
|
12
12
|
|
|
@@ -112,7 +112,7 @@ export class AutoDial implements Startable {
|
|
|
112
112
|
|
|
113
113
|
// Already has enough connections
|
|
114
114
|
if (numConnections >= this.minConnections) {
|
|
115
|
-
log('have enough connections %d/%d', numConnections, this.minConnections)
|
|
115
|
+
log.trace('have enough connections %d/%d', numConnections, this.minConnections)
|
|
116
116
|
return
|
|
117
117
|
}
|
|
118
118
|
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { logger } from '@libp2p/logger'
|
|
2
|
-
import type { ConnectionManager } from '@libp2p/interface-connection-manager'
|
|
3
|
-
import type { PeerStore } from '@libp2p/interface-peer-store'
|
|
4
2
|
import { PeerMap } from '@libp2p/peer-collections'
|
|
5
|
-
import type { Multiaddr } from '@multiformats/multiaddr'
|
|
6
3
|
import { MAX_CONNECTIONS } from './constants.js'
|
|
7
|
-
import type {
|
|
4
|
+
import type { ConnectionManager } from '@libp2p/interface-connection-manager'
|
|
8
5
|
import type { Libp2pEvents } from '@libp2p/interface-libp2p'
|
|
6
|
+
import type { PeerStore } from '@libp2p/interface-peer-store'
|
|
7
|
+
import type { EventEmitter } from '@libp2p/interfaces/events'
|
|
8
|
+
import type { Multiaddr } from '@multiformats/multiaddr'
|
|
9
9
|
|
|
10
10
|
const log = logger('libp2p:connection-manager:connection-pruner')
|
|
11
11
|
|