libp2p 0.43.1 → 0.43.2-1e851148
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 +21 -21
- package/dist/src/circuit/server/index.js +1 -1
- package/dist/src/circuit/server/index.js.map +1 -1
- package/dist/src/circuit/server/reservation-store.d.ts.map +1 -1
- package/dist/src/circuit/server/reservation-store.js +2 -1
- package/dist/src/circuit/server/reservation-store.js.map +1 -1
- package/dist/src/circuit/transport/discovery.js.map +1 -1
- package/dist/src/circuit/transport/listener.d.ts +1 -1
- package/dist/src/circuit/transport/listener.d.ts.map +1 -1
- package/dist/src/circuit/transport/reservation-store.d.ts.map +1 -1
- package/dist/src/circuit/transport/reservation-store.js +4 -3
- package/dist/src/circuit/transport/reservation-store.js.map +1 -1
- package/dist/src/connection-manager/dialer/index.d.ts.map +1 -1
- package/dist/src/connection-manager/dialer/index.js +22 -9
- package/dist/src/connection-manager/dialer/index.js.map +1 -1
- package/dist/src/connection-manager/index.d.ts.map +1 -1
- package/dist/src/connection-manager/index.js +8 -1
- package/dist/src/connection-manager/index.js.map +1 -1
- package/dist/src/identify/index.js +1 -1
- package/dist/src/identify/index.js.map +1 -1
- package/package.json +1 -1
- package/src/circuit/server/index.ts +1 -1
- package/src/circuit/server/reservation-store.ts +6 -1
- package/src/circuit/transport/discovery.ts +2 -2
- package/src/circuit/transport/listener.ts +1 -1
- package/src/circuit/transport/reservation-store.ts +4 -3
- package/src/connection-manager/dialer/index.ts +24 -8
- package/src/connection-manager/index.ts +9 -1
- package/src/identify/index.ts +1 -1
- package/src/version.ts +1 -1
- package/dist/typedoc-urls.json +0 -41
|
@@ -167,8 +167,9 @@ export class ReservationStore extends EventEmitter<ReservationStoreEvents> imple
|
|
|
167
167
|
|
|
168
168
|
const expiration = getExpirationMilliseconds(reservation.expire)
|
|
169
169
|
|
|
170
|
-
// sets a lower bound on the timeout
|
|
171
|
-
|
|
170
|
+
// sets a lower bound on the timeout, and also don't let it go over
|
|
171
|
+
// 2^31 - 1 (setTimeout will only accept signed 32 bit integers)
|
|
172
|
+
const timeoutDuration = Math.min(Math.max(expiration - REFRESH_TIMEOUT, REFRESH_TIMEOUT_MIN), Math.pow(2, 31) - 1)
|
|
172
173
|
|
|
173
174
|
const timeout = setTimeout(() => {
|
|
174
175
|
this.addRelay(peerId, type).catch(err => {
|
|
@@ -215,7 +216,7 @@ export class ReservationStore extends EventEmitter<ReservationStoreEvents> imple
|
|
|
215
216
|
try {
|
|
216
217
|
response = await hopstr.read()
|
|
217
218
|
} catch (err: any) {
|
|
218
|
-
log.error('error parsing reserve message response from %
|
|
219
|
+
log.error('error parsing reserve message response from %p because', connection.remotePeer, err)
|
|
219
220
|
throw err
|
|
220
221
|
} finally {
|
|
221
222
|
stream.close()
|
|
@@ -209,7 +209,9 @@ export class DefaultDialer implements Startable, Dialer {
|
|
|
209
209
|
log('dial failed to %s', dialTarget.id, err)
|
|
210
210
|
// Error is a timeout
|
|
211
211
|
if (pendingDial.controller.signal.aborted) {
|
|
212
|
-
err.
|
|
212
|
+
const error = new CodeError(err.message, codes.ERR_TIMEOUT)
|
|
213
|
+
log.error(error)
|
|
214
|
+
throw error
|
|
213
215
|
}
|
|
214
216
|
log.error(err)
|
|
215
217
|
throw err
|
|
@@ -260,24 +262,38 @@ export class DefaultDialer implements Startable, Dialer {
|
|
|
260
262
|
addrs.map(async (ma) => await this._resolve(ma, options))
|
|
261
263
|
))
|
|
262
264
|
.flat()
|
|
263
|
-
|
|
264
|
-
|
|
265
|
+
|
|
266
|
+
// Multiaddrs not supported by the available transports will be filtered out.
|
|
267
|
+
const filteredAddrs = addrs.filter(ma => Boolean(this.components.transportManager.transportForMultiaddr(ma)))
|
|
265
268
|
|
|
266
269
|
// deduplicate addresses
|
|
267
|
-
|
|
270
|
+
const dedupedAddrs = [...new Set(filteredAddrs.map(ma => ma.toString()))]
|
|
271
|
+
let dedupedMultiaddrs = dedupedAddrs.map(ma => multiaddr(ma))
|
|
268
272
|
|
|
269
|
-
if (
|
|
273
|
+
if (dedupedMultiaddrs.length > this.maxAddrsToDial) {
|
|
274
|
+
log('addresses after filtering', dedupedMultiaddrs.map(ma => ma.toString()))
|
|
270
275
|
throw new CodeError('dial with more addresses than allowed', codes.ERR_TOO_MANY_ADDRESSES)
|
|
271
276
|
}
|
|
272
277
|
|
|
278
|
+
if (dedupedMultiaddrs.length === 0) {
|
|
279
|
+
log('addresses before filtering', addrs.map(ma => ma.toString()))
|
|
280
|
+
log('addresses after filtering', dedupedMultiaddrs.map(ma => ma.toString()))
|
|
281
|
+
}
|
|
282
|
+
|
|
273
283
|
const peerId = isPeerId(peerIdOrMultiaddr.peerId) ? peerIdOrMultiaddr.peerId : undefined
|
|
274
284
|
|
|
275
285
|
if (peerId != null) {
|
|
276
286
|
const peerIdMultiaddr = `/p2p/${peerId.toString()}`
|
|
277
|
-
|
|
287
|
+
dedupedMultiaddrs = dedupedMultiaddrs.map(addr => {
|
|
278
288
|
const addressPeerId = addr.getPeerId()
|
|
289
|
+
const lastProto = addr.protos().pop()
|
|
290
|
+
|
|
291
|
+
// do not append peer id to path multiaddrs
|
|
292
|
+
if (lastProto?.path === true) {
|
|
293
|
+
return addr
|
|
294
|
+
}
|
|
279
295
|
|
|
280
|
-
if (addressPeerId == null
|
|
296
|
+
if (addressPeerId == null) {
|
|
281
297
|
return addr.encapsulate(peerIdMultiaddr)
|
|
282
298
|
}
|
|
283
299
|
|
|
@@ -287,7 +303,7 @@ export class DefaultDialer implements Startable, Dialer {
|
|
|
287
303
|
|
|
288
304
|
return {
|
|
289
305
|
id: peerId == null ? randomId() : peerId.toString(),
|
|
290
|
-
addrs
|
|
306
|
+
addrs: dedupedMultiaddrs
|
|
291
307
|
}
|
|
292
308
|
}
|
|
293
309
|
|
|
@@ -648,7 +648,15 @@ export class DefaultConnectionManager extends EventEmitter<ConnectionManagerEven
|
|
|
648
648
|
|
|
649
649
|
for (const connection of sortedConnections) {
|
|
650
650
|
log('too many connections open - closing a connection to %p', connection.remotePeer)
|
|
651
|
-
|
|
651
|
+
// check allow list
|
|
652
|
+
const connectionInAllowList = this.allow.some((ma) => {
|
|
653
|
+
return connection.remoteAddr.toString().startsWith(ma.toString())
|
|
654
|
+
})
|
|
655
|
+
|
|
656
|
+
// Connections in the allow list should be excluded from pruning
|
|
657
|
+
if (!connectionInAllowList) {
|
|
658
|
+
toClose.push(connection)
|
|
659
|
+
}
|
|
652
660
|
|
|
653
661
|
if (toClose.length === toPrune) {
|
|
654
662
|
break
|
package/src/identify/index.ts
CHANGED
|
@@ -348,7 +348,7 @@ export class IdentifyService implements Startable {
|
|
|
348
348
|
await this.components.peerStore.metadataBook.setValue(id, 'ProtocolVersion', uint8ArrayFromString(protocolVersion))
|
|
349
349
|
}
|
|
350
350
|
|
|
351
|
-
log('identify completed for peer %p and protocols %o', id, protocols)
|
|
351
|
+
log('identify completed for peer %p with and protocols %o', id, protocols)
|
|
352
352
|
|
|
353
353
|
return
|
|
354
354
|
}
|
package/src/version.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const version = '0.43.
|
|
1
|
+
export const version = '0.43.2-1e851148'
|
|
2
2
|
export const name = 'libp2p'
|
package/dist/typedoc-urls.json
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"codec": "https://libp2p.github.io/js-libp2p/functions/circuit._internal_.Limit.codec.html",
|
|
3
|
-
"decode": "https://libp2p.github.io/js-libp2p/functions/circuit._internal_.Limit.decode.html",
|
|
4
|
-
"encode": "https://libp2p.github.io/js-libp2p/functions/circuit._internal_.Limit.encode.html",
|
|
5
|
-
"AdvertServiceComponents": "https://libp2p.github.io/js-libp2p/interfaces/circuit._internal_.AdvertServiceComponents.html",
|
|
6
|
-
"AdvertServiceInit": "https://libp2p.github.io/js-libp2p/interfaces/circuit._internal_.AdvertServiceInit.html",
|
|
7
|
-
"CircuitRelayServerComponents": "https://libp2p.github.io/js-libp2p/interfaces/circuit._internal_.CircuitRelayServerComponents.html",
|
|
8
|
-
"CircuitRelayServerInit": "https://libp2p.github.io/js-libp2p/interfaces/circuit._internal_.CircuitRelayServerInit.html",
|
|
9
|
-
"CircuitRelayTransportComponents": "https://libp2p.github.io/js-libp2p/interfaces/circuit._internal_.CircuitRelayTransportComponents.html",
|
|
10
|
-
"CircuitRelayTransportInit": "https://libp2p.github.io/js-libp2p/interfaces/circuit._internal_.CircuitRelayTransportInit.html",
|
|
11
|
-
"Limit": "https://libp2p.github.io/js-libp2p/interfaces/circuit._internal_.Limit-1.html",
|
|
12
|
-
"RelayDiscoveryComponents": "https://libp2p.github.io/js-libp2p/interfaces/circuit._internal_.RelayDiscoveryComponents.html",
|
|
13
|
-
"RelayStoreInit": "https://libp2p.github.io/js-libp2p/interfaces/circuit._internal_.RelayStoreInit.html",
|
|
14
|
-
"ReservationStoreInit": "https://libp2p.github.io/js-libp2p/interfaces/circuit._internal_.ReservationStoreInit.html",
|
|
15
|
-
"CircuitRelayService": "https://libp2p.github.io/js-libp2p/interfaces/circuit.CircuitRelayService.html",
|
|
16
|
-
"CircuitRelayServiceEvents": "https://libp2p.github.io/js-libp2p/interfaces/circuit.CircuitRelayServiceEvents.html",
|
|
17
|
-
"RelayReservation": "https://libp2p.github.io/js-libp2p/interfaces/circuit.RelayReservation.html",
|
|
18
|
-
"circuitRelayServer": "https://libp2p.github.io/js-libp2p/functions/circuit.circuitRelayServer.html",
|
|
19
|
-
"circuitRelayTransport": "https://libp2p.github.io/js-libp2p/functions/circuit.circuitRelayTransport.html",
|
|
20
|
-
"AddressFilter": "https://libp2p.github.io/js-libp2p/interfaces/index._internal_.AddressFilter.html",
|
|
21
|
-
"AddressManagerInit": "https://libp2p.github.io/js-libp2p/interfaces/index._internal_.AddressManagerInit.html",
|
|
22
|
-
"AutonatServiceInit": "https://libp2p.github.io/js-libp2p/interfaces/index._internal_.AutonatServiceInit.html",
|
|
23
|
-
"Components": "https://libp2p.github.io/js-libp2p/interfaces/index._internal_.Components.html",
|
|
24
|
-
"ConnectionManagerConfig": "https://libp2p.github.io/js-libp2p/interfaces/index._internal_.ConnectionManagerConfig.html",
|
|
25
|
-
"FetchServiceInit": "https://libp2p.github.io/js-libp2p/interfaces/index._internal_.FetchServiceInit.html",
|
|
26
|
-
"HostProperties": "https://libp2p.github.io/js-libp2p/interfaces/index._internal_.HostProperties.html",
|
|
27
|
-
"IdentifyServiceInit": "https://libp2p.github.io/js-libp2p/interfaces/index._internal_.IdentifyServiceInit.html",
|
|
28
|
-
"NatManagerInit": "https://libp2p.github.io/js-libp2p/interfaces/index._internal_.NatManagerInit.html",
|
|
29
|
-
"PeerRoutingInit": "https://libp2p.github.io/js-libp2p/interfaces/index._internal_.PeerRoutingInit.html",
|
|
30
|
-
"PingServiceInit": "https://libp2p.github.io/js-libp2p/interfaces/index._internal_.PingServiceInit.html",
|
|
31
|
-
"RefreshManagerInit": "https://libp2p.github.io/js-libp2p/interfaces/index._internal_.RefreshManagerInit.html",
|
|
32
|
-
"TransportManagerInit": "https://libp2p.github.io/js-libp2p/interfaces/index._internal_.TransportManagerInit.html",
|
|
33
|
-
"Libp2pEvents": "https://libp2p.github.io/js-libp2p/interfaces/index.Libp2pEvents.html",
|
|
34
|
-
"Libp2pInit": "https://libp2p.github.io/js-libp2p/interfaces/index.Libp2pInit.html",
|
|
35
|
-
"Libp2pOptions": "https://libp2p.github.io/js-libp2p/types/index.Libp2pOptions.html",
|
|
36
|
-
"createLibp2p": "https://libp2p.github.io/js-libp2p/functions/index.createLibp2p.html",
|
|
37
|
-
"plaintext": "https://libp2p.github.io/js-libp2p/functions/insecure.plaintext.html",
|
|
38
|
-
"ProtectorInit": "https://libp2p.github.io/js-libp2p/interfaces/pnet.ProtectorInit.html",
|
|
39
|
-
"generateKey": "https://libp2p.github.io/js-libp2p/functions/pnet.generateKey.html",
|
|
40
|
-
"preSharedKey": "https://libp2p.github.io/js-libp2p/functions/pnet.preSharedKey.html"
|
|
41
|
-
}
|