libp2p 0.46.15 → 0.46.16-025c082a
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 +20 -63
- package/dist/index.min.js +29 -29
- package/dist/src/autonat/index.d.ts.map +1 -1
- package/dist/src/autonat/index.js +3 -11
- package/dist/src/autonat/index.js.map +1 -1
- package/dist/src/circuit-relay/server/index.d.ts.map +1 -1
- package/dist/src/circuit-relay/server/index.js +2 -7
- package/dist/src/circuit-relay/server/index.js.map +1 -1
- package/dist/src/circuit-relay/transport/discovery.d.ts.map +1 -1
- package/dist/src/circuit-relay/transport/discovery.js +1 -0
- package/dist/src/circuit-relay/transport/discovery.js.map +1 -1
- package/dist/src/circuit-relay/transport/listener.d.ts.map +1 -1
- package/dist/src/circuit-relay/transport/listener.js +3 -17
- package/dist/src/circuit-relay/transport/listener.js.map +1 -1
- package/dist/src/connection/index.d.ts.map +1 -1
- package/dist/src/connection/index.js +5 -6
- package/dist/src/connection/index.js.map +1 -1
- package/dist/src/connection-manager/dial-queue.d.ts +4 -0
- package/dist/src/connection-manager/dial-queue.d.ts.map +1 -1
- package/dist/src/connection-manager/dial-queue.js +37 -7
- package/dist/src/connection-manager/dial-queue.js.map +1 -1
- package/dist/src/connection-manager/index.d.ts.map +1 -1
- package/dist/src/connection-manager/index.js +7 -5
- package/dist/src/connection-manager/index.js.map +1 -1
- package/dist/src/connection-manager/utils.d.ts.map +1 -1
- package/dist/src/connection-manager/utils.js +3 -11
- package/dist/src/connection-manager/utils.js.map +1 -1
- package/dist/src/dcutr/dcutr.d.ts +0 -5
- package/dist/src/dcutr/dcutr.d.ts.map +1 -1
- package/dist/src/dcutr/dcutr.js +4 -28
- package/dist/src/dcutr/dcutr.js.map +1 -1
- package/dist/src/dcutr/utils.d.ts +8 -0
- package/dist/src/dcutr/utils.d.ts.map +1 -0
- package/dist/src/dcutr/utils.js +27 -0
- package/dist/src/dcutr/utils.js.map +1 -0
- package/dist/src/fetch/index.d.ts.map +1 -1
- package/dist/src/fetch/index.js +2 -6
- package/dist/src/fetch/index.js.map +1 -1
- package/dist/src/identify/consts.d.ts +1 -1
- package/dist/src/identify/consts.d.ts.map +1 -1
- package/dist/src/identify/identify.d.ts.map +1 -1
- package/dist/src/identify/identify.js +55 -47
- package/dist/src/identify/identify.js.map +1 -1
- package/dist/src/libp2p.d.ts.map +1 -1
- package/dist/src/libp2p.js +3 -7
- package/dist/src/libp2p.js.map +1 -1
- package/dist/src/registrar.d.ts +7 -6
- package/dist/src/registrar.d.ts.map +1 -1
- package/dist/src/registrar.js +16 -41
- package/dist/src/registrar.js.map +1 -1
- package/dist/src/upgrader.d.ts.map +1 -1
- package/dist/src/upgrader.js +3 -11
- package/dist/src/upgrader.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 +23 -24
- package/src/autonat/index.ts +3 -9
- package/src/circuit-relay/server/index.ts +2 -6
- package/src/circuit-relay/transport/discovery.ts +1 -0
- package/src/circuit-relay/transport/listener.ts +3 -21
- package/src/connection/index.ts +6 -5
- package/src/connection-manager/dial-queue.ts +46 -6
- package/src/connection-manager/index.ts +7 -5
- package/src/connection-manager/utils.ts +3 -9
- package/src/dcutr/dcutr.ts +4 -35
- package/src/dcutr/utils.ts +33 -0
- package/src/fetch/index.ts +2 -5
- package/src/identify/identify.ts +63 -47
- package/src/libp2p.ts +3 -6
- package/src/pnet/README.md +0 -4
- package/src/registrar.ts +19 -50
- package/src/upgrader.ts +3 -9
- package/src/version.ts +1 -1
- package/dist/typedoc-urls.json +0 -71
package/src/registrar.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { CodeError } from '@libp2p/interface/errors'
|
|
|
2
2
|
import { logger } from '@libp2p/logger'
|
|
3
3
|
import merge from 'merge-options'
|
|
4
4
|
import { codes } from './errors.js'
|
|
5
|
-
import type { Libp2pEvents, PeerUpdate } from '@libp2p/interface'
|
|
5
|
+
import type { IdentifyResult, Libp2pEvents, PeerUpdate } from '@libp2p/interface'
|
|
6
6
|
import type { TypedEventTarget } from '@libp2p/interface/events'
|
|
7
7
|
import type { PeerId } from '@libp2p/interface/peer-id'
|
|
8
8
|
import type { PeerStore } from '@libp2p/interface/peer-store'
|
|
@@ -37,11 +37,11 @@ export class DefaultRegistrar implements Registrar {
|
|
|
37
37
|
|
|
38
38
|
this._onDisconnect = this._onDisconnect.bind(this)
|
|
39
39
|
this._onPeerUpdate = this._onPeerUpdate.bind(this)
|
|
40
|
-
this.
|
|
40
|
+
this._onPeerIdentify = this._onPeerIdentify.bind(this)
|
|
41
41
|
|
|
42
42
|
this.components.events.addEventListener('peer:disconnect', this._onDisconnect)
|
|
43
|
-
this.components.events.addEventListener('peer:connect', this._onConnect)
|
|
44
43
|
this.components.events.addEventListener('peer:update', this._onPeerUpdate)
|
|
44
|
+
this.components.events.addEventListener('peer:identify', this._onPeerIdentify)
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
getProtocols (): string[] {
|
|
@@ -183,52 +183,12 @@ export class DefaultRegistrar implements Registrar {
|
|
|
183
183
|
}
|
|
184
184
|
|
|
185
185
|
/**
|
|
186
|
-
*
|
|
187
|
-
*
|
|
188
|
-
*/
|
|
189
|
-
_onConnect (evt: CustomEvent<PeerId>): void {
|
|
190
|
-
const remotePeer = evt.detail
|
|
191
|
-
|
|
192
|
-
void this.components.peerStore.get(remotePeer)
|
|
193
|
-
.then(peer => {
|
|
194
|
-
const connection = this.components.connectionManager.getConnections(peer.id)[0]
|
|
195
|
-
|
|
196
|
-
if (connection == null) {
|
|
197
|
-
log('peer %p connected but the connection manager did not have a connection', peer)
|
|
198
|
-
// peer disconnected while we were loading their details from the peer store
|
|
199
|
-
return
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
for (const protocol of peer.protocols) {
|
|
203
|
-
const topologies = this.topologies.get(protocol)
|
|
204
|
-
|
|
205
|
-
if (topologies == null) {
|
|
206
|
-
// no topologies are interested in this protocol
|
|
207
|
-
continue
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
for (const topology of topologies.values()) {
|
|
211
|
-
topology.onConnect?.(remotePeer, connection)
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
})
|
|
215
|
-
.catch(err => {
|
|
216
|
-
if (err.code === codes.ERR_NOT_FOUND) {
|
|
217
|
-
// peer has not completed identify so they are not in the peer store
|
|
218
|
-
return
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
log.error('could not inform topologies of connecting peer %p', remotePeer, err)
|
|
222
|
-
})
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
/**
|
|
226
|
-
* Check if a new peer support the multicodecs for this topology
|
|
186
|
+
* When a peer is updated, if they have removed supported protocols notify any
|
|
187
|
+
* topologies interested in the removed protocols.
|
|
227
188
|
*/
|
|
228
189
|
_onPeerUpdate (evt: CustomEvent<PeerUpdate>): void {
|
|
229
190
|
const { peer, previous } = evt.detail
|
|
230
191
|
const removed = (previous?.protocols ?? []).filter(protocol => !peer.protocols.includes(protocol))
|
|
231
|
-
const added = peer.protocols.filter(protocol => !(previous?.protocols ?? []).includes(protocol))
|
|
232
192
|
|
|
233
193
|
for (const protocol of removed) {
|
|
234
194
|
const topologies = this.topologies.get(protocol)
|
|
@@ -242,8 +202,18 @@ export class DefaultRegistrar implements Registrar {
|
|
|
242
202
|
topology.onDisconnect?.(peer.id)
|
|
243
203
|
}
|
|
244
204
|
}
|
|
205
|
+
}
|
|
245
206
|
|
|
246
|
-
|
|
207
|
+
/**
|
|
208
|
+
* After identify has completed and we have received the list of supported
|
|
209
|
+
* protocols, notify any topologies interested in those protocols.
|
|
210
|
+
*/
|
|
211
|
+
_onPeerIdentify (evt: CustomEvent<IdentifyResult>): void {
|
|
212
|
+
const protocols = evt.detail.protocols
|
|
213
|
+
const connection = evt.detail.connection
|
|
214
|
+
const peerId = evt.detail.peerId
|
|
215
|
+
|
|
216
|
+
for (const protocol of protocols) {
|
|
247
217
|
const topologies = this.topologies.get(protocol)
|
|
248
218
|
|
|
249
219
|
if (topologies == null) {
|
|
@@ -252,12 +222,11 @@ export class DefaultRegistrar implements Registrar {
|
|
|
252
222
|
}
|
|
253
223
|
|
|
254
224
|
for (const topology of topologies.values()) {
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
if (connection == null) {
|
|
225
|
+
if (connection.transient && topology.notifyOnTransient !== true) {
|
|
258
226
|
continue
|
|
259
227
|
}
|
|
260
|
-
|
|
228
|
+
|
|
229
|
+
topology.onConnect?.(peerId, connection)
|
|
261
230
|
}
|
|
262
231
|
}
|
|
263
232
|
}
|
package/src/upgrader.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { setMaxListeners } from 'events'
|
|
2
1
|
import { CodeError } from '@libp2p/interface/errors'
|
|
2
|
+
import { setMaxListeners } from '@libp2p/interface/events'
|
|
3
3
|
import { logger } from '@libp2p/logger'
|
|
4
4
|
import * as mss from '@libp2p/multistream-select'
|
|
5
5
|
import { peerIdFromString } from '@libp2p/peer-id'
|
|
@@ -170,10 +170,7 @@ export class DefaultUpgrader implements Upgrader {
|
|
|
170
170
|
|
|
171
171
|
signal.addEventListener('abort', onAbort, { once: true })
|
|
172
172
|
|
|
173
|
-
|
|
174
|
-
// fails on node < 15.4
|
|
175
|
-
setMaxListeners?.(Infinity, signal)
|
|
176
|
-
} catch { }
|
|
173
|
+
setMaxListeners(Infinity, signal)
|
|
177
174
|
|
|
178
175
|
try {
|
|
179
176
|
if ((await this.components.connectionGater.denyInboundConnection?.(maConn)) === true) {
|
|
@@ -444,10 +441,7 @@ export class DefaultUpgrader implements Upgrader {
|
|
|
444
441
|
|
|
445
442
|
options.signal = AbortSignal.timeout(30000)
|
|
446
443
|
|
|
447
|
-
|
|
448
|
-
// fails on node < 15.4
|
|
449
|
-
setMaxListeners?.(Infinity, options.signal)
|
|
450
|
-
} catch { }
|
|
444
|
+
setMaxListeners(Infinity, options.signal)
|
|
451
445
|
}
|
|
452
446
|
|
|
453
447
|
const { stream, protocol } = await mss.select(muxedStream, protocols, options)
|
package/src/version.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const version = '0.46.
|
|
1
|
+
export const version = '0.46.16-025c082a'
|
|
2
2
|
export const name = 'libp2p'
|
package/dist/typedoc-urls.json
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"AutoNATComponents": "https://libp2p.github.io/js-libp2p/interfaces/libp2p.autonat.AutoNATComponents.html",
|
|
3
|
-
"./autonat:AutoNATComponents": "https://libp2p.github.io/js-libp2p/interfaces/libp2p.autonat.AutoNATComponents.html",
|
|
4
|
-
"AutoNATServiceInit": "https://libp2p.github.io/js-libp2p/interfaces/libp2p.autonat.AutoNATServiceInit.html",
|
|
5
|
-
"./autonat:AutoNATServiceInit": "https://libp2p.github.io/js-libp2p/interfaces/libp2p.autonat.AutoNATServiceInit.html",
|
|
6
|
-
"autoNATService": "https://libp2p.github.io/js-libp2p/functions/libp2p.autonat.autoNATService.html",
|
|
7
|
-
"./autonat:autoNATService": "https://libp2p.github.io/js-libp2p/functions/libp2p.autonat.autoNATService.html",
|
|
8
|
-
"CircuitRelayService": "https://libp2p.github.io/js-libp2p/interfaces/libp2p.circuit_relay.CircuitRelayService.html",
|
|
9
|
-
"./circuit-relay:CircuitRelayService": "https://libp2p.github.io/js-libp2p/interfaces/libp2p.circuit_relay.CircuitRelayService.html",
|
|
10
|
-
"CircuitRelayServiceEvents": "https://libp2p.github.io/js-libp2p/interfaces/libp2p.circuit_relay.CircuitRelayServiceEvents.html",
|
|
11
|
-
"./circuit-relay:CircuitRelayServiceEvents": "https://libp2p.github.io/js-libp2p/interfaces/libp2p.circuit_relay.CircuitRelayServiceEvents.html",
|
|
12
|
-
"RelayReservation": "https://libp2p.github.io/js-libp2p/interfaces/libp2p.circuit_relay.RelayReservation.html",
|
|
13
|
-
"./circuit-relay:RelayReservation": "https://libp2p.github.io/js-libp2p/interfaces/libp2p.circuit_relay.RelayReservation.html",
|
|
14
|
-
"circuitRelayServer": "https://libp2p.github.io/js-libp2p/functions/libp2p.circuit_relay.circuitRelayServer.html",
|
|
15
|
-
"circuitRelayTransport": "https://libp2p.github.io/js-libp2p/functions/libp2p.circuit_relay.circuitRelayTransport.html",
|
|
16
|
-
"FetchService": "https://libp2p.github.io/js-libp2p/interfaces/libp2p.fetch.FetchService.html",
|
|
17
|
-
"./fetch:FetchService": "https://libp2p.github.io/js-libp2p/interfaces/libp2p.fetch.FetchService.html",
|
|
18
|
-
"FetchServiceComponents": "https://libp2p.github.io/js-libp2p/interfaces/libp2p.fetch.FetchServiceComponents.html",
|
|
19
|
-
"./fetch:FetchServiceComponents": "https://libp2p.github.io/js-libp2p/interfaces/libp2p.fetch.FetchServiceComponents.html",
|
|
20
|
-
"FetchServiceInit": "https://libp2p.github.io/js-libp2p/interfaces/libp2p.fetch.FetchServiceInit.html",
|
|
21
|
-
"./fetch:FetchServiceInit": "https://libp2p.github.io/js-libp2p/interfaces/libp2p.fetch.FetchServiceInit.html",
|
|
22
|
-
"HandleMessageOptions": "https://libp2p.github.io/js-libp2p/interfaces/libp2p.fetch.HandleMessageOptions.html",
|
|
23
|
-
"./fetch:HandleMessageOptions": "https://libp2p.github.io/js-libp2p/interfaces/libp2p.fetch.HandleMessageOptions.html",
|
|
24
|
-
"LookupFunction": "https://libp2p.github.io/js-libp2p/interfaces/libp2p.fetch.LookupFunction.html",
|
|
25
|
-
"./fetch:LookupFunction": "https://libp2p.github.io/js-libp2p/interfaces/libp2p.fetch.LookupFunction.html",
|
|
26
|
-
"fetchService": "https://libp2p.github.io/js-libp2p/functions/libp2p.fetch.fetchService-1.html",
|
|
27
|
-
"./fetch:fetchService": "https://libp2p.github.io/js-libp2p/functions/libp2p.fetch.fetchService-1.html",
|
|
28
|
-
"IdentifyService": "https://libp2p.github.io/js-libp2p/interfaces/libp2p.identify.IdentifyService.html",
|
|
29
|
-
"./identify:IdentifyService": "https://libp2p.github.io/js-libp2p/interfaces/libp2p.identify.IdentifyService.html",
|
|
30
|
-
"IdentifyServiceComponents": "https://libp2p.github.io/js-libp2p/interfaces/libp2p.identify.IdentifyServiceComponents.html",
|
|
31
|
-
"./identify:IdentifyServiceComponents": "https://libp2p.github.io/js-libp2p/interfaces/libp2p.identify.IdentifyServiceComponents.html",
|
|
32
|
-
"IdentifyServiceInit": "https://libp2p.github.io/js-libp2p/interfaces/libp2p.identify.IdentifyServiceInit.html",
|
|
33
|
-
"./identify:IdentifyServiceInit": "https://libp2p.github.io/js-libp2p/interfaces/libp2p.identify.IdentifyServiceInit.html",
|
|
34
|
-
"Message": "https://libp2p.github.io/js-libp2p/variables/libp2p.identify.Message.html",
|
|
35
|
-
"./identify:Message": "https://libp2p.github.io/js-libp2p/variables/libp2p.identify.Message.html",
|
|
36
|
-
"multicodecs": "https://libp2p.github.io/js-libp2p/variables/libp2p.identify.multicodecs.html",
|
|
37
|
-
"./identify:multicodecs": "https://libp2p.github.io/js-libp2p/variables/libp2p.identify.multicodecs.html",
|
|
38
|
-
"identifyService": "https://libp2p.github.io/js-libp2p/functions/libp2p.identify.identifyService-1.html",
|
|
39
|
-
"./identify:identifyService": "https://libp2p.github.io/js-libp2p/functions/libp2p.identify.identifyService-1.html",
|
|
40
|
-
"Libp2pInit": "https://libp2p.github.io/js-libp2p/interfaces/libp2p.index.Libp2pInit.html",
|
|
41
|
-
".:Libp2pInit": "https://libp2p.github.io/js-libp2p/interfaces/libp2p.index.Libp2pInit.html",
|
|
42
|
-
"Libp2pOptions": "https://libp2p.github.io/js-libp2p/types/libp2p.index.Libp2pOptions.html",
|
|
43
|
-
".:Libp2pOptions": "https://libp2p.github.io/js-libp2p/types/libp2p.index.Libp2pOptions.html",
|
|
44
|
-
"ServiceFactoryMap": "https://libp2p.github.io/js-libp2p/types/libp2p.index.ServiceFactoryMap.html",
|
|
45
|
-
".:ServiceFactoryMap": "https://libp2p.github.io/js-libp2p/types/libp2p.index.ServiceFactoryMap.html",
|
|
46
|
-
"createLibp2p": "https://libp2p.github.io/js-libp2p/functions/libp2p.index.createLibp2p.html",
|
|
47
|
-
".:createLibp2p": "https://libp2p.github.io/js-libp2p/functions/libp2p.index.createLibp2p.html",
|
|
48
|
-
"plaintext": "https://libp2p.github.io/js-libp2p/functions/libp2p.insecure.plaintext.html",
|
|
49
|
-
"./insecure:plaintext": "https://libp2p.github.io/js-libp2p/functions/libp2p.insecure.plaintext.html",
|
|
50
|
-
"PingService": "https://libp2p.github.io/js-libp2p/interfaces/libp2p.ping.PingService.html",
|
|
51
|
-
"./ping:PingService": "https://libp2p.github.io/js-libp2p/interfaces/libp2p.ping.PingService.html",
|
|
52
|
-
"PingServiceComponents": "https://libp2p.github.io/js-libp2p/interfaces/libp2p.ping.PingServiceComponents.html",
|
|
53
|
-
"./ping:PingServiceComponents": "https://libp2p.github.io/js-libp2p/interfaces/libp2p.ping.PingServiceComponents.html",
|
|
54
|
-
"PingServiceInit": "https://libp2p.github.io/js-libp2p/interfaces/libp2p.ping.PingServiceInit.html",
|
|
55
|
-
"./ping:PingServiceInit": "https://libp2p.github.io/js-libp2p/interfaces/libp2p.ping.PingServiceInit.html",
|
|
56
|
-
"pingService": "https://libp2p.github.io/js-libp2p/functions/libp2p.ping.pingService-1.html",
|
|
57
|
-
"./ping:pingService": "https://libp2p.github.io/js-libp2p/functions/libp2p.ping.pingService-1.html",
|
|
58
|
-
"ProtectorInit": "https://libp2p.github.io/js-libp2p/interfaces/libp2p.pnet.ProtectorInit.html",
|
|
59
|
-
"./pnet:ProtectorInit": "https://libp2p.github.io/js-libp2p/interfaces/libp2p.pnet.ProtectorInit.html",
|
|
60
|
-
"generateKey": "https://libp2p.github.io/js-libp2p/functions/libp2p.pnet.generateKey.html",
|
|
61
|
-
"preSharedKey": "https://libp2p.github.io/js-libp2p/functions/libp2p.pnet.preSharedKey.html",
|
|
62
|
-
"./pnet:preSharedKey": "https://libp2p.github.io/js-libp2p/functions/libp2p.pnet.preSharedKey.html",
|
|
63
|
-
"PMPOptions": "https://libp2p.github.io/js-libp2p/interfaces/libp2p.upnp_nat.PMPOptions.html",
|
|
64
|
-
"./upnp-nat:PMPOptions": "https://libp2p.github.io/js-libp2p/interfaces/libp2p.upnp_nat.PMPOptions.html",
|
|
65
|
-
"UPnPNATComponents": "https://libp2p.github.io/js-libp2p/interfaces/libp2p.upnp_nat.UPnPNATComponents.html",
|
|
66
|
-
"./upnp-nat:UPnPNATComponents": "https://libp2p.github.io/js-libp2p/interfaces/libp2p.upnp_nat.UPnPNATComponents.html",
|
|
67
|
-
"UPnPNATInit": "https://libp2p.github.io/js-libp2p/interfaces/libp2p.upnp_nat.UPnPNATInit.html",
|
|
68
|
-
"./upnp-nat:UPnPNATInit": "https://libp2p.github.io/js-libp2p/interfaces/libp2p.upnp_nat.UPnPNATInit.html",
|
|
69
|
-
"uPnPNATService": "https://libp2p.github.io/js-libp2p/functions/libp2p.upnp_nat.uPnPNATService.html",
|
|
70
|
-
"./upnp-nat:uPnPNATService": "https://libp2p.github.io/js-libp2p/functions/libp2p.upnp_nat.uPnPNATService.html"
|
|
71
|
-
}
|