libp2p 0.46.21 → 1.0.0
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 +51 -47
- package/dist/index.min.js +40 -28
- package/dist/src/address-manager/index.d.ts +4 -5
- package/dist/src/address-manager/index.d.ts.map +1 -1
- package/dist/src/address-manager/index.js +3 -3
- package/dist/src/address-manager/index.js.map +1 -1
- package/dist/src/components.d.ts +4 -15
- 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 +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/connection-gater.d.ts +1 -1
- package/dist/src/config/connection-gater.d.ts.map +1 -1
- package/dist/src/config.d.ts.map +1 -1
- package/dist/src/config.js +1 -2
- package/dist/src/config.js.map +1 -1
- package/dist/src/connection/index.d.ts +4 -6
- package/dist/src/connection/index.d.ts.map +1 -1
- package/dist/src/connection/index.js +11 -13
- package/dist/src/connection/index.js.map +1 -1
- package/dist/src/connection-manager/auto-dial.d.ts +3 -6
- package/dist/src/connection-manager/auto-dial.d.ts.map +1 -1
- package/dist/src/connection-manager/auto-dial.js +21 -21
- package/dist/src/connection-manager/auto-dial.js.map +1 -1
- package/dist/src/connection-manager/connection-pruner.d.ts +3 -5
- package/dist/src/connection-manager/connection-pruner.d.ts.map +1 -1
- package/dist/src/connection-manager/connection-pruner.js +8 -8
- package/dist/src/connection-manager/connection-pruner.js.map +1 -1
- package/dist/src/connection-manager/constants.defaults.d.ts +0 -4
- package/dist/src/connection-manager/constants.defaults.d.ts.map +1 -1
- package/dist/src/connection-manager/constants.defaults.js +0 -4
- package/dist/src/connection-manager/constants.defaults.js.map +1 -1
- package/dist/src/connection-manager/dial-queue.d.ts +3 -10
- package/dist/src/connection-manager/dial-queue.d.ts.map +1 -1
- package/dist/src/connection-manager/dial-queue.js +30 -38
- package/dist/src/connection-manager/dial-queue.js.map +1 -1
- package/dist/src/connection-manager/index.d.ts +3 -18
- package/dist/src/connection-manager/index.d.ts.map +1 -1
- package/dist/src/connection-manager/index.js +17 -18
- package/dist/src/connection-manager/index.js.map +1 -1
- package/dist/src/connection-manager/utils.js +1 -1
- package/dist/src/connection-manager/utils.js.map +1 -1
- package/dist/src/content-routing/index.d.ts +1 -5
- package/dist/src/content-routing/index.d.ts.map +1 -1
- package/dist/src/content-routing/index.js +2 -2
- package/dist/src/content-routing/index.js.map +1 -1
- package/dist/src/content-routing/utils.d.ts +1 -2
- package/dist/src/content-routing/utils.d.ts.map +1 -1
- package/dist/src/content-routing/utils.js +1 -1
- package/dist/src/content-routing/utils.js.map +1 -1
- package/dist/src/errors.d.ts +0 -2
- package/dist/src/errors.d.ts.map +1 -1
- package/dist/src/errors.js +0 -2
- package/dist/src/errors.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 +1 -5
- package/dist/src/get-peer.js.map +1 -1
- package/dist/src/index.d.ts +5 -16
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/libp2p.d.ts +4 -12
- package/dist/src/libp2p.d.ts.map +1 -1
- package/dist/src/libp2p.js +31 -65
- package/dist/src/libp2p.js.map +1 -1
- package/dist/src/peer-routing.d.ts +6 -6
- package/dist/src/peer-routing.d.ts.map +1 -1
- package/dist/src/peer-routing.js +12 -9
- package/dist/src/peer-routing.js.map +1 -1
- package/dist/src/registrar.d.ts +5 -7
- package/dist/src/registrar.d.ts.map +1 -1
- package/dist/src/registrar.js +4 -4
- package/dist/src/registrar.js.map +1 -1
- package/dist/src/transport-manager.d.ts +5 -9
- package/dist/src/transport-manager.d.ts.map +1 -1
- package/dist/src/transport-manager.js +12 -13
- package/dist/src/transport-manager.js.map +1 -1
- package/dist/src/upgrader.d.ts +8 -19
- package/dist/src/upgrader.d.ts.map +1 -1
- package/dist/src/upgrader.js +75 -38
- 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/dist/typedoc-urls.json +8 -69
- package/package.json +37 -106
- package/src/address-manager/index.ts +6 -9
- package/src/components.ts +5 -16
- package/src/config/connection-gater.browser.ts +1 -1
- package/src/config/connection-gater.ts +1 -1
- package/src/config.ts +1 -2
- package/src/connection/index.ts +12 -17
- package/src/connection-manager/auto-dial.ts +23 -26
- package/src/connection-manager/connection-pruner.ts +10 -12
- package/src/connection-manager/constants.defaults.ts +0 -5
- package/src/connection-manager/dial-queue.ts +31 -46
- package/src/connection-manager/index.ts +19 -36
- package/src/connection-manager/utils.ts +1 -1
- package/src/content-routing/index.ts +3 -7
- package/src/content-routing/utils.ts +2 -3
- package/src/errors.ts +0 -2
- package/src/get-peer.ts +2 -7
- package/src/index.ts +6 -17
- package/src/libp2p.ts +32 -80
- package/src/peer-routing.ts +16 -15
- package/src/registrar.ts +8 -12
- package/src/transport-manager.ts +15 -22
- package/src/upgrader.ts +110 -64
- package/src/version.ts +1 -1
- package/dist/src/autonat/constants.d.ts +0 -18
- package/dist/src/autonat/constants.d.ts.map +0 -1
- package/dist/src/autonat/constants.js +0 -18
- package/dist/src/autonat/constants.js.map +0 -1
- package/dist/src/autonat/index.d.ts +0 -62
- package/dist/src/autonat/index.d.ts.map +0 -1
- package/dist/src/autonat/index.js +0 -447
- package/dist/src/autonat/index.js.map +0 -1
- package/dist/src/autonat/pb/index.d.ts +0 -57
- package/dist/src/autonat/pb/index.d.ts.map +0 -1
- package/dist/src/autonat/pb/index.js +0 -250
- package/dist/src/autonat/pb/index.js.map +0 -1
- package/dist/src/circuit-relay/constants.d.ts +0 -50
- package/dist/src/circuit-relay/constants.d.ts.map +0 -1
- package/dist/src/circuit-relay/constants.js +0 -56
- package/dist/src/circuit-relay/constants.js.map +0 -1
- package/dist/src/circuit-relay/index.d.ts +0 -55
- package/dist/src/circuit-relay/index.d.ts.map +0 -1
- package/dist/src/circuit-relay/index.js +0 -38
- package/dist/src/circuit-relay/index.js.map +0 -1
- package/dist/src/circuit-relay/pb/index.d.ts +0 -93
- package/dist/src/circuit-relay/pb/index.d.ts.map +0 -1
- package/dist/src/circuit-relay/pb/index.js +0 -425
- package/dist/src/circuit-relay/pb/index.js.map +0 -1
- package/dist/src/circuit-relay/server/advert-service.d.ts +0 -43
- package/dist/src/circuit-relay/server/advert-service.d.ts.map +0 -1
- package/dist/src/circuit-relay/server/advert-service.js +0 -73
- package/dist/src/circuit-relay/server/advert-service.js.map +0 -1
- package/dist/src/circuit-relay/server/index.d.ts +0 -65
- package/dist/src/circuit-relay/server/index.d.ts.map +0 -1
- package/dist/src/circuit-relay/server/index.js +0 -312
- package/dist/src/circuit-relay/server/index.js.map +0 -1
- package/dist/src/circuit-relay/server/reservation-store.d.ts +0 -49
- package/dist/src/circuit-relay/server/reservation-store.d.ts.map +0 -1
- package/dist/src/circuit-relay/server/reservation-store.js +0 -65
- package/dist/src/circuit-relay/server/reservation-store.js.map +0 -1
- package/dist/src/circuit-relay/server/reservation-voucher.d.ts +0 -18
- package/dist/src/circuit-relay/server/reservation-voucher.d.ts.map +0 -1
- package/dist/src/circuit-relay/server/reservation-voucher.js +0 -36
- package/dist/src/circuit-relay/server/reservation-voucher.js.map +0 -1
- package/dist/src/circuit-relay/transport/discovery.d.ts +0 -45
- package/dist/src/circuit-relay/transport/discovery.d.ts.map +0 -1
- package/dist/src/circuit-relay/transport/discovery.js +0 -97
- package/dist/src/circuit-relay/transport/discovery.js.map +0 -1
- package/dist/src/circuit-relay/transport/index.d.ts +0 -57
- package/dist/src/circuit-relay/transport/index.d.ts.map +0 -1
- package/dist/src/circuit-relay/transport/index.js +0 -276
- package/dist/src/circuit-relay/transport/index.js.map +0 -1
- package/dist/src/circuit-relay/transport/listener.d.ts +0 -9
- package/dist/src/circuit-relay/transport/listener.d.ts.map +0 -1
- package/dist/src/circuit-relay/transport/listener.js +0 -66
- package/dist/src/circuit-relay/transport/listener.js.map +0 -1
- package/dist/src/circuit-relay/transport/reservation-store.d.ts +0 -72
- package/dist/src/circuit-relay/transport/reservation-store.d.ts.map +0 -1
- package/dist/src/circuit-relay/transport/reservation-store.js +0 -209
- package/dist/src/circuit-relay/transport/reservation-store.js.map +0 -1
- package/dist/src/circuit-relay/utils.d.ts +0 -13
- package/dist/src/circuit-relay/utils.d.ts.map +0 -1
- package/dist/src/circuit-relay/utils.js +0 -108
- package/dist/src/circuit-relay/utils.js.map +0 -1
- package/dist/src/dcutr/dcutr.d.ts +0 -43
- package/dist/src/dcutr/dcutr.d.ts.map +0 -1
- package/dist/src/dcutr/dcutr.js +0 -313
- package/dist/src/dcutr/dcutr.js.map +0 -1
- package/dist/src/dcutr/index.d.ts +0 -92
- package/dist/src/dcutr/index.d.ts.map +0 -1
- package/dist/src/dcutr/index.js +0 -63
- package/dist/src/dcutr/index.js.map +0 -1
- package/dist/src/dcutr/pb/message.d.ts +0 -20
- package/dist/src/dcutr/pb/message.d.ts.map +0 -1
- package/dist/src/dcutr/pb/message.js +0 -77
- package/dist/src/dcutr/pb/message.js.map +0 -1
- package/dist/src/dcutr/utils.d.ts +0 -8
- package/dist/src/dcutr/utils.d.ts.map +0 -1
- package/dist/src/dcutr/utils.js +0 -27
- package/dist/src/dcutr/utils.js.map +0 -1
- package/dist/src/fetch/constants.d.ts +0 -3
- package/dist/src/fetch/constants.d.ts.map +0 -1
- package/dist/src/fetch/constants.js +0 -4
- package/dist/src/fetch/constants.js.map +0 -1
- package/dist/src/fetch/index.d.ts +0 -61
- package/dist/src/fetch/index.d.ts.map +0 -1
- package/dist/src/fetch/index.js +0 -205
- package/dist/src/fetch/index.js.map +0 -1
- package/dist/src/fetch/pb/proto.d.ts +0 -28
- package/dist/src/fetch/pb/proto.d.ts.map +0 -1
- package/dist/src/fetch/pb/proto.js +0 -120
- package/dist/src/fetch/pb/proto.js.map +0 -1
- package/dist/src/identify/consts.d.ts +0 -10
- package/dist/src/identify/consts.d.ts.map +0 -1
- package/dist/src/identify/consts.js +0 -11
- package/dist/src/identify/consts.js.map +0 -1
- package/dist/src/identify/identify.d.ts +0 -54
- package/dist/src/identify/identify.d.ts.map +0 -1
- package/dist/src/identify/identify.js +0 -447
- package/dist/src/identify/identify.js.map +0 -1
- package/dist/src/identify/index.d.ts +0 -72
- package/dist/src/identify/index.d.ts.map +0 -1
- package/dist/src/identify/index.js +0 -15
- package/dist/src/identify/index.js.map +0 -1
- package/dist/src/identify/pb/message.d.ts +0 -17
- package/dist/src/identify/pb/message.d.ts.map +0 -1
- package/dist/src/identify/pb/message.js +0 -98
- package/dist/src/identify/pb/message.js.map +0 -1
- package/dist/src/insecure/index.d.ts +0 -26
- package/dist/src/insecure/index.d.ts.map +0 -1
- package/dist/src/insecure/index.js +0 -110
- package/dist/src/insecure/index.js.map +0 -1
- package/dist/src/insecure/pb/proto.d.ts +0 -30
- package/dist/src/insecure/pb/proto.d.ts.map +0 -1
- package/dist/src/insecure/pb/proto.js +0 -127
- package/dist/src/insecure/pb/proto.js.map +0 -1
- package/dist/src/ping/constants.d.ts +0 -9
- package/dist/src/ping/constants.d.ts.map +0 -1
- package/dist/src/ping/constants.js +0 -15
- package/dist/src/ping/constants.js.map +0 -1
- package/dist/src/ping/index.d.ts +0 -24
- package/dist/src/ping/index.d.ts.map +0 -1
- package/dist/src/ping/index.js +0 -115
- package/dist/src/ping/index.js.map +0 -1
- package/dist/src/pnet/crypto.d.ts +0 -18
- package/dist/src/pnet/crypto.d.ts.map +0 -1
- package/dist/src/pnet/crypto.js +0 -60
- package/dist/src/pnet/crypto.js.map +0 -1
- package/dist/src/pnet/errors.d.ts +0 -6
- package/dist/src/pnet/errors.d.ts.map +0 -1
- package/dist/src/pnet/errors.js +0 -6
- package/dist/src/pnet/errors.js.map +0 -1
- package/dist/src/pnet/index.d.ts +0 -31
- package/dist/src/pnet/index.d.ts.map +0 -1
- package/dist/src/pnet/index.js +0 -97
- package/dist/src/pnet/index.js.map +0 -1
- package/dist/src/pnet/key-generator.d.ts +0 -11
- package/dist/src/pnet/key-generator.d.ts.map +0 -1
- package/dist/src/pnet/key-generator.js +0 -22
- package/dist/src/pnet/key-generator.js.map +0 -1
- package/dist/src/upnp-nat/index.d.ts +0 -71
- package/dist/src/upnp-nat/index.d.ts.map +0 -1
- package/dist/src/upnp-nat/index.js +0 -136
- package/dist/src/upnp-nat/index.js.map +0 -1
- package/dist/src/utils/peer-job-queue.d.ts +0 -33
- package/dist/src/utils/peer-job-queue.d.ts.map +0 -1
- package/dist/src/utils/peer-job-queue.js +0 -82
- package/dist/src/utils/peer-job-queue.js.map +0 -1
- package/src/autonat/constants.ts +0 -19
- package/src/autonat/index.ts +0 -597
- package/src/autonat/pb/index.proto +0 -35
- package/src/autonat/pb/index.ts +0 -320
- package/src/circuit-relay/constants.ts +0 -72
- package/src/circuit-relay/index.ts +0 -59
- package/src/circuit-relay/pb/index.proto +0 -67
- package/src/circuit-relay/pb/index.ts +0 -539
- package/src/circuit-relay/server/advert-service.ts +0 -108
- package/src/circuit-relay/server/index.ts +0 -443
- package/src/circuit-relay/server/reservation-store.ts +0 -116
- package/src/circuit-relay/server/reservation-voucher.ts +0 -51
- package/src/circuit-relay/transport/discovery.ts +0 -136
- package/src/circuit-relay/transport/index.ts +0 -396
- package/src/circuit-relay/transport/listener.ts +0 -97
- package/src/circuit-relay/transport/reservation-store.ts +0 -312
- package/src/circuit-relay/utils.ts +0 -136
- package/src/dcutr/dcutr.ts +0 -378
- package/src/dcutr/index.ts +0 -102
- package/src/dcutr/pb/message.proto +0 -12
- package/src/dcutr/pb/message.ts +0 -96
- package/src/dcutr/utils.ts +0 -33
- package/src/fetch/README.md +0 -41
- package/src/fetch/constants.ts +0 -3
- package/src/fetch/index.ts +0 -315
- package/src/fetch/pb/proto.proto +0 -15
- package/src/fetch/pb/proto.ts +0 -153
- package/src/identify/README.md +0 -13
- package/src/identify/consts.ts +0 -12
- package/src/identify/identify.ts +0 -561
- package/src/identify/index.ts +0 -90
- package/src/identify/pb/message.proto +0 -30
- package/src/identify/pb/message.ts +0 -126
- package/src/insecure/index.ts +0 -138
- package/src/insecure/pb/proto.proto +0 -18
- package/src/insecure/pb/proto.ts +0 -161
- package/src/ping/constants.ts +0 -15
- package/src/ping/index.ts +0 -170
- package/src/pnet/README.md +0 -68
- package/src/pnet/crypto.ts +0 -67
- package/src/pnet/errors.ts +0 -5
- package/src/pnet/index.ts +0 -126
- package/src/pnet/key-generator.ts +0 -23
- package/src/upnp-nat/index.ts +0 -212
- package/src/utils/peer-job-queue.ts +0 -119
package/dist/typedoc-urls.json
CHANGED
|
@@ -1,71 +1,10 @@
|
|
|
1
1
|
{
|
|
2
|
-
"
|
|
3
|
-
"
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
"
|
|
8
|
-
"
|
|
9
|
-
"
|
|
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"
|
|
2
|
+
"Libp2pInit": "https://libp2p.github.io/js-libp2p/interfaces/libp2p.Libp2pInit.html",
|
|
3
|
+
".:Libp2pInit": "https://libp2p.github.io/js-libp2p/interfaces/libp2p.Libp2pInit.html",
|
|
4
|
+
"Libp2pOptions": "https://libp2p.github.io/js-libp2p/types/libp2p.Libp2pOptions.html",
|
|
5
|
+
".:Libp2pOptions": "https://libp2p.github.io/js-libp2p/types/libp2p.Libp2pOptions.html",
|
|
6
|
+
"ServiceFactoryMap": "https://libp2p.github.io/js-libp2p/types/libp2p.ServiceFactoryMap.html",
|
|
7
|
+
".:ServiceFactoryMap": "https://libp2p.github.io/js-libp2p/types/libp2p.ServiceFactoryMap.html",
|
|
8
|
+
"createLibp2p": "https://libp2p.github.io/js-libp2p/functions/libp2p.createLibp2p.html",
|
|
9
|
+
".:createLibp2p": "https://libp2p.github.io/js-libp2p/functions/libp2p.createLibp2p.html"
|
|
71
10
|
}
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "libp2p",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "JavaScript implementation of libp2p, a modular peer to peer network stack",
|
|
5
5
|
"license": "Apache-2.0 OR MIT",
|
|
6
|
-
"homepage": "https://github.com/libp2p/js-libp2p/tree/
|
|
6
|
+
"homepage": "https://github.com/libp2p/js-libp2p/tree/main/packages/libp2p#readme",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
9
9
|
"url": "git+https://github.com/libp2p/js-libp2p.git"
|
|
@@ -11,6 +11,9 @@
|
|
|
11
11
|
"bugs": {
|
|
12
12
|
"url": "https://github.com/libp2p/js-libp2p/issues"
|
|
13
13
|
},
|
|
14
|
+
"publishConfig": {
|
|
15
|
+
"provenance": true
|
|
16
|
+
},
|
|
14
17
|
"keywords": [
|
|
15
18
|
"IPFS",
|
|
16
19
|
"libp2p",
|
|
@@ -21,22 +24,6 @@
|
|
|
21
24
|
],
|
|
22
25
|
"type": "module",
|
|
23
26
|
"types": "./dist/src/index.d.ts",
|
|
24
|
-
"typesVersions": {
|
|
25
|
-
"*": {
|
|
26
|
-
"*": [
|
|
27
|
-
"*",
|
|
28
|
-
"dist/*",
|
|
29
|
-
"dist/src/*",
|
|
30
|
-
"dist/src/*/index"
|
|
31
|
-
],
|
|
32
|
-
"src/*": [
|
|
33
|
-
"*",
|
|
34
|
-
"dist/*",
|
|
35
|
-
"dist/src/*",
|
|
36
|
-
"dist/src/*/index"
|
|
37
|
-
]
|
|
38
|
-
}
|
|
39
|
-
},
|
|
40
27
|
"files": [
|
|
41
28
|
"src",
|
|
42
29
|
"dist",
|
|
@@ -47,42 +34,6 @@
|
|
|
47
34
|
".": {
|
|
48
35
|
"types": "./dist/src/index.d.ts",
|
|
49
36
|
"import": "./dist/src/index.js"
|
|
50
|
-
},
|
|
51
|
-
"./autonat": {
|
|
52
|
-
"types": "./dist/src/autonat/index.d.ts",
|
|
53
|
-
"import": "./dist/src/autonat/index.js"
|
|
54
|
-
},
|
|
55
|
-
"./circuit-relay": {
|
|
56
|
-
"types": "./dist/src/circuit-relay/index.d.ts",
|
|
57
|
-
"import": "./dist/src/circuit-relay/index.js"
|
|
58
|
-
},
|
|
59
|
-
"./dcutr": {
|
|
60
|
-
"types": "./dist/src/dcutr/index.d.ts",
|
|
61
|
-
"import": "./dist/src/dcutr/index.js"
|
|
62
|
-
},
|
|
63
|
-
"./fetch": {
|
|
64
|
-
"types": "./dist/src/fetch/index.d.ts",
|
|
65
|
-
"import": "./dist/src/fetch/index.js"
|
|
66
|
-
},
|
|
67
|
-
"./identify": {
|
|
68
|
-
"types": "./dist/src/identify/index.d.ts",
|
|
69
|
-
"import": "./dist/src/identify/index.js"
|
|
70
|
-
},
|
|
71
|
-
"./insecure": {
|
|
72
|
-
"types": "./dist/src/insecure/index.d.ts",
|
|
73
|
-
"import": "./dist/src/insecure/index.js"
|
|
74
|
-
},
|
|
75
|
-
"./ping": {
|
|
76
|
-
"types": "./dist/src/ping/index.d.ts",
|
|
77
|
-
"import": "./dist/src/ping/index.js"
|
|
78
|
-
},
|
|
79
|
-
"./pnet": {
|
|
80
|
-
"types": "./dist/src/pnet/index.d.ts",
|
|
81
|
-
"import": "./dist/src/pnet/index.js"
|
|
82
|
-
},
|
|
83
|
-
"./upnp-nat": {
|
|
84
|
-
"types": "./dist/src/upnp-nat/index.d.ts",
|
|
85
|
-
"import": "./dist/src/upnp-nat/index.js"
|
|
86
37
|
}
|
|
87
38
|
},
|
|
88
39
|
"eslintConfig": {
|
|
@@ -103,13 +54,6 @@
|
|
|
103
54
|
"dep-check": "aegir dep-check",
|
|
104
55
|
"prepublishOnly": "node scripts/update-version.js && npm run build",
|
|
105
56
|
"build": "aegir build",
|
|
106
|
-
"generate": "run-s generate:proto:*",
|
|
107
|
-
"generate:proto:autonat": "protons ./src/autonat/pb/index.proto",
|
|
108
|
-
"generate:proto:circuit-relay": "protons ./src/circuit-relay/pb/index.proto",
|
|
109
|
-
"generate:proto:dcutr": "protons ./src/dcutr/pb/message.proto",
|
|
110
|
-
"generate:proto:fetch": "protons ./src/fetch/pb/proto.proto",
|
|
111
|
-
"generate:proto:identify": "protons ./src/identify/pb/message.proto",
|
|
112
|
-
"generate:proto:plaintext": "protons ./src/insecure/pb/proto.proto",
|
|
113
57
|
"test": "aegir test",
|
|
114
58
|
"test:node": "aegir test -t node -f \"./dist/test/**/*.{node,spec}.js\" --cov",
|
|
115
59
|
"test:chrome": "aegir test -t browser -f \"./dist/test/**/*.spec.js\" --cov",
|
|
@@ -120,22 +64,19 @@
|
|
|
120
64
|
"test:interop": "aegir test -t node -f dist/test/interop.js"
|
|
121
65
|
},
|
|
122
66
|
"dependencies": {
|
|
123
|
-
"@
|
|
124
|
-
"@libp2p/
|
|
125
|
-
"@libp2p/interface": "^0.1.
|
|
126
|
-
"@libp2p/
|
|
127
|
-
"@libp2p/
|
|
128
|
-
"@libp2p/
|
|
129
|
-
"@libp2p/
|
|
130
|
-
"@libp2p/peer-
|
|
131
|
-
"@libp2p/peer-
|
|
132
|
-
"@libp2p/
|
|
133
|
-
"@
|
|
134
|
-
"@
|
|
135
|
-
"@
|
|
136
|
-
"@multiformats/mafmt": "^12.1.2",
|
|
137
|
-
"@multiformats/multiaddr": "^12.1.5",
|
|
138
|
-
"@multiformats/multiaddr-matcher": "^1.0.0",
|
|
67
|
+
"@libp2p/crypto": "^3.0.0",
|
|
68
|
+
"@libp2p/interface": "^1.0.0",
|
|
69
|
+
"@libp2p/interface-internal": "^0.1.10",
|
|
70
|
+
"@libp2p/logger": "^4.0.0",
|
|
71
|
+
"@libp2p/multistream-select": "^4.0.7",
|
|
72
|
+
"@libp2p/peer-collections": "^4.0.9",
|
|
73
|
+
"@libp2p/peer-id": "^4.0.0",
|
|
74
|
+
"@libp2p/peer-id-factory": "^3.0.9",
|
|
75
|
+
"@libp2p/peer-store": "^9.0.10",
|
|
76
|
+
"@libp2p/utils": "^5.0.0",
|
|
77
|
+
"@multiformats/mafmt": "^12.1.6",
|
|
78
|
+
"@multiformats/multiaddr": "^12.1.10",
|
|
79
|
+
"@multiformats/multiaddr-matcher": "^1.1.0",
|
|
139
80
|
"any-signal": "^4.1.1",
|
|
140
81
|
"datastore-core": "^9.0.1",
|
|
141
82
|
"delay": "^6.0.0",
|
|
@@ -143,55 +84,45 @@
|
|
|
143
84
|
"it-all": "^3.0.2",
|
|
144
85
|
"it-drain": "^3.0.2",
|
|
145
86
|
"it-filter": "^3.0.1",
|
|
146
|
-
"it-first": "^3.0.
|
|
147
|
-
"it-
|
|
148
|
-
"it-length-prefixed": "^9.0.1",
|
|
149
|
-
"it-map": "^3.0.3",
|
|
87
|
+
"it-first": "^3.0.3",
|
|
88
|
+
"it-map": "^3.0.4",
|
|
150
89
|
"it-merge": "^3.0.0",
|
|
151
|
-
"it-pair": "^2.0.6",
|
|
152
|
-
"it-parallel": "^3.0.0",
|
|
153
90
|
"it-pipe": "^3.0.1",
|
|
154
|
-
"it-protobuf-stream": "^1.0.0",
|
|
155
91
|
"it-stream-types": "^2.0.1",
|
|
156
92
|
"merge-options": "^3.0.4",
|
|
157
|
-
"multiformats": "^12.
|
|
93
|
+
"multiformats": "^12.1.3",
|
|
158
94
|
"p-defer": "^4.0.0",
|
|
159
|
-
"p-queue": "^7.
|
|
160
|
-
"
|
|
161
|
-
"private-ip": "^3.0.0",
|
|
162
|
-
"protons-runtime": "^5.0.0",
|
|
95
|
+
"p-queue": "^7.4.1",
|
|
96
|
+
"private-ip": "^3.0.1",
|
|
163
97
|
"rate-limiter-flexible": "^3.0.0",
|
|
164
98
|
"uint8arraylist": "^2.4.3",
|
|
165
|
-
"uint8arrays": "^4.0.6"
|
|
166
|
-
"wherearewe": "^2.0.1",
|
|
167
|
-
"xsalsa20": "^1.1.0"
|
|
99
|
+
"uint8arrays": "^4.0.6"
|
|
168
100
|
},
|
|
169
101
|
"devDependencies": {
|
|
170
102
|
"@chainsafe/libp2p-gossipsub": "^10.0.0",
|
|
171
|
-
"@chainsafe/libp2p-noise": "^13.0.
|
|
103
|
+
"@chainsafe/libp2p-noise": "^13.0.2",
|
|
172
104
|
"@chainsafe/libp2p-yamux": "^5.0.0",
|
|
173
|
-
"@libp2p/bootstrap": "^
|
|
105
|
+
"@libp2p/bootstrap": "^10.0.0",
|
|
106
|
+
"@libp2p/circuit-relay-v2": "^1.0.0",
|
|
174
107
|
"@libp2p/daemon-client": "^7.0.0",
|
|
175
108
|
"@libp2p/daemon-server": "^6.0.0",
|
|
176
|
-
"@libp2p/floodsub": "^8.0.
|
|
177
|
-
"@libp2p/
|
|
109
|
+
"@libp2p/floodsub": "^8.0.14",
|
|
110
|
+
"@libp2p/identify": "^1.0.0",
|
|
111
|
+
"@libp2p/interface-compliance-tests": "^5.0.0",
|
|
178
112
|
"@libp2p/interop": "^9.0.0",
|
|
179
|
-
"@libp2p/kad-dht": "^
|
|
180
|
-
"@libp2p/mdns": "^
|
|
181
|
-
"@libp2p/mplex": "^
|
|
182
|
-
"@libp2p/
|
|
183
|
-
"@libp2p/
|
|
184
|
-
"@
|
|
113
|
+
"@libp2p/kad-dht": "^11.0.0",
|
|
114
|
+
"@libp2p/mdns": "^10.0.0",
|
|
115
|
+
"@libp2p/mplex": "^10.0.0",
|
|
116
|
+
"@libp2p/plaintext": "^1.0.0",
|
|
117
|
+
"@libp2p/tcp": "^9.0.0",
|
|
118
|
+
"@libp2p/websockets": "^8.0.0",
|
|
185
119
|
"aegir": "^41.0.2",
|
|
186
120
|
"execa": "^8.0.1",
|
|
187
121
|
"go-libp2p": "^1.1.1",
|
|
188
|
-
"it-pushable": "^3.2.
|
|
189
|
-
"it-to-buffer": "^4.0.1",
|
|
190
|
-
"npm-run-all": "^4.1.5",
|
|
122
|
+
"it-pushable": "^3.2.1",
|
|
191
123
|
"p-event": "^6.0.0",
|
|
192
124
|
"p-times": "^4.0.0",
|
|
193
125
|
"p-wait-for": "^5.0.2",
|
|
194
|
-
"protons": "^7.0.2",
|
|
195
126
|
"sinon": "^17.0.0",
|
|
196
127
|
"sinon-ts": "^2.0.0"
|
|
197
128
|
},
|
|
@@ -1,16 +1,10 @@
|
|
|
1
|
-
import { logger } from '@libp2p/logger'
|
|
2
1
|
import { peerIdFromString } from '@libp2p/peer-id'
|
|
3
2
|
import { multiaddr } from '@multiformats/multiaddr'
|
|
4
3
|
import { debounce } from './utils.js'
|
|
5
|
-
import type { Libp2pEvents } from '@libp2p/interface'
|
|
6
|
-
import type {
|
|
7
|
-
import type { PeerId } from '@libp2p/interface/peer-id'
|
|
8
|
-
import type { PeerStore } from '@libp2p/interface/peer-store'
|
|
9
|
-
import type { TransportManager } from '@libp2p/interface-internal/transport-manager'
|
|
4
|
+
import type { ComponentLogger, Libp2pEvents, Logger, TypedEventTarget, PeerId, PeerStore } from '@libp2p/interface'
|
|
5
|
+
import type { TransportManager } from '@libp2p/interface-internal'
|
|
10
6
|
import type { Multiaddr } from '@multiformats/multiaddr'
|
|
11
7
|
|
|
12
|
-
const log = logger('libp2p:address-manager')
|
|
13
|
-
|
|
14
8
|
export interface AddressManagerInit {
|
|
15
9
|
/**
|
|
16
10
|
* Pass an function in this field to override the list of addresses
|
|
@@ -39,6 +33,7 @@ export interface DefaultAddressManagerComponents {
|
|
|
39
33
|
transportManager: TransportManager
|
|
40
34
|
peerStore: PeerStore
|
|
41
35
|
events: TypedEventTarget<Libp2pEvents>
|
|
36
|
+
logger: ComponentLogger
|
|
42
37
|
}
|
|
43
38
|
|
|
44
39
|
/**
|
|
@@ -75,6 +70,7 @@ function stripPeerId (ma: Multiaddr, peerId: PeerId): Multiaddr {
|
|
|
75
70
|
}
|
|
76
71
|
|
|
77
72
|
export class DefaultAddressManager {
|
|
73
|
+
private readonly log: Logger
|
|
78
74
|
private readonly components: DefaultAddressManagerComponents
|
|
79
75
|
// this is an array to allow for duplicates, e.g. multiples of `/ip4/0.0.0.0/tcp/0`
|
|
80
76
|
private readonly listen: string[]
|
|
@@ -92,6 +88,7 @@ export class DefaultAddressManager {
|
|
|
92
88
|
const { listen = [], announce = [] } = init
|
|
93
89
|
|
|
94
90
|
this.components = components
|
|
91
|
+
this.log = components.logger.forComponent('libp2p:address-manager')
|
|
95
92
|
this.listen = listen.map(ma => ma.toString())
|
|
96
93
|
this.announce = new Set(announce.map(ma => ma.toString()))
|
|
97
94
|
this.observed = new Map()
|
|
@@ -132,7 +129,7 @@ export class DefaultAddressManager {
|
|
|
132
129
|
this.components.peerStore.patch(this.components.peerId, {
|
|
133
130
|
multiaddrs: addrs
|
|
134
131
|
})
|
|
135
|
-
.catch(err => { log.error('error updating addresses', err) })
|
|
132
|
+
.catch(err => { this.log.error('error updating addresses', err) })
|
|
136
133
|
}
|
|
137
134
|
|
|
138
135
|
/**
|
package/src/components.ts
CHANGED
|
@@ -1,24 +1,12 @@
|
|
|
1
|
-
import { CodeError } from '@libp2p/interface
|
|
2
|
-
import { isStartable, type Startable } from '@libp2p/interface
|
|
1
|
+
import { CodeError } from '@libp2p/interface'
|
|
2
|
+
import { isStartable, type Startable, type Libp2pEvents, type ComponentLogger, type NodeInfo, type ConnectionProtector, type ConnectionGater, type ContentRouting, type TypedEventTarget, type Metrics, type PeerId, type PeerRouting, type PeerStore, type Upgrader } from '@libp2p/interface'
|
|
3
3
|
import { defaultLogger } from '@libp2p/logger'
|
|
4
|
-
import type {
|
|
5
|
-
import type { ConnectionProtector } from '@libp2p/interface/connection'
|
|
6
|
-
import type { ConnectionGater } from '@libp2p/interface/connection-gater'
|
|
7
|
-
import type { ContentRouting } from '@libp2p/interface/content-routing'
|
|
8
|
-
import type { TypedEventTarget } from '@libp2p/interface/events'
|
|
9
|
-
import type { Metrics } from '@libp2p/interface/metrics'
|
|
10
|
-
import type { PeerId } from '@libp2p/interface/peer-id'
|
|
11
|
-
import type { PeerRouting } from '@libp2p/interface/peer-routing'
|
|
12
|
-
import type { PeerStore } from '@libp2p/interface/peer-store'
|
|
13
|
-
import type { Upgrader } from '@libp2p/interface/transport'
|
|
14
|
-
import type { AddressManager } from '@libp2p/interface-internal/address-manager'
|
|
15
|
-
import type { ConnectionManager } from '@libp2p/interface-internal/connection-manager'
|
|
16
|
-
import type { Registrar } from '@libp2p/interface-internal/registrar'
|
|
17
|
-
import type { TransportManager } from '@libp2p/interface-internal/transport-manager'
|
|
4
|
+
import type { AddressManager, ConnectionManager, Registrar, TransportManager } from '@libp2p/interface-internal'
|
|
18
5
|
import type { Datastore } from 'interface-datastore'
|
|
19
6
|
|
|
20
7
|
export interface Components extends Record<string, any>, Startable {
|
|
21
8
|
peerId: PeerId
|
|
9
|
+
nodeInfo: NodeInfo
|
|
22
10
|
logger: ComponentLogger
|
|
23
11
|
events: TypedEventTarget<Libp2pEvents>
|
|
24
12
|
addressManager: AddressManager
|
|
@@ -37,6 +25,7 @@ export interface Components extends Record<string, any>, Startable {
|
|
|
37
25
|
|
|
38
26
|
export interface ComponentsInit {
|
|
39
27
|
peerId?: PeerId
|
|
28
|
+
nodeInfo?: NodeInfo
|
|
40
29
|
logger?: ComponentLogger
|
|
41
30
|
events?: TypedEventTarget<Libp2pEvents>
|
|
42
31
|
addressManager?: AddressManager
|
package/src/config.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { CodeError } from '@libp2p/interface
|
|
2
|
-
import { FaultTolerance } from '@libp2p/interface/transport'
|
|
1
|
+
import { CodeError, FaultTolerance } from '@libp2p/interface'
|
|
3
2
|
import { defaultAddressSort } from '@libp2p/utils/address-sort'
|
|
4
3
|
import { dnsaddrResolver } from '@multiformats/multiaddr/resolvers'
|
|
5
4
|
import mergeOptions from 'merge-options'
|
package/src/connection/index.ts
CHANGED
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { setMaxListeners } from '@libp2p/interface/events'
|
|
4
|
-
import type { AbortOptions, Logger, ComponentLogger } from '@libp2p/interface'
|
|
5
|
-
import type { Direction, Connection, Stream, ConnectionTimeline, ConnectionStatus, NewStreamOptions } from '@libp2p/interface/connection'
|
|
6
|
-
import type { PeerId } from '@libp2p/interface/peer-id'
|
|
1
|
+
import { connectionSymbol, CodeError, setMaxListeners } from '@libp2p/interface'
|
|
2
|
+
import type { AbortOptions, Logger, ComponentLogger, Direction, Connection, Stream, ConnectionTimeline, ConnectionStatus, NewStreamOptions, PeerId } from '@libp2p/interface'
|
|
7
3
|
import type { Multiaddr } from '@multiformats/multiaddr'
|
|
8
4
|
|
|
9
5
|
const CLOSE_TIMEOUT = 500
|
|
@@ -50,6 +46,7 @@ export class ConnectionImpl implements Connection {
|
|
|
50
46
|
public encryption?: string
|
|
51
47
|
public status: ConnectionStatus
|
|
52
48
|
public transient: boolean
|
|
49
|
+
public readonly log: Logger
|
|
53
50
|
|
|
54
51
|
/**
|
|
55
52
|
* User provided tags
|
|
@@ -74,8 +71,6 @@ export class ConnectionImpl implements Connection {
|
|
|
74
71
|
*/
|
|
75
72
|
private readonly _getStreams: () => Stream[]
|
|
76
73
|
|
|
77
|
-
readonly #log: Logger
|
|
78
|
-
|
|
79
74
|
/**
|
|
80
75
|
* An implementation of the js-libp2p connection.
|
|
81
76
|
* Any libp2p transport should use an upgrader to return this connection.
|
|
@@ -92,7 +87,7 @@ export class ConnectionImpl implements Connection {
|
|
|
92
87
|
this.multiplexer = init.multiplexer
|
|
93
88
|
this.encryption = init.encryption
|
|
94
89
|
this.transient = init.transient ?? false
|
|
95
|
-
this
|
|
90
|
+
this.log = init.logger.forComponent(`libp2p:connection:${this.direction}:${this.id}`)
|
|
96
91
|
|
|
97
92
|
if (this.remoteAddr.getPeerId() == null) {
|
|
98
93
|
this.remoteAddr = this.remoteAddr.encapsulate(`/p2p/${this.remotePeer}`)
|
|
@@ -107,7 +102,7 @@ export class ConnectionImpl implements Connection {
|
|
|
107
102
|
|
|
108
103
|
readonly [Symbol.toStringTag] = 'Connection'
|
|
109
104
|
|
|
110
|
-
readonly [
|
|
105
|
+
readonly [connectionSymbol] = true
|
|
111
106
|
|
|
112
107
|
/**
|
|
113
108
|
* Get all the streams of the muxer
|
|
@@ -151,7 +146,7 @@ export class ConnectionImpl implements Connection {
|
|
|
151
146
|
return
|
|
152
147
|
}
|
|
153
148
|
|
|
154
|
-
this
|
|
149
|
+
this.log('closing connection to %a', this.remoteAddr)
|
|
155
150
|
|
|
156
151
|
this.status = 'closing'
|
|
157
152
|
|
|
@@ -166,35 +161,35 @@ export class ConnectionImpl implements Connection {
|
|
|
166
161
|
}
|
|
167
162
|
|
|
168
163
|
try {
|
|
169
|
-
this
|
|
164
|
+
this.log.trace('closing all streams')
|
|
170
165
|
|
|
171
166
|
// close all streams gracefully - this can throw if we're not multiplexed
|
|
172
167
|
await Promise.all(
|
|
173
168
|
this.streams.map(async s => s.close(options))
|
|
174
169
|
)
|
|
175
170
|
|
|
176
|
-
this
|
|
171
|
+
this.log.trace('closing underlying transport')
|
|
177
172
|
|
|
178
173
|
// close raw connection
|
|
179
174
|
await this._close(options)
|
|
180
175
|
|
|
181
|
-
this
|
|
176
|
+
this.log.trace('updating timeline with close time')
|
|
182
177
|
|
|
183
178
|
this.status = 'closed'
|
|
184
179
|
this.timeline.close = Date.now()
|
|
185
180
|
} catch (err: any) {
|
|
186
|
-
this
|
|
181
|
+
this.log.error('error encountered during graceful close of connection to %a', this.remoteAddr, err)
|
|
187
182
|
this.abort(err)
|
|
188
183
|
}
|
|
189
184
|
}
|
|
190
185
|
|
|
191
186
|
abort (err: Error): void {
|
|
192
|
-
this
|
|
187
|
+
this.log.error('aborting connection to %a due to error', this.remoteAddr, err)
|
|
193
188
|
|
|
194
189
|
this.status = 'closing'
|
|
195
190
|
this.streams.forEach(s => { s.abort(err) })
|
|
196
191
|
|
|
197
|
-
this
|
|
192
|
+
this.log.error('all streams aborted', this.streams.length)
|
|
198
193
|
|
|
199
194
|
// Abort raw connection
|
|
200
195
|
this._abort(err)
|