libp2p 3.2.0 → 3.2.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/dist/index.min.js +15 -18
- package/dist/index.min.js.map +4 -4
- package/dist/src/address-manager/dns-mappings.d.ts +1 -1
- package/dist/src/address-manager/index.js +4 -4
- package/dist/src/address-manager/ip-mappings.d.ts +1 -1
- package/dist/src/address-manager/observed-addresses.d.ts +1 -1
- package/dist/src/address-manager/transport-addresses.d.ts +1 -1
- package/dist/src/components.js +1 -1
- package/dist/src/config.d.ts +1 -1
- package/dist/src/connection-manager/connection-pruner.js +1 -1
- package/dist/src/connection-manager/constants.browser.d.ts +1 -1
- package/dist/src/connection-manager/constants.browser.js +1 -1
- package/dist/src/connection-manager/constants.d.ts +1 -1
- package/dist/src/connection-manager/constants.defaults.d.ts +4 -0
- package/dist/src/connection-manager/constants.defaults.d.ts.map +1 -1
- package/dist/src/connection-manager/constants.defaults.js +4 -0
- package/dist/src/connection-manager/constants.defaults.js.map +1 -1
- package/dist/src/connection-manager/constants.js +1 -1
- package/dist/src/connection-manager/dial-queue.d.ts +2 -0
- package/dist/src/connection-manager/dial-queue.d.ts.map +1 -1
- package/dist/src/connection-manager/dial-queue.js +21 -8
- package/dist/src/connection-manager/dial-queue.js.map +1 -1
- package/dist/src/connection-manager/index.d.ts +12 -3
- package/dist/src/connection-manager/index.d.ts.map +1 -1
- package/dist/src/connection-manager/index.js +6 -5
- package/dist/src/connection-manager/index.js.map +1 -1
- package/dist/src/connection-manager/reconnect-queue.js +1 -1
- package/dist/src/connection-manager/resolvers/index.d.ts +1 -1
- package/dist/src/connection-manager/resolvers/index.js +1 -1
- package/dist/src/content-routing.js +1 -1
- package/dist/src/index.d.ts +5 -5
- package/dist/src/index.js +2 -2
- package/dist/src/libp2p.d.ts +2 -2
- package/dist/src/libp2p.js +13 -13
- package/dist/src/peer-routing.js +1 -1
- package/dist/src/registrar.js +1 -1
- package/dist/src/transport-manager.js +1 -1
- package/dist/src/upgrader.js +3 -3
- package/dist/src/user-agent.browser.js +1 -1
- package/dist/src/user-agent.js +1 -1
- package/dist/src/user-agent.react-native.js +1 -1
- package/dist/src/version.d.ts +1 -1
- package/dist/src/version.js +1 -1
- package/package.json +17 -14
- package/src/address-manager/dns-mappings.ts +1 -1
- package/src/address-manager/index.ts +4 -4
- package/src/address-manager/ip-mappings.ts +1 -1
- package/src/address-manager/observed-addresses.ts +1 -1
- package/src/address-manager/transport-addresses.ts +1 -1
- package/src/components.ts +1 -1
- package/src/config.ts +1 -1
- package/src/connection-manager/connection-pruner.ts +1 -1
- package/src/connection-manager/constants.browser.ts +1 -1
- package/src/connection-manager/constants.defaults.ts +5 -0
- package/src/connection-manager/constants.ts +1 -1
- package/src/connection-manager/dial-queue.ts +23 -8
- package/src/connection-manager/index.ts +16 -5
- package/src/connection-manager/reconnect-queue.ts +1 -1
- package/src/connection-manager/resolvers/index.ts +1 -1
- package/src/content-routing.ts +1 -1
- package/src/index.ts +7 -7
- package/src/libp2p.ts +15 -15
- package/src/peer-routing.ts +1 -1
- package/src/registrar.ts +1 -1
- package/src/transport-manager.ts +1 -1
- package/src/upgrader.ts +3 -3
- package/src/user-agent.browser.ts +1 -1
- package/src/user-agent.react-native.ts +1 -1
- package/src/user-agent.ts +1 -1
- package/src/version.ts +1 -1
package/dist/src/registrar.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { InvalidParametersError } from '@libp2p/interface';
|
|
2
2
|
import { trackedMap } from '@libp2p/utils';
|
|
3
|
-
import { DuplicateProtocolHandlerError, UnhandledProtocolError } from
|
|
3
|
+
import { DuplicateProtocolHandlerError, UnhandledProtocolError } from "./errors.js";
|
|
4
4
|
export const DEFAULT_MAX_INBOUND_STREAMS = 32;
|
|
5
5
|
export const DEFAULT_MAX_OUTBOUND_STREAMS = 64;
|
|
6
6
|
/**
|
|
@@ -2,7 +2,7 @@ import { FaultTolerance, InvalidParametersError, NotStartedError } from '@libp2p
|
|
|
2
2
|
import { trackedMap } from '@libp2p/utils';
|
|
3
3
|
import { IP4, IP6 } from '@multiformats/multiaddr-matcher';
|
|
4
4
|
import { CustomProgressEvent } from 'progress-events';
|
|
5
|
-
import { TransportUnavailableError, UnsupportedListenAddressError, UnsupportedListenAddressesError } from
|
|
5
|
+
import { TransportUnavailableError, UnsupportedListenAddressError, UnsupportedListenAddressesError } from "./errors.js";
|
|
6
6
|
export class DefaultTransportManager {
|
|
7
7
|
log;
|
|
8
8
|
components;
|
package/dist/src/upgrader.js
CHANGED
|
@@ -7,9 +7,9 @@ import { anySignal } from 'any-signal';
|
|
|
7
7
|
import { setMaxListeners } from 'main-event';
|
|
8
8
|
import { CustomProgressEvent } from 'progress-events';
|
|
9
9
|
import { raceSignal } from 'race-signal';
|
|
10
|
-
import { PROTOCOL_NEGOTIATION_TIMEOUT, INBOUND_UPGRADE_TIMEOUT, CONNECTION_CLOSE_TIMEOUT } from
|
|
11
|
-
import { createConnection } from
|
|
12
|
-
import { ConnectionDeniedError, ConnectionInterceptedError, EncryptionFailedError, MuxerUnavailableError } from
|
|
10
|
+
import { PROTOCOL_NEGOTIATION_TIMEOUT, INBOUND_UPGRADE_TIMEOUT, CONNECTION_CLOSE_TIMEOUT } from "./connection-manager/constants.js";
|
|
11
|
+
import { createConnection } from "./connection.js";
|
|
12
|
+
import { ConnectionDeniedError, ConnectionInterceptedError, EncryptionFailedError, MuxerUnavailableError } from "./errors.js";
|
|
13
13
|
export class Upgrader {
|
|
14
14
|
components;
|
|
15
15
|
connectionEncrypters;
|
package/dist/src/user-agent.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Platform } from 'react-native';
|
|
2
|
-
import * as pkg from
|
|
2
|
+
import * as pkg from "./version.js";
|
|
3
3
|
export function userAgent(name, version) {
|
|
4
4
|
return `${name ?? pkg.name}/${version ?? pkg.version} react-native/${Platform.OS}-${`${Platform.Version}`.replaceAll('v', '')}`;
|
|
5
5
|
}
|
package/dist/src/version.d.ts
CHANGED
package/dist/src/version.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "libp2p",
|
|
3
|
-
"version": "3.2.
|
|
3
|
+
"version": "3.2.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/tree/main/packages/libp2p#readme",
|
|
@@ -50,16 +50,19 @@
|
|
|
50
50
|
"exports": {
|
|
51
51
|
".": {
|
|
52
52
|
"types": "./dist/src/index.d.ts",
|
|
53
|
-
"import": "./dist/src/index.js"
|
|
53
|
+
"import": "./dist/src/index.js",
|
|
54
|
+
"module-sync": "./dist/src/index.js"
|
|
54
55
|
},
|
|
55
56
|
"./user-agent": {
|
|
56
57
|
"types": "./dist/src/user-agent.d.ts",
|
|
57
58
|
"browser": "./dist/src/user-agent.browser.js",
|
|
58
|
-
"import": "./dist/src/user-agent.js"
|
|
59
|
+
"import": "./dist/src/user-agent.js",
|
|
60
|
+
"module-sync": "./dist/src/user-agent.js"
|
|
59
61
|
},
|
|
60
62
|
"./version": {
|
|
61
63
|
"types": "./dist/src/version.d.ts",
|
|
62
|
-
"import": "./dist/src/version.js"
|
|
64
|
+
"import": "./dist/src/version.js",
|
|
65
|
+
"module-sync": "./dist/src/version.js"
|
|
63
66
|
}
|
|
64
67
|
},
|
|
65
68
|
"scripts": {
|
|
@@ -80,15 +83,15 @@
|
|
|
80
83
|
"dependencies": {
|
|
81
84
|
"@chainsafe/is-ip": "^2.1.0",
|
|
82
85
|
"@chainsafe/netmask": "^2.0.0",
|
|
83
|
-
"@libp2p/crypto": "^5.1.
|
|
84
|
-
"@libp2p/interface": "^3.2.
|
|
85
|
-
"@libp2p/interface-internal": "^3.1.
|
|
86
|
-
"@libp2p/logger": "^6.2.
|
|
87
|
-
"@libp2p/multistream-select": "^7.0.
|
|
88
|
-
"@libp2p/peer-collections": "^7.0.
|
|
89
|
-
"@libp2p/peer-id": "^6.0.
|
|
90
|
-
"@libp2p/peer-store": "^12.0.
|
|
91
|
-
"@libp2p/utils": "^7.0.
|
|
86
|
+
"@libp2p/crypto": "^5.1.16",
|
|
87
|
+
"@libp2p/interface": "^3.2.1",
|
|
88
|
+
"@libp2p/interface-internal": "^3.1.1",
|
|
89
|
+
"@libp2p/logger": "^6.2.5",
|
|
90
|
+
"@libp2p/multistream-select": "^7.0.16",
|
|
91
|
+
"@libp2p/peer-collections": "^7.0.16",
|
|
92
|
+
"@libp2p/peer-id": "^6.0.7",
|
|
93
|
+
"@libp2p/peer-store": "^12.0.16",
|
|
94
|
+
"@libp2p/utils": "^7.0.16",
|
|
92
95
|
"@multiformats/dns": "^1.0.6",
|
|
93
96
|
"@multiformats/multiaddr": "^13.0.1",
|
|
94
97
|
"@multiformats/multiaddr-matcher": "^3.0.1",
|
|
@@ -101,7 +104,7 @@
|
|
|
101
104
|
"multiformats": "^13.4.0",
|
|
102
105
|
"p-defer": "^4.0.1",
|
|
103
106
|
"p-event": "^7.0.0",
|
|
104
|
-
"p-retry": "^
|
|
107
|
+
"p-retry": "^8.0.0",
|
|
105
108
|
"progress-events": "^1.1.0",
|
|
106
109
|
"race-signal": "^2.0.0",
|
|
107
110
|
"uint8arrays": "^5.1.0"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { getNetConfig, isNetworkAddress, isPrivateIp, trackedMap } from '@libp2p/utils'
|
|
2
2
|
import { CODE_SNI, CODE_TLS, multiaddr } from '@multiformats/multiaddr'
|
|
3
|
-
import type { AddressManagerComponents, AddressManagerInit } from './index.
|
|
3
|
+
import type { AddressManagerComponents, AddressManagerInit } from './index.ts'
|
|
4
4
|
import type { Logger } from '@libp2p/interface'
|
|
5
5
|
import type { NodeAddress } from '@libp2p/interface-internal'
|
|
6
6
|
import type { Multiaddr } from '@multiformats/multiaddr'
|
|
@@ -4,10 +4,10 @@ import { peerIdFromString } from '@libp2p/peer-id'
|
|
|
4
4
|
import { debounce, createScalableCuckooFilter, isPrivateIp, getNetConfig, isNetworkAddress, isLoopback } from '@libp2p/utils'
|
|
5
5
|
import { CODE_P2P, multiaddr } from '@multiformats/multiaddr'
|
|
6
6
|
import { QUIC_V1, TCP, WebSockets, WebSocketsSecure } from '@multiformats/multiaddr-matcher'
|
|
7
|
-
import { DNSMappings } from './dns-mappings.
|
|
8
|
-
import { IPMappings } from './ip-mappings.
|
|
9
|
-
import { ObservedAddresses } from './observed-addresses.
|
|
10
|
-
import { TransportAddresses } from './transport-addresses.
|
|
7
|
+
import { DNSMappings } from './dns-mappings.ts'
|
|
8
|
+
import { IPMappings } from './ip-mappings.ts'
|
|
9
|
+
import { ObservedAddresses } from './observed-addresses.ts'
|
|
10
|
+
import { TransportAddresses } from './transport-addresses.ts'
|
|
11
11
|
import type { ComponentLogger, Libp2pEvents, Logger, PeerId, PeerStore, Metrics } from '@libp2p/interface'
|
|
12
12
|
import type { AddressManager as AddressManagerInterface, TransportManager, NodeAddress, ConfirmAddressOptions } from '@libp2p/interface-internal'
|
|
13
13
|
import type { Filter } from '@libp2p/utils'
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { isIPv4 } from '@chainsafe/is-ip'
|
|
2
2
|
import { getNetConfig, isNetworkAddress, trackedMap } from '@libp2p/utils'
|
|
3
3
|
import { CODE_IP4, CODE_IP6, multiaddr } from '@multiformats/multiaddr'
|
|
4
|
-
import type { AddressManagerComponents, AddressManagerInit } from './index.
|
|
4
|
+
import type { AddressManagerComponents, AddressManagerInit } from './index.ts'
|
|
5
5
|
import type { Logger } from '@libp2p/interface'
|
|
6
6
|
import type { NodeAddress } from '@libp2p/interface-internal'
|
|
7
7
|
import type { Multiaddr } from '@multiformats/multiaddr'
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { isLinkLocal, isPrivate, trackedMap } from '@libp2p/utils'
|
|
2
2
|
import { multiaddr } from '@multiformats/multiaddr'
|
|
3
|
-
import type { AddressManagerComponents, AddressManagerInit } from './index.
|
|
3
|
+
import type { AddressManagerComponents, AddressManagerInit } from './index.ts'
|
|
4
4
|
import type { Logger } from '@libp2p/interface'
|
|
5
5
|
import type { NodeAddress } from '@libp2p/interface-internal'
|
|
6
6
|
import type { Multiaddr } from '@multiformats/multiaddr'
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getNetConfig, isNetworkAddress, isPrivate, trackedMap } from '@libp2p/utils'
|
|
2
|
-
import type { AddressManagerComponents, AddressManagerInit } from './index.
|
|
2
|
+
import type { AddressManagerComponents, AddressManagerInit } from './index.ts'
|
|
3
3
|
import type { Logger } from '@libp2p/interface'
|
|
4
4
|
import type { NodeAddress } from '@libp2p/interface-internal'
|
|
5
5
|
import type { Multiaddr } from '@multiformats/multiaddr'
|
package/src/components.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { serviceCapabilities, serviceDependencies, isStartable } from '@libp2p/interface'
|
|
2
2
|
import { defaultLogger } from '@libp2p/logger'
|
|
3
|
-
import { MissingServiceError, UnmetServiceDependenciesError } from './errors.
|
|
3
|
+
import { MissingServiceError, UnmetServiceDependenciesError } from './errors.ts'
|
|
4
4
|
import type { Startable, Libp2pEvents, ComponentLogger, NodeInfo, ConnectionProtector, ConnectionGater, ContentRouting, Metrics, PeerId, PeerRouting, PeerStore, PrivateKey, Upgrader } from '@libp2p/interface'
|
|
5
5
|
import type { AddressManager, ConnectionManager, RandomWalk, Registrar, TransportManager } from '@libp2p/interface-internal'
|
|
6
6
|
import type { DNS } from '@multiformats/dns'
|
package/src/config.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { InvalidParametersError } from '@libp2p/interface'
|
|
2
|
-
import type { Libp2pInit } from './index.
|
|
2
|
+
import type { Libp2pInit } from './index.ts'
|
|
3
3
|
import type { ServiceMap } from '@libp2p/interface'
|
|
4
4
|
|
|
5
5
|
export async function validateConfig <T extends ServiceMap = Record<string, unknown>> (opts: Libp2pInit<T>): Promise<Libp2pInit<T>> {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { PeerMap } from '@libp2p/peer-collections'
|
|
2
2
|
import { getNetConfig, isNetworkAddress } from '@libp2p/utils'
|
|
3
|
-
import { multiaddrToIpNet, safelyCloseConnectionIfUnused } from './utils.
|
|
3
|
+
import { multiaddrToIpNet, safelyCloseConnectionIfUnused } from './utils.ts'
|
|
4
4
|
import type { IpNet } from '@chainsafe/netmask'
|
|
5
5
|
import type { Libp2pEvents, Logger, ComponentLogger, PeerStore, Connection } from '@libp2p/interface'
|
|
6
6
|
import type { ConnectionManager } from '@libp2p/interface-internal'
|
|
@@ -3,6 +3,11 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export const DIAL_TIMEOUT = 10_000
|
|
5
5
|
|
|
6
|
+
/**
|
|
7
|
+
* @see https://libp2p.github.io/js-libp2p/interfaces/libp2p.index.ConnectionManagerInit.html#addressDialTimeout
|
|
8
|
+
*/
|
|
9
|
+
export const ADDRESS_DIAL_TIMEOUT = 6_000
|
|
10
|
+
|
|
6
11
|
/**
|
|
7
12
|
* @see https://libp2p.github.io/js-libp2p/interfaces/libp2p.index.ConnectionManagerInit.html#connectionCloseTimeout
|
|
8
13
|
*/
|
|
@@ -10,18 +10,19 @@ import { CustomProgressEvent } from 'progress-events'
|
|
|
10
10
|
import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string'
|
|
11
11
|
import { DialDeniedError, NoValidAddressesError } from '../errors.js'
|
|
12
12
|
import { getPeerAddress } from '../get-peer.js'
|
|
13
|
-
import { defaultAddressSorter } from './address-sorter.
|
|
13
|
+
import { defaultAddressSorter } from './address-sorter.ts'
|
|
14
14
|
import {
|
|
15
|
+
ADDRESS_DIAL_TIMEOUT,
|
|
15
16
|
DIAL_TIMEOUT,
|
|
16
17
|
MAX_PARALLEL_DIALS,
|
|
17
18
|
MAX_PEER_ADDRS_TO_DIAL,
|
|
18
19
|
LAST_DIAL_FAILURE_KEY,
|
|
19
20
|
MAX_DIAL_QUEUE_LENGTH,
|
|
20
21
|
LAST_DIAL_SUCCESS_KEY
|
|
21
|
-
} from './constants.
|
|
22
|
-
import {
|
|
22
|
+
} from './constants.ts'
|
|
23
|
+
import { DEFAULT_DIAL_PRIORITY } from './index.ts'
|
|
24
|
+
import { resolveMultiaddr, dnsaddrResolver } from './resolvers/index.ts'
|
|
23
25
|
import { findExistingConnection } from './utils.ts'
|
|
24
|
-
import { DEFAULT_DIAL_PRIORITY } from './index.js'
|
|
25
26
|
import type { AddressSorter, ComponentLogger, Logger, Connection, ConnectionGater, Metrics, PeerId, Address, PeerStore, PeerRouting, IsDialableOptions, OpenConnectionProgressEvents, MultiaddrResolver, DialTarget } from '@libp2p/interface'
|
|
26
27
|
import type { OpenConnectionOptions, TransportManager } from '@libp2p/interface-internal'
|
|
27
28
|
import type { PriorityQueueJobOptions } from '@libp2p/utils'
|
|
@@ -45,6 +46,7 @@ interface DialerInit {
|
|
|
45
46
|
maxDialQueueLength?: number
|
|
46
47
|
maxPeerAddrsToDial?: number
|
|
47
48
|
dialTimeout?: number
|
|
49
|
+
addressDialTimeout?: number
|
|
48
50
|
resolvers?: Record<string, MultiaddrResolver>
|
|
49
51
|
connections?: PeerMap<Connection[]>
|
|
50
52
|
}
|
|
@@ -54,6 +56,7 @@ const defaultOptions = {
|
|
|
54
56
|
maxDialQueueLength: MAX_DIAL_QUEUE_LENGTH,
|
|
55
57
|
maxPeerAddrsToDial: MAX_PEER_ADDRS_TO_DIAL,
|
|
56
58
|
dialTimeout: DIAL_TIMEOUT,
|
|
59
|
+
addressDialTimeout: ADDRESS_DIAL_TIMEOUT,
|
|
57
60
|
resolvers: {
|
|
58
61
|
dnsaddr: dnsaddrResolver
|
|
59
62
|
}
|
|
@@ -77,6 +80,7 @@ export class DialQueue {
|
|
|
77
80
|
private readonly maxPeerAddrsToDial: number
|
|
78
81
|
private readonly maxDialQueueLength: number
|
|
79
82
|
private readonly dialTimeout: number
|
|
83
|
+
private readonly addressDialTimeout: number
|
|
80
84
|
private shutDownController: AbortController
|
|
81
85
|
private readonly connections: PeerMap<Connection[]>
|
|
82
86
|
private readonly log: Logger
|
|
@@ -87,6 +91,7 @@ export class DialQueue {
|
|
|
87
91
|
this.maxPeerAddrsToDial = init.maxPeerAddrsToDial ?? defaultOptions.maxPeerAddrsToDial
|
|
88
92
|
this.maxDialQueueLength = init.maxDialQueueLength ?? defaultOptions.maxDialQueueLength
|
|
89
93
|
this.dialTimeout = init.dialTimeout ?? defaultOptions.dialTimeout
|
|
94
|
+
this.addressDialTimeout = init.addressDialTimeout ?? defaultOptions.addressDialTimeout
|
|
90
95
|
this.connections = init.connections ?? new PeerMap()
|
|
91
96
|
this.log = components.logger.forComponent('libp2p:connection-manager:dial-queue')
|
|
92
97
|
this.components = components
|
|
@@ -279,11 +284,17 @@ export class DialQueue {
|
|
|
279
284
|
|
|
280
285
|
dialed++
|
|
281
286
|
|
|
287
|
+
// create a per-address signal so a single slow/unreachable address
|
|
288
|
+
// cannot consume the entire dialTimeout budget when multiple addresses
|
|
289
|
+
// are available - the outer batch signal can still abort everything
|
|
290
|
+
const addressSignal = anySignal([signal, AbortSignal.timeout(this.addressDialTimeout)])
|
|
291
|
+
setMaxListeners(Infinity, addressSignal)
|
|
292
|
+
|
|
282
293
|
try {
|
|
283
294
|
// try to dial the address
|
|
284
295
|
const conn = await this.components.transportManager.dial(address.multiaddr, {
|
|
285
296
|
...options,
|
|
286
|
-
signal
|
|
297
|
+
signal: addressSignal
|
|
287
298
|
})
|
|
288
299
|
|
|
289
300
|
this.log('dial to %a succeeded', address.multiaddr)
|
|
@@ -323,12 +334,16 @@ export class DialQueue {
|
|
|
323
334
|
}
|
|
324
335
|
}
|
|
325
336
|
|
|
326
|
-
// the user/
|
|
337
|
+
// the user/batch timeout/shutdown controller signal aborted - stop
|
|
338
|
+
// trying further addresses for this peer
|
|
327
339
|
if (signal.aborted) {
|
|
328
340
|
throw new TimeoutError(err.message)
|
|
329
341
|
}
|
|
330
342
|
|
|
331
343
|
errors.push(err)
|
|
344
|
+
} finally {
|
|
345
|
+
// unregister listeners on parent signals immediately to avoid leaks
|
|
346
|
+
addressSignal.clear()
|
|
332
347
|
}
|
|
333
348
|
}
|
|
334
349
|
}
|
|
@@ -473,7 +488,7 @@ export class DialQueue {
|
|
|
473
488
|
|
|
474
489
|
// make sure we actually have some addresses to dial
|
|
475
490
|
if (dedupedMultiaddrs.length === 0) {
|
|
476
|
-
throw new NoValidAddressesError(
|
|
491
|
+
throw new NoValidAddressesError(`The dial request has no valid addresses for peer: ${peerId?.toString() ?? 'unknown peer'}`)
|
|
477
492
|
}
|
|
478
493
|
|
|
479
494
|
const gatedAddrs: Address[] = []
|
|
@@ -490,7 +505,7 @@ export class DialQueue {
|
|
|
490
505
|
|
|
491
506
|
// make sure we actually have some addresses to dial
|
|
492
507
|
if (sortedGatedAddrs.length === 0) {
|
|
493
|
-
throw new DialDeniedError(
|
|
508
|
+
throw new DialDeniedError(`The connection gater denied all addresses in the dial request for peer: ${peerId?.toString() ?? 'unknown peer'}`)
|
|
494
509
|
}
|
|
495
510
|
|
|
496
511
|
this.log.trace('addresses for %p before filtering', peerId ?? 'unknown peer', resolvedAddresses.map(({ multiaddr }) => multiaddr.toString()))
|
|
@@ -5,12 +5,12 @@ import { multiaddr } from '@multiformats/multiaddr'
|
|
|
5
5
|
import { pEvent } from 'p-event'
|
|
6
6
|
import { CustomProgressEvent } from 'progress-events'
|
|
7
7
|
import { getPeerAddress } from '../get-peer.js'
|
|
8
|
-
import { ConnectionPruner } from './connection-pruner.
|
|
9
|
-
import { DIAL_TIMEOUT, INBOUND_CONNECTION_THRESHOLD, MAX_CONNECTIONS, MAX_DIAL_QUEUE_LENGTH, MAX_INCOMING_PENDING_CONNECTIONS, MAX_PARALLEL_DIALS, MAX_PEER_ADDRS_TO_DIAL } from './constants.
|
|
10
|
-
import { DialQueue } from './dial-queue.
|
|
11
|
-
import { ReconnectQueue } from './reconnect-queue.
|
|
8
|
+
import { ConnectionPruner } from './connection-pruner.ts'
|
|
9
|
+
import { ADDRESS_DIAL_TIMEOUT, DIAL_TIMEOUT, INBOUND_CONNECTION_THRESHOLD, MAX_CONNECTIONS, MAX_DIAL_QUEUE_LENGTH, MAX_INCOMING_PENDING_CONNECTIONS, MAX_PARALLEL_DIALS, MAX_PEER_ADDRS_TO_DIAL } from './constants.ts'
|
|
10
|
+
import { DialQueue } from './dial-queue.ts'
|
|
11
|
+
import { ReconnectQueue } from './reconnect-queue.ts'
|
|
12
12
|
import { dnsaddrResolver } from './resolvers/index.ts'
|
|
13
|
-
import { findExistingConnection, multiaddrToIpNet } from './utils.
|
|
13
|
+
import { findExistingConnection, multiaddrToIpNet } from './utils.ts'
|
|
14
14
|
import type { IpNet } from '@chainsafe/netmask'
|
|
15
15
|
import type { PendingDial, AddressSorter, Libp2pEvents, AbortOptions, ComponentLogger, Logger, Connection, MultiaddrConnection, ConnectionGater, Metrics, PeerId, PeerStore, Startable, PendingDialStatus, PeerRouting, IsDialableOptions, MultiaddrResolver, Stream, NewStreamOptions, DialTarget } from '@libp2p/interface'
|
|
16
16
|
import type { ConnectionManager, OpenConnectionOptions, TransportManager } from '@libp2p/interface-internal'
|
|
@@ -66,6 +66,16 @@ export interface ConnectionManagerInit {
|
|
|
66
66
|
*/
|
|
67
67
|
dialTimeout?: number
|
|
68
68
|
|
|
69
|
+
/**
|
|
70
|
+
* How long a single address dial attempt is allowed to take before the
|
|
71
|
+
* dialer moves on to the next address. This prevents a single slow or
|
|
72
|
+
* unreachable address from consuming the entire `dialTimeout` budget when
|
|
73
|
+
* multiple addresses are available for a peer.
|
|
74
|
+
*
|
|
75
|
+
* @default 6_000
|
|
76
|
+
*/
|
|
77
|
+
addressDialTimeout?: number
|
|
78
|
+
|
|
69
79
|
/**
|
|
70
80
|
* How many ms to wait when closing a connection if an abort signal is not
|
|
71
81
|
* passed
|
|
@@ -261,6 +271,7 @@ export class DefaultConnectionManager implements ConnectionManager, Startable {
|
|
|
261
271
|
maxDialQueueLength: init.maxDialQueueLength ?? MAX_DIAL_QUEUE_LENGTH,
|
|
262
272
|
maxPeerAddrsToDial: init.maxPeerAddrsToDial ?? MAX_PEER_ADDRS_TO_DIAL,
|
|
263
273
|
dialTimeout: init.dialTimeout ?? DIAL_TIMEOUT,
|
|
274
|
+
addressDialTimeout: init.addressDialTimeout ?? ADDRESS_DIAL_TIMEOUT,
|
|
264
275
|
resolvers: init.resolvers ?? {
|
|
265
276
|
dnsaddr: dnsaddrResolver
|
|
266
277
|
},
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { KEEP_ALIVE } from '@libp2p/interface'
|
|
2
2
|
import { PeerQueue } from '@libp2p/utils'
|
|
3
3
|
import pRetry from 'p-retry'
|
|
4
|
-
import { MAX_PARALLEL_RECONNECTS } from './constants.
|
|
4
|
+
import { MAX_PARALLEL_RECONNECTS } from './constants.ts'
|
|
5
5
|
import type { ComponentLogger, Libp2pEvents, Logger, Metrics, Peer, PeerId, PeerStore, Startable } from '@libp2p/interface'
|
|
6
6
|
import type { ConnectionManager } from '@libp2p/interface-internal'
|
|
7
7
|
import type { TypedEventTarget } from 'main-event'
|
package/src/content-routing.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { NotStartedError } from '@libp2p/interface'
|
|
|
2
2
|
import { PeerSet } from '@libp2p/peer-collections'
|
|
3
3
|
import merge from 'it-merge'
|
|
4
4
|
import { toString as uint8ArrayToString } from 'uint8arrays/to-string'
|
|
5
|
-
import { NoContentRoutersError } from './errors.
|
|
5
|
+
import { NoContentRoutersError } from './errors.ts'
|
|
6
6
|
import type { AbortOptions, ComponentLogger, ContentRouting, Metrics, PeerRouting, PeerStore, Provider, RoutingOptions, Startable } from '@libp2p/interface'
|
|
7
7
|
import type { CID } from 'multiformats/cid'
|
|
8
8
|
|
package/src/index.ts
CHANGED
|
@@ -16,13 +16,13 @@
|
|
|
16
16
|
|
|
17
17
|
import { generateKeyPair } from '@libp2p/crypto/keys'
|
|
18
18
|
import { peerIdFromPrivateKey } from '@libp2p/peer-id'
|
|
19
|
-
import { validateConfig } from './config.
|
|
20
|
-
import { Libp2p as Libp2pClass } from './libp2p.
|
|
21
|
-
import type { AddressManagerInit, AddressFilter } from './address-manager/index.
|
|
22
|
-
import type { Components } from './components.
|
|
23
|
-
import type { ConnectionManagerInit } from './connection-manager/index.
|
|
24
|
-
import type { ConnectionMonitorInit } from './connection-monitor.
|
|
25
|
-
import type { TransportManagerInit } from './transport-manager.
|
|
19
|
+
import { validateConfig } from './config.ts'
|
|
20
|
+
import { Libp2p as Libp2pClass } from './libp2p.ts'
|
|
21
|
+
import type { AddressManagerInit, AddressFilter } from './address-manager/index.ts'
|
|
22
|
+
import type { Components } from './components.ts'
|
|
23
|
+
import type { ConnectionManagerInit } from './connection-manager/index.ts'
|
|
24
|
+
import type { ConnectionMonitorInit } from './connection-monitor.ts'
|
|
25
|
+
import type { TransportManagerInit } from './transport-manager.ts'
|
|
26
26
|
import type { Libp2p, ServiceMap, ComponentLogger, NodeInfo, ConnectionProtector, ConnectionEncrypter, ConnectionGater, ContentRouting, Metrics, PeerDiscovery, PeerRouting, StreamMuxerFactory, Transport, PrivateKey } from '@libp2p/interface'
|
|
27
27
|
import type { PersistentPeerStoreInit } from '@libp2p/peer-store'
|
|
28
28
|
import type { DNS } from '@multiformats/dns'
|
package/src/libp2p.ts
CHANGED
|
@@ -9,21 +9,21 @@ import { MemoryDatastore } from 'datastore-core/memory'
|
|
|
9
9
|
import { TypedEventEmitter, setMaxListeners } from 'main-event'
|
|
10
10
|
import { concat as uint8ArrayConcat } from 'uint8arrays/concat'
|
|
11
11
|
import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string'
|
|
12
|
-
import { AddressManager } from './address-manager/index.
|
|
13
|
-
import { checkServiceDependencies, defaultComponents } from './components.
|
|
14
|
-
import { connectionGater } from './config/connection-gater.
|
|
15
|
-
import { DefaultConnectionManager } from './connection-manager/index.
|
|
16
|
-
import { ConnectionMonitor } from './connection-monitor.
|
|
17
|
-
import { CompoundContentRouting } from './content-routing.
|
|
18
|
-
import { DefaultPeerRouting } from './peer-routing.
|
|
19
|
-
import { RandomWalk } from './random-walk.
|
|
20
|
-
import { Registrar } from './registrar.
|
|
21
|
-
import { DefaultTransportManager } from './transport-manager.
|
|
22
|
-
import { Upgrader } from './upgrader.
|
|
23
|
-
import { userAgent } from './user-agent.
|
|
24
|
-
import * as pkg from './version.
|
|
25
|
-
import type { Components } from './components.
|
|
26
|
-
import type { Libp2p as Libp2pInterface, Libp2pInit } from './index.
|
|
12
|
+
import { AddressManager } from './address-manager/index.ts'
|
|
13
|
+
import { checkServiceDependencies, defaultComponents } from './components.ts'
|
|
14
|
+
import { connectionGater } from './config/connection-gater.ts'
|
|
15
|
+
import { DefaultConnectionManager } from './connection-manager/index.ts'
|
|
16
|
+
import { ConnectionMonitor } from './connection-monitor.ts'
|
|
17
|
+
import { CompoundContentRouting } from './content-routing.ts'
|
|
18
|
+
import { DefaultPeerRouting } from './peer-routing.ts'
|
|
19
|
+
import { RandomWalk } from './random-walk.ts'
|
|
20
|
+
import { Registrar } from './registrar.ts'
|
|
21
|
+
import { DefaultTransportManager } from './transport-manager.ts'
|
|
22
|
+
import { Upgrader } from './upgrader.ts'
|
|
23
|
+
import { userAgent } from './user-agent.ts'
|
|
24
|
+
import * as pkg from './version.ts'
|
|
25
|
+
import type { Components } from './components.ts'
|
|
26
|
+
import type { Libp2p as Libp2pInterface, Libp2pInit } from './index.ts'
|
|
27
27
|
import type { PeerRouting, ContentRouting, Libp2pEvents, PendingDial, ServiceMap, AbortOptions, ComponentLogger, Logger, Connection, Stream, Metrics, PeerId, PeerInfo, PeerStore, Topology, Libp2pStatus, IsDialableOptions, DialOptions, PublicKey, Ed25519PeerId, Secp256k1PeerId, RSAPublicKey, RSAPeerId, URLPeerId, Ed25519PublicKey, Secp256k1PublicKey, StreamHandler, StreamHandlerOptions, StreamMiddleware, DialTarget, DialProtocolOptions } from '@libp2p/interface'
|
|
28
28
|
import type { Multiaddr } from '@multiformats/multiaddr'
|
|
29
29
|
|
package/src/peer-routing.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { createScalableCuckooFilter } from '@libp2p/utils'
|
|
|
3
3
|
import merge from 'it-merge'
|
|
4
4
|
import parallel from 'it-parallel'
|
|
5
5
|
import { toString as uint8ArrayToString } from 'uint8arrays/to-string'
|
|
6
|
-
import { NoPeerRoutersError, QueriedForSelfError } from './errors.
|
|
6
|
+
import { NoPeerRoutersError, QueriedForSelfError } from './errors.ts'
|
|
7
7
|
import type { Logger, Metrics, PeerId, PeerInfo, PeerRouting, PeerStore, RoutingOptions } from '@libp2p/interface'
|
|
8
8
|
import type { ComponentLogger } from '@libp2p/logger'
|
|
9
9
|
|
package/src/registrar.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { InvalidParametersError } from '@libp2p/interface'
|
|
2
2
|
import { trackedMap } from '@libp2p/utils'
|
|
3
|
-
import { DuplicateProtocolHandlerError, UnhandledProtocolError } from './errors.
|
|
3
|
+
import { DuplicateProtocolHandlerError, UnhandledProtocolError } from './errors.ts'
|
|
4
4
|
import type { IdentifyResult, Libp2pEvents, Logger, PeerUpdate, PeerId, PeerStore, Topology, StreamHandler, StreamHandlerRecord, StreamHandlerOptions, AbortOptions, Metrics, StreamMiddleware } from '@libp2p/interface'
|
|
5
5
|
import type { Registrar as RegistrarInterface } from '@libp2p/interface-internal'
|
|
6
6
|
import type { ComponentLogger } from '@libp2p/logger'
|
package/src/transport-manager.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { FaultTolerance, InvalidParametersError, NotStartedError } from '@libp2p
|
|
|
2
2
|
import { trackedMap } from '@libp2p/utils'
|
|
3
3
|
import { IP4, IP6 } from '@multiformats/multiaddr-matcher'
|
|
4
4
|
import { CustomProgressEvent } from 'progress-events'
|
|
5
|
-
import { TransportUnavailableError, UnsupportedListenAddressError, UnsupportedListenAddressesError } from './errors.
|
|
5
|
+
import { TransportUnavailableError, UnsupportedListenAddressError, UnsupportedListenAddressesError } from './errors.ts'
|
|
6
6
|
import type { Libp2pEvents, ComponentLogger, Logger, Connection, Metrics, Startable, Listener, Transport, Upgrader } from '@libp2p/interface'
|
|
7
7
|
import type { AddressManager, TransportManager, TransportManagerDialOptions } from '@libp2p/interface-internal'
|
|
8
8
|
import type { Multiaddr } from '@multiformats/multiaddr'
|
package/src/upgrader.ts
CHANGED
|
@@ -7,9 +7,9 @@ import { anySignal } from 'any-signal'
|
|
|
7
7
|
import { setMaxListeners } from 'main-event'
|
|
8
8
|
import { CustomProgressEvent } from 'progress-events'
|
|
9
9
|
import { raceSignal } from 'race-signal'
|
|
10
|
-
import { PROTOCOL_NEGOTIATION_TIMEOUT, INBOUND_UPGRADE_TIMEOUT, CONNECTION_CLOSE_TIMEOUT } from './connection-manager/constants.
|
|
11
|
-
import { createConnection } from './connection.
|
|
12
|
-
import { ConnectionDeniedError, ConnectionInterceptedError, EncryptionFailedError, MuxerUnavailableError } from './errors.
|
|
10
|
+
import { PROTOCOL_NEGOTIATION_TIMEOUT, INBOUND_UPGRADE_TIMEOUT, CONNECTION_CLOSE_TIMEOUT } from './connection-manager/constants.ts'
|
|
11
|
+
import { createConnection } from './connection.ts'
|
|
12
|
+
import { ConnectionDeniedError, ConnectionInterceptedError, EncryptionFailedError, MuxerUnavailableError } from './errors.ts'
|
|
13
13
|
import type { Libp2pEvents, AbortOptions, ComponentLogger, MultiaddrConnection, Connection, ConnectionProtector, ConnectionEncrypter, ConnectionGater, Metrics, PeerId, PeerStore, StreamMuxerFactory, Upgrader as UpgraderInterface, UpgraderOptions, ConnectionLimits, CounterGroup, ClearableSignal, MessageStream, SecuredConnection, StreamMuxer, UpgraderWithoutEncryptionOptions, SecureConnectionOptions } from '@libp2p/interface'
|
|
14
14
|
import type { ConnectionManager, Registrar } from '@libp2p/interface-internal'
|
|
15
15
|
import type { TypedEventTarget } from 'main-event'
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Platform } from 'react-native'
|
|
2
|
-
import * as pkg from './version.
|
|
2
|
+
import * as pkg from './version.ts'
|
|
3
3
|
|
|
4
4
|
export function userAgent (name?: string, version?: string): string {
|
|
5
5
|
return `${name ?? pkg.name}/${version ?? pkg.version} react-native/${Platform.OS}-${`${Platform.Version}`.replaceAll('v', '')}`
|
package/src/user-agent.ts
CHANGED
package/src/version.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const version = '3.2.
|
|
1
|
+
export const version = '3.2.1'
|
|
2
2
|
export const name = 'js-libp2p'
|