libp2p 0.46.8 → 0.46.9-28d6722f
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 +22 -22
- package/dist/src/autonat/index.d.ts.map +1 -1
- package/dist/src/autonat/index.js +18 -9
- package/dist/src/autonat/index.js.map +1 -1
- package/dist/src/circuit-relay/transport/reservation-store.js +1 -1
- 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 +14 -7
- package/dist/src/circuit-relay/utils.js.map +1 -1
- package/dist/src/config.js +2 -2
- package/dist/src/config.js.map +1 -1
- package/dist/src/connection-manager/auto-dial.d.ts +2 -0
- package/dist/src/connection-manager/auto-dial.d.ts.map +1 -1
- package/dist/src/connection-manager/auto-dial.js +19 -2
- package/dist/src/connection-manager/auto-dial.js.map +1 -1
- package/dist/src/connection-manager/constants.browser.d.ts +6 -6
- package/dist/src/connection-manager/constants.browser.d.ts.map +1 -1
- package/dist/src/connection-manager/constants.browser.js +6 -6
- package/dist/src/connection-manager/constants.browser.js.map +1 -1
- package/dist/src/connection-manager/constants.d.ts +6 -6
- package/dist/src/connection-manager/constants.d.ts.map +1 -1
- package/dist/src/connection-manager/constants.defaults.d.ts +7 -3
- package/dist/src/connection-manager/constants.defaults.d.ts.map +1 -1
- package/dist/src/connection-manager/constants.defaults.js +7 -3
- package/dist/src/connection-manager/constants.defaults.js.map +1 -1
- package/dist/src/connection-manager/constants.js +6 -6
- package/dist/src/connection-manager/constants.js.map +1 -1
- package/dist/src/connection-manager/dial-queue.js +2 -2
- package/dist/src/connection-manager/dial-queue.js.map +1 -1
- package/dist/src/connection-manager/index.d.ts +12 -5
- package/dist/src/connection-manager/index.d.ts.map +1 -1
- package/dist/src/connection-manager/index.js +4 -3
- package/dist/src/connection-manager/index.js.map +1 -1
- package/dist/src/fetch/index.d.ts.map +1 -1
- package/dist/src/fetch/index.js +7 -3
- 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/libp2p.js +1 -1
- package/dist/src/libp2p.js.map +1 -1
- package/dist/src/ping/index.d.ts.map +1 -1
- package/dist/src/ping/index.js +7 -3
- package/dist/src/ping/index.js.map +1 -1
- package/dist/src/upgrader.d.ts.map +1 -1
- package/dist/src/upgrader.js +5 -4
- 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 +21 -22
- package/src/autonat/index.ts +20 -7
- package/src/circuit-relay/transport/reservation-store.ts +1 -1
- package/src/circuit-relay/utils.ts +18 -7
- package/src/config.ts +2 -2
- package/src/connection-manager/auto-dial.ts +22 -2
- package/src/connection-manager/constants.browser.ts +7 -7
- package/src/connection-manager/constants.defaults.ts +8 -3
- package/src/connection-manager/constants.ts +7 -7
- package/src/connection-manager/dial-queue.ts +2 -2
- package/src/connection-manager/index.ts +17 -8
- package/src/fetch/index.ts +8 -3
- package/src/libp2p.ts +1 -1
- package/src/ping/index.ts +8 -3
- package/src/upgrader.ts +8 -5
- package/src/version.ts +1 -1
- package/dist/typedoc-urls.json +0 -58
package/src/libp2p.ts
CHANGED
|
@@ -105,7 +105,7 @@ export class Libp2pNode<T extends ServiceMap = Record<string, unknown>> extends
|
|
|
105
105
|
protocols: evt.detail.peer.protocols
|
|
106
106
|
}
|
|
107
107
|
|
|
108
|
-
|
|
108
|
+
components.events.safeDispatchEvent('peer:discovery', { detail: peerInfo })
|
|
109
109
|
}
|
|
110
110
|
})
|
|
111
111
|
|
package/src/ping/index.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { randomBytes } from '@libp2p/crypto'
|
|
2
2
|
import { CodeError } from '@libp2p/interface/errors'
|
|
3
3
|
import { logger } from '@libp2p/logger'
|
|
4
|
-
import { abortableDuplex } from 'abortable-iterator'
|
|
5
4
|
import first from 'it-first'
|
|
6
5
|
import { pipe } from 'it-pipe'
|
|
7
6
|
import { equals as uint8ArrayEquals } from 'uint8arrays/equals'
|
|
@@ -108,6 +107,7 @@ class DefaultPingService implements Startable, PingService {
|
|
|
108
107
|
const data = randomBytes(PING_LENGTH)
|
|
109
108
|
const connection = await this.components.connectionManager.openConnection(peer, options)
|
|
110
109
|
let stream: Stream | undefined
|
|
110
|
+
let onAbort = (): void => {}
|
|
111
111
|
|
|
112
112
|
options.signal = options.signal ?? AbortSignal.timeout(this.timeout)
|
|
113
113
|
|
|
@@ -117,12 +117,16 @@ class DefaultPingService implements Startable, PingService {
|
|
|
117
117
|
runOnTransientConnection: this.runOnTransientConnection
|
|
118
118
|
})
|
|
119
119
|
|
|
120
|
+
onAbort = () => {
|
|
121
|
+
stream?.abort(new CodeError('ping timeout', codes.ERR_TIMEOUT))
|
|
122
|
+
}
|
|
123
|
+
|
|
120
124
|
// make stream abortable
|
|
121
|
-
|
|
125
|
+
options.signal.addEventListener('abort', onAbort, { once: true })
|
|
122
126
|
|
|
123
127
|
const result = await pipe(
|
|
124
128
|
[data],
|
|
125
|
-
|
|
129
|
+
stream,
|
|
126
130
|
async (source) => first(source)
|
|
127
131
|
)
|
|
128
132
|
|
|
@@ -146,6 +150,7 @@ class DefaultPingService implements Startable, PingService {
|
|
|
146
150
|
|
|
147
151
|
throw err
|
|
148
152
|
} finally {
|
|
153
|
+
options.signal.removeEventListener('abort', onAbort)
|
|
149
154
|
if (stream != null) {
|
|
150
155
|
await stream.close()
|
|
151
156
|
}
|
package/src/upgrader.ts
CHANGED
|
@@ -3,7 +3,6 @@ import { CodeError } from '@libp2p/interface/errors'
|
|
|
3
3
|
import { logger } from '@libp2p/logger'
|
|
4
4
|
import * as mss from '@libp2p/multistream-select'
|
|
5
5
|
import { peerIdFromString } from '@libp2p/peer-id'
|
|
6
|
-
import { abortableDuplex } from 'abortable-iterator'
|
|
7
6
|
import { createConnection } from './connection/index.js'
|
|
8
7
|
import { INBOUND_UPGRADE_TIMEOUT } from './connection-manager/constants.js'
|
|
9
8
|
import { codes } from './errors.js'
|
|
@@ -165,16 +164,18 @@ export class DefaultUpgrader implements Upgrader {
|
|
|
165
164
|
|
|
166
165
|
const signal = AbortSignal.timeout(this.inboundUpgradeTimeout)
|
|
167
166
|
|
|
167
|
+
const onAbort = (): void => {
|
|
168
|
+
maConn.abort(new CodeError('inbound upgrade timeout', codes.ERR_TIMEOUT))
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
signal.addEventListener('abort', onAbort, { once: true })
|
|
172
|
+
|
|
168
173
|
try {
|
|
169
174
|
// fails on node < 15.4
|
|
170
175
|
setMaxListeners?.(Infinity, signal)
|
|
171
176
|
} catch { }
|
|
172
177
|
|
|
173
178
|
try {
|
|
174
|
-
const abortableStream = abortableDuplex(maConn, signal)
|
|
175
|
-
maConn.source = abortableStream.source
|
|
176
|
-
maConn.sink = abortableStream.sink
|
|
177
|
-
|
|
178
179
|
if ((await this.components.connectionGater.denyInboundConnection?.(maConn)) === true) {
|
|
179
180
|
throw new CodeError('The multiaddr connection is blocked by gater.acceptConnection', codes.ERR_CONNECTION_INTERCEPTED)
|
|
180
181
|
}
|
|
@@ -255,6 +256,8 @@ export class DefaultUpgrader implements Upgrader {
|
|
|
255
256
|
transient: opts?.transient
|
|
256
257
|
})
|
|
257
258
|
} finally {
|
|
259
|
+
signal.removeEventListener('abort', onAbort)
|
|
260
|
+
|
|
258
261
|
this.components.connectionManager.afterUpgradeInbound()
|
|
259
262
|
}
|
|
260
263
|
}
|
package/src/version.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const version = '0.46.
|
|
1
|
+
export const version = '0.46.9-28d6722f'
|
|
2
2
|
export const name = 'libp2p'
|
package/dist/typedoc-urls.json
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"AutoNATComponents": "https://libp2p.github.io/js-libp2p/interfaces/libp2p.autonat.AutoNATComponents.html",
|
|
3
|
-
"AutoNATServiceInit": "https://libp2p.github.io/js-libp2p/interfaces/libp2p.autonat.AutoNATServiceInit.html",
|
|
4
|
-
"autoNATService": "https://libp2p.github.io/js-libp2p/functions/libp2p.autonat.autoNATService.html",
|
|
5
|
-
"codec": "https://libp2p.github.io/js-libp2p/functions/libp2p.circuit_relay.unknown.Limit.codec.html",
|
|
6
|
-
"decode": "https://libp2p.github.io/js-libp2p/functions/libp2p.circuit_relay.unknown.Limit.decode.html",
|
|
7
|
-
"encode": "https://libp2p.github.io/js-libp2p/functions/libp2p.circuit_relay.unknown.Limit.encode.html",
|
|
8
|
-
"Limit": "https://libp2p.github.io/js-libp2p/interfaces/libp2p.circuit_relay.unknown.Limit-1.html",
|
|
9
|
-
"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
|
-
"RelayReservation": "https://libp2p.github.io/js-libp2p/interfaces/libp2p.circuit_relay.RelayReservation.html",
|
|
12
|
-
"circuitRelayServer": "https://libp2p.github.io/js-libp2p/functions/libp2p.circuit_relay.circuitRelayServer.html",
|
|
13
|
-
"circuitRelayTransport": "https://libp2p.github.io/js-libp2p/functions/libp2p.circuit_relay.circuitRelayTransport.html",
|
|
14
|
-
"FetchService": "https://libp2p.github.io/js-libp2p/interfaces/libp2p.fetch.FetchService.html",
|
|
15
|
-
"FetchServiceComponents": "https://libp2p.github.io/js-libp2p/interfaces/libp2p.fetch.FetchServiceComponents.html",
|
|
16
|
-
"FetchServiceInit": "https://libp2p.github.io/js-libp2p/interfaces/libp2p.fetch.FetchServiceInit.html",
|
|
17
|
-
"HandleMessageOptions": "https://libp2p.github.io/js-libp2p/interfaces/libp2p.fetch.HandleMessageOptions.html",
|
|
18
|
-
"LookupFunction": "https://libp2p.github.io/js-libp2p/interfaces/libp2p.fetch.LookupFunction.html",
|
|
19
|
-
"fetchService": "https://libp2p.github.io/js-libp2p/functions/libp2p.fetch.fetchService-1.html",
|
|
20
|
-
"Identify": "https://libp2p.github.io/js-libp2p/interfaces/libp2p.identify.unknown.Identify-1.html",
|
|
21
|
-
"IdentifyService": "https://libp2p.github.io/js-libp2p/interfaces/libp2p.identify.IdentifyService.html",
|
|
22
|
-
"IdentifyServiceComponents": "https://libp2p.github.io/js-libp2p/interfaces/libp2p.identify.IdentifyServiceComponents.html",
|
|
23
|
-
"IdentifyServiceInit": "https://libp2p.github.io/js-libp2p/interfaces/libp2p.identify.IdentifyServiceInit.html",
|
|
24
|
-
"Message": "https://libp2p.github.io/js-libp2p/variables/libp2p.identify.Message.html",
|
|
25
|
-
"multicodecs": "https://libp2p.github.io/js-libp2p/variables/libp2p.identify.multicodecs.html",
|
|
26
|
-
"identifyService": "https://libp2p.github.io/js-libp2p/functions/libp2p.identify.identifyService-1.html",
|
|
27
|
-
"AddressFilter": "https://libp2p.github.io/js-libp2p/interfaces/libp2p.index.unknown.AddressFilter.html",
|
|
28
|
-
"AddressManagerInit": "https://libp2p.github.io/js-libp2p/interfaces/libp2p.index.unknown.AddressManagerInit.html",
|
|
29
|
-
"Components": "https://libp2p.github.io/js-libp2p/interfaces/libp2p.index.unknown.Components.html",
|
|
30
|
-
"ConnectionManagerInit": "https://libp2p.github.io/js-libp2p/interfaces/libp2p.index.unknown.ConnectionManagerInit.html",
|
|
31
|
-
"TransportManagerInit": "https://libp2p.github.io/js-libp2p/interfaces/libp2p.index.unknown.TransportManagerInit.html",
|
|
32
|
-
"Libp2pInit": "https://libp2p.github.io/js-libp2p/interfaces/libp2p.index.Libp2pInit.html",
|
|
33
|
-
"Libp2pOptions": "https://libp2p.github.io/js-libp2p/types/libp2p.index.Libp2pOptions.html",
|
|
34
|
-
"ServiceFactoryMap": "https://libp2p.github.io/js-libp2p/types/libp2p.index.ServiceFactoryMap.html",
|
|
35
|
-
"createLibp2p": "https://libp2p.github.io/js-libp2p/functions/libp2p.index.createLibp2p.html",
|
|
36
|
-
"plaintext": "https://libp2p.github.io/js-libp2p/functions/libp2p.insecure.plaintext.html",
|
|
37
|
-
"PingService": "https://libp2p.github.io/js-libp2p/interfaces/libp2p.ping.PingService.html",
|
|
38
|
-
"PingServiceComponents": "https://libp2p.github.io/js-libp2p/interfaces/libp2p.ping.PingServiceComponents.html",
|
|
39
|
-
"PingServiceInit": "https://libp2p.github.io/js-libp2p/interfaces/libp2p.ping.PingServiceInit.html",
|
|
40
|
-
"pingService": "https://libp2p.github.io/js-libp2p/functions/libp2p.ping.pingService-1.html",
|
|
41
|
-
"ProtectorInit": "https://libp2p.github.io/js-libp2p/interfaces/libp2p.pnet.ProtectorInit.html",
|
|
42
|
-
"generateKey": "https://libp2p.github.io/js-libp2p/functions/libp2p.pnet.generateKey.html",
|
|
43
|
-
"preSharedKey": "https://libp2p.github.io/js-libp2p/functions/libp2p.pnet.preSharedKey.html",
|
|
44
|
-
"UPnPNAT": "https://libp2p.github.io/js-libp2p/classes/libp2p.upnp_nat.unknown.UPnPNAT.html",
|
|
45
|
-
"AdvertServiceComponents": "https://libp2p.github.io/js-libp2p/interfaces/libp2p.upnp_nat.unknown.AdvertServiceComponents.html",
|
|
46
|
-
"AdvertServiceInit": "https://libp2p.github.io/js-libp2p/interfaces/libp2p.upnp_nat.unknown.AdvertServiceInit.html",
|
|
47
|
-
"CircuitRelayServerComponents": "https://libp2p.github.io/js-libp2p/interfaces/libp2p.upnp_nat.unknown.CircuitRelayServerComponents.html",
|
|
48
|
-
"CircuitRelayServerInit": "https://libp2p.github.io/js-libp2p/interfaces/libp2p.upnp_nat.unknown.CircuitRelayServerInit.html",
|
|
49
|
-
"CircuitRelayTransportComponents": "https://libp2p.github.io/js-libp2p/interfaces/libp2p.upnp_nat.unknown.CircuitRelayTransportComponents.html",
|
|
50
|
-
"CircuitRelayTransportInit": "https://libp2p.github.io/js-libp2p/interfaces/libp2p.upnp_nat.unknown.CircuitRelayTransportInit.html",
|
|
51
|
-
"RelayDiscoveryComponents": "https://libp2p.github.io/js-libp2p/interfaces/libp2p.upnp_nat.unknown.RelayDiscoveryComponents.html",
|
|
52
|
-
"RelayStoreInit": "https://libp2p.github.io/js-libp2p/interfaces/libp2p.upnp_nat.unknown.RelayStoreInit.html",
|
|
53
|
-
"ReservationStoreInit": "https://libp2p.github.io/js-libp2p/interfaces/libp2p.upnp_nat.unknown.ReservationStoreInit.html",
|
|
54
|
-
"PMPOptions": "https://libp2p.github.io/js-libp2p/interfaces/libp2p.upnp_nat.PMPOptions.html",
|
|
55
|
-
"UPnPNATComponents": "https://libp2p.github.io/js-libp2p/interfaces/libp2p.upnp_nat.UPnPNATComponents.html",
|
|
56
|
-
"UPnPNATInit": "https://libp2p.github.io/js-libp2p/interfaces/libp2p.upnp_nat.UPnPNATInit.html",
|
|
57
|
-
"uPnPNATService": "https://libp2p.github.io/js-libp2p/functions/libp2p.upnp_nat.uPnPNATService.html"
|
|
58
|
-
}
|