libp2p 0.36.2 → 0.37.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/LICENSE +3 -21
- package/README.md +13 -10
- package/dist/src/address-manager/index.d.ts +34 -52
- package/dist/src/address-manager/index.d.ts.map +1 -1
- package/dist/src/address-manager/index.js +81 -0
- package/dist/src/address-manager/index.js.map +1 -0
- package/dist/src/circuit/auto-relay.d.ts +24 -85
- package/dist/src/circuit/auto-relay.d.ts.map +1 -1
- package/dist/src/circuit/auto-relay.js +216 -0
- package/dist/src/circuit/auto-relay.js.map +1 -0
- package/dist/src/circuit/circuit/hop.d.ts +26 -53
- package/dist/src/circuit/circuit/hop.d.ts.map +1 -1
- package/dist/src/circuit/circuit/hop.js +138 -0
- package/dist/src/circuit/circuit/hop.js.map +1 -0
- package/dist/src/circuit/circuit/stop.d.ts +18 -10
- package/dist/src/circuit/circuit/stop.d.ts.map +1 -1
- package/dist/src/circuit/circuit/stop.js +49 -0
- package/dist/src/circuit/circuit/stop.js.map +1 -0
- package/dist/src/circuit/circuit/stream-handler.d.ts +19 -38
- package/dist/src/circuit/circuit/stream-handler.d.ts.map +1 -1
- package/dist/src/circuit/circuit/stream-handler.js +59 -0
- package/dist/src/circuit/circuit/stream-handler.js.map +1 -0
- package/dist/src/circuit/circuit/utils.d.ts +3 -6
- package/dist/src/circuit/circuit/utils.d.ts.map +1 -1
- package/dist/src/circuit/circuit/utils.js +43 -0
- package/dist/src/circuit/circuit/utils.js.map +1 -0
- package/dist/src/circuit/constants.d.ts +24 -6
- package/dist/src/circuit/constants.d.ts.map +1 -1
- package/dist/src/circuit/constants.js +26 -0
- package/dist/src/circuit/constants.js.map +1 -0
- package/dist/src/circuit/index.d.ts +41 -74
- package/dist/src/circuit/index.d.ts.map +1 -1
- package/dist/src/circuit/index.js +69 -0
- package/dist/src/circuit/index.js.map +1 -0
- package/dist/src/circuit/listener.d.ts +8 -3
- package/dist/src/circuit/listener.d.ts.map +1 -1
- package/dist/src/circuit/listener.js +62 -0
- package/dist/src/circuit/listener.js.map +1 -0
- package/dist/src/circuit/multicodec.d.ts +1 -1
- package/dist/src/circuit/multicodec.d.ts.map +1 -1
- package/dist/src/circuit/multicodec.js +2 -0
- package/dist/src/circuit/multicodec.js.map +1 -0
- package/dist/src/circuit/pb/index.d.ts +52 -0
- package/dist/src/circuit/pb/index.d.ts.map +1 -0
- package/dist/src/circuit/pb/index.js +98 -0
- package/dist/src/circuit/pb/index.js.map +1 -0
- package/dist/src/circuit/transport.d.ts +18 -78
- package/dist/src/circuit/transport.d.ts.map +1 -1
- package/dist/src/circuit/transport.js +192 -0
- package/dist/src/circuit/transport.js.map +1 -0
- package/dist/src/circuit/utils.d.ts +5 -2
- package/dist/src/circuit/utils.d.ts.map +1 -1
- package/dist/src/circuit/utils.js +11 -0
- package/dist/src/circuit/utils.js.map +1 -0
- package/dist/src/config.d.ts +3 -85
- package/dist/src/config.d.ts.map +1 -1
- package/dist/src/config.js +91 -0
- package/dist/src/config.js.map +1 -0
- package/dist/src/connection-manager/auto-dialler.d.ts +24 -41
- package/dist/src/connection-manager/auto-dialler.d.ts.map +1 -1
- package/dist/src/connection-manager/auto-dialler.js +105 -0
- package/dist/src/connection-manager/auto-dialler.js.map +1 -0
- package/dist/src/connection-manager/dialer/auto-dialer.d.ts +16 -0
- package/dist/src/connection-manager/dialer/auto-dialer.d.ts.map +1 -0
- package/dist/src/connection-manager/dialer/auto-dialer.js +37 -0
- package/dist/src/connection-manager/dialer/auto-dialer.js.map +1 -0
- package/dist/src/connection-manager/dialer/dial-request.d.ts +27 -0
- package/dist/src/connection-manager/dialer/dial-request.d.ts.map +1 -0
- package/dist/src/connection-manager/dialer/dial-request.js +83 -0
- package/dist/src/connection-manager/dialer/dial-request.js.map +1 -0
- package/dist/src/connection-manager/dialer/index.d.ts +104 -0
- package/dist/src/connection-manager/dialer/index.d.ts.map +1 -0
- package/dist/src/connection-manager/dialer/index.js +267 -0
- package/dist/src/connection-manager/dialer/index.js.map +1 -0
- package/dist/src/connection-manager/index.d.ts +102 -136
- package/dist/src/connection-manager/index.d.ts.map +1 -1
- package/dist/src/connection-manager/index.js +333 -0
- package/dist/src/connection-manager/index.js.map +1 -0
- package/dist/src/connection-manager/latency-monitor.d.ts +72 -97
- package/dist/src/connection-manager/latency-monitor.d.ts.map +1 -1
- package/dist/src/connection-manager/latency-monitor.js +220 -0
- package/dist/src/connection-manager/latency-monitor.js.map +1 -0
- package/dist/src/connection-manager/visibility-change-emitter.d.ts +15 -16
- package/dist/src/connection-manager/visibility-change-emitter.d.ts.map +1 -1
- package/dist/src/connection-manager/visibility-change-emitter.js +118 -0
- package/dist/src/connection-manager/visibility-change-emitter.js.map +1 -0
- package/dist/src/constants.d.ts +22 -10
- package/dist/src/constants.d.ts.map +1 -1
- package/dist/src/constants.js +27 -0
- package/dist/src/constants.js.map +1 -0
- package/dist/src/content-routing/index.d.ts +27 -81
- package/dist/src/content-routing/index.d.ts.map +1 -1
- package/dist/src/content-routing/index.js +99 -0
- package/dist/src/content-routing/index.js.map +1 -0
- package/dist/src/content-routing/utils.d.ts +6 -49
- package/dist/src/content-routing/utils.d.ts.map +1 -1
- package/dist/src/content-routing/utils.js +42 -0
- package/dist/src/content-routing/utils.js.map +1 -0
- package/dist/src/dht/dht-content-routing.d.ts +10 -24
- package/dist/src/dht/dht-content-routing.d.ts.map +1 -1
- package/dist/src/dht/dht-content-routing.js +32 -0
- package/dist/src/dht/dht-content-routing.js.map +1 -0
- package/dist/src/dht/dht-peer-routing.d.ts +9 -24
- package/dist/src/dht/dht-peer-routing.d.ts.map +1 -1
- package/dist/src/dht/dht-peer-routing.js +26 -0
- package/dist/src/dht/dht-peer-routing.js.map +1 -0
- package/dist/src/dht/dummy-dht.d.ts +20 -0
- package/dist/src/dht/dummy-dht.d.ts.map +1 -0
- package/dist/src/dht/dummy-dht.js +46 -0
- package/dist/src/dht/dummy-dht.js.map +1 -0
- package/dist/src/errors.d.ts +70 -63
- package/dist/src/errors.d.ts.map +1 -1
- package/dist/src/errors.js +75 -0
- package/dist/src/errors.js.map +1 -0
- package/dist/src/fetch/constants.d.ts +1 -1
- package/dist/src/fetch/constants.d.ts.map +1 -1
- package/dist/src/fetch/constants.js +3 -0
- package/dist/src/fetch/constants.js.map +1 -0
- package/dist/src/fetch/index.d.ts +30 -49
- package/dist/src/fetch/index.d.ts.map +1 -1
- package/dist/src/fetch/index.js +129 -0
- package/dist/src/fetch/index.js.map +1 -0
- package/dist/src/fetch/pb/proto.d.ts +27 -0
- package/dist/src/fetch/pb/proto.d.ts.map +1 -0
- package/dist/src/fetch/pb/proto.js +50 -0
- package/dist/src/fetch/pb/proto.js.map +1 -0
- package/dist/src/get-peer.d.ts +4 -11
- package/dist/src/get-peer.d.ts.map +1 -1
- package/dist/src/get-peer.js +43 -0
- package/dist/src/get-peer.js.map +1 -0
- package/dist/src/identify/consts.d.ts +9 -9
- package/dist/src/identify/consts.d.ts.map +1 -1
- package/dist/src/identify/consts.js +11 -0
- package/dist/src/identify/consts.js.map +1 -0
- package/dist/src/identify/index.d.ts +42 -96
- package/dist/src/identify/index.d.ts.map +1 -1
- package/dist/src/identify/index.js +322 -0
- package/dist/src/identify/index.js.map +1 -0
- package/dist/src/identify/pb/message.d.ts +16 -0
- package/dist/src/identify/pb/message.d.ts.map +1 -0
- package/dist/src/identify/pb/message.js +24 -0
- package/dist/src/identify/pb/message.js.map +1 -0
- package/dist/src/index.d.ts +150 -496
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +9 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/insecure/index.d.ts +9 -0
- package/dist/src/insecure/index.d.ts.map +1 -0
- package/dist/src/insecure/index.js +81 -0
- package/dist/src/insecure/index.js.map +1 -0
- package/dist/src/insecure/pb/proto.d.ts +29 -0
- package/dist/src/insecure/pb/proto.d.ts.map +1 -0
- package/dist/src/insecure/pb/proto.js +53 -0
- package/dist/src/insecure/pb/proto.js.map +1 -0
- package/dist/src/keychain/cms.d.ts +6 -14
- package/dist/src/keychain/cms.d.ts.map +1 -1
- package/dist/src/keychain/cms.js +129 -0
- package/dist/src/keychain/cms.js.map +1 -0
- package/dist/src/keychain/index.d.ts +60 -81
- package/dist/src/keychain/index.d.ts.map +1 -1
- package/dist/src/keychain/index.js +492 -0
- package/dist/src/keychain/index.js.map +1 -0
- package/dist/src/keychain/util.d.ts +3 -6
- package/dist/src/keychain/util.d.ts.map +1 -1
- package/dist/src/keychain/util.js +79 -0
- package/dist/src/keychain/util.js.map +1 -0
- package/dist/src/libp2p.d.ts +80 -0
- package/dist/src/libp2p.d.ts.map +1 -0
- package/dist/src/libp2p.js +397 -0
- package/dist/src/libp2p.js.map +1 -0
- package/dist/src/metrics/index.d.ts +47 -104
- package/dist/src/metrics/index.d.ts.map +1 -1
- package/dist/src/metrics/index.js +231 -0
- package/dist/src/metrics/index.js.map +1 -0
- package/dist/src/metrics/moving-average.d.ts +14 -0
- package/dist/src/metrics/moving-average.d.ts.map +1 -0
- package/dist/src/metrics/moving-average.js +40 -0
- package/dist/src/metrics/moving-average.js.map +1 -0
- package/dist/src/metrics/stats.d.ts +41 -93
- package/dist/src/metrics/stats.d.ts.map +1 -1
- package/dist/src/metrics/stats.js +183 -0
- package/dist/src/metrics/stats.js.map +1 -0
- package/dist/src/nat-manager.d.ts +42 -99
- package/dist/src/nat-manager.d.ts.map +1 -1
- package/dist/src/nat-manager.js +114 -0
- package/dist/src/nat-manager.js.map +1 -0
- package/dist/src/peer-record-updater.d.ts +15 -0
- package/dist/src/peer-record-updater.d.ts.map +1 -0
- package/dist/src/peer-record-updater.js +44 -0
- package/dist/src/peer-record-updater.js.map +1 -0
- package/dist/src/peer-routing.d.ts +40 -84
- package/dist/src/peer-routing.d.ts.map +1 -1
- package/dist/src/peer-routing.js +108 -0
- package/dist/src/peer-routing.js.map +1 -0
- package/dist/src/ping/constants.d.ts +4 -4
- package/dist/src/ping/constants.d.ts.map +1 -1
- package/dist/src/ping/constants.js +5 -0
- package/dist/src/ping/constants.js.map +1 -0
- package/dist/src/ping/index.d.ts +17 -31
- package/dist/src/ping/index.d.ts.map +1 -1
- package/dist/src/ping/index.js +57 -0
- package/dist/src/ping/index.js.map +1 -0
- package/dist/src/pnet/crypto.d.ts +15 -5
- package/dist/src/pnet/crypto.d.ts.map +1 -1
- package/dist/src/pnet/crypto.js +60 -0
- package/dist/src/pnet/crypto.js.map +1 -0
- package/dist/src/pnet/errors.d.ts +5 -5
- package/dist/src/pnet/errors.d.ts.map +1 -1
- package/dist/src/pnet/errors.js +6 -0
- package/dist/src/pnet/errors.js.map +1 -0
- package/dist/src/pnet/index.d.ts +12 -20
- package/dist/src/pnet/index.d.ts.map +1 -1
- package/dist/src/pnet/index.js +67 -0
- package/dist/src/pnet/index.js.map +1 -0
- package/dist/src/pnet/key-generator.d.ts +3 -7
- package/dist/src/pnet/key-generator.d.ts.map +1 -1
- package/dist/src/pnet/key-generator.js +25 -0
- package/dist/src/pnet/key-generator.js.map +1 -0
- package/dist/src/pubsub/dummy-pubsub.d.ts +17 -0
- package/dist/src/pubsub/dummy-pubsub.d.ts.map +1 -0
- package/dist/src/pubsub/dummy-pubsub.js +37 -0
- package/dist/src/pubsub/dummy-pubsub.js.map +1 -0
- package/dist/src/registrar.d.ts +26 -65
- package/dist/src/registrar.d.ts.map +1 -1
- package/dist/src/registrar.js +144 -0
- package/dist/src/registrar.js.map +1 -0
- package/dist/src/transport-manager.d.ts +36 -82
- package/dist/src/transport-manager.d.ts.map +1 -1
- package/dist/src/transport-manager.js +223 -0
- package/dist/src/transport-manager.js.map +1 -0
- package/dist/src/upgrader.d.ts +49 -129
- package/dist/src/upgrader.d.ts.map +1 -1
- package/dist/src/upgrader.js +402 -0
- package/dist/src/upgrader.js.map +1 -0
- package/dist/src/version.d.ts +3 -0
- package/dist/src/version.d.ts.map +1 -0
- package/dist/src/version.js +3 -0
- package/dist/src/version.js.map +1 -0
- package/package.json +144 -201
- package/src/address-manager/index.ts +130 -0
- package/src/circuit/README.md +16 -11
- package/src/circuit/auto-relay.ts +286 -0
- package/src/circuit/circuit/hop.ts +211 -0
- package/src/circuit/circuit/stop.ts +78 -0
- package/src/circuit/circuit/stream-handler.ts +86 -0
- package/src/circuit/circuit/{utils.js → utils.ts} +9 -25
- package/src/circuit/constants.ts +31 -0
- package/src/circuit/index.ts +120 -0
- package/src/circuit/listener.ts +82 -0
- package/src/circuit/multicodec.ts +2 -0
- package/src/circuit/{protocol → pb}/index.proto +1 -1
- package/src/circuit/pb/index.ts +117 -0
- package/src/circuit/transport.ts +219 -0
- package/src/circuit/utils.ts +12 -0
- package/src/config.ts +99 -0
- package/src/connection-manager/auto-dialler.ts +154 -0
- package/src/connection-manager/dialer/auto-dialer.ts +59 -0
- package/src/{dialer/dial-request.js → connection-manager/dialer/dial-request.ts} +60 -51
- package/src/connection-manager/dialer/index.ts +382 -0
- package/src/connection-manager/index.ts +508 -0
- package/src/connection-manager/latency-monitor.ts +319 -0
- package/src/connection-manager/{visibility-change-emitter.js → visibility-change-emitter.ts} +48 -38
- package/src/constants.ts +31 -0
- package/src/content-routing/index.ts +144 -0
- package/src/content-routing/utils.ts +54 -0
- package/src/dht/dht-content-routing.ts +43 -0
- package/src/dht/dht-peer-routing.ts +35 -0
- package/src/dht/dummy-dht.ts +60 -0
- package/src/errors.ts +73 -0
- package/src/fetch/README.md +1 -1
- package/src/fetch/constants.ts +3 -0
- package/src/fetch/index.ts +167 -0
- package/src/fetch/{proto.proto → pb/proto.proto} +0 -0
- package/src/fetch/pb/proto.ts +65 -0
- package/src/get-peer.ts +57 -0
- package/src/identify/consts.ts +13 -0
- package/src/identify/index.ts +445 -0
- package/src/identify/{message.proto → pb/message.proto} +0 -0
- package/src/identify/pb/message.ts +37 -0
- package/src/index.ts +220 -0
- package/src/insecure/index.ts +101 -0
- package/src/insecure/{proto.proto → pb/proto.proto} +0 -0
- package/src/insecure/pb/proto.ts +68 -0
- package/src/keychain/{cms.js → cms.ts} +62 -58
- package/src/keychain/index.ts +587 -0
- package/src/keychain/{util.js → util.ts} +7 -17
- package/src/libp2p.ts +538 -0
- package/src/metrics/index.ts +310 -0
- package/src/metrics/moving-average.ts +53 -0
- package/src/metrics/stats.ts +238 -0
- package/src/nat-manager.ts +194 -0
- package/src/peer-record-updater.ts +55 -0
- package/src/peer-routing.ts +186 -0
- package/src/ping/README.md +1 -1
- package/src/ping/constants.ts +5 -0
- package/src/ping/index.ts +84 -0
- package/src/pnet/README.md +2 -2
- package/src/pnet/crypto.ts +67 -0
- package/src/pnet/errors.ts +5 -0
- package/src/pnet/index.ts +97 -0
- package/src/pnet/key-generator.ts +28 -0
- package/src/pubsub/dummy-pubsub.ts +51 -0
- package/src/registrar.ts +189 -0
- package/src/transport-manager.ts +281 -0
- package/src/upgrader.ts +499 -0
- package/src/version.ts +3 -0
- package/dist/index.min.js +0 -55
- package/dist/src/circuit/protocol/index.d.ts +0 -173
- package/dist/src/dialer/dial-request.d.ts +0 -55
- package/dist/src/dialer/dial-request.d.ts.map +0 -1
- package/dist/src/dialer/index.d.ts +0 -182
- package/dist/src/dialer/index.d.ts.map +0 -1
- package/dist/src/fetch/proto.d.ts +0 -134
- package/dist/src/identify/message.d.ts +0 -95
- package/dist/src/insecure/plaintext.d.ts +0 -12
- package/dist/src/insecure/plaintext.d.ts.map +0 -1
- package/dist/src/insecure/proto.d.ts +0 -128
- package/dist/src/metrics/old-peers.d.ts +0 -3
- package/dist/src/metrics/old-peers.d.ts.map +0 -1
- package/dist/src/metrics/tracked-map.d.ts +0 -8
- package/dist/src/metrics/tracked-map.d.ts.map +0 -1
- package/dist/src/peer-store/address-book.d.ts +0 -67
- package/dist/src/peer-store/address-book.d.ts.map +0 -1
- package/dist/src/peer-store/index.d.ts +0 -58
- package/dist/src/peer-store/index.d.ts.map +0 -1
- package/dist/src/peer-store/key-book.d.ts +0 -40
- package/dist/src/peer-store/key-book.d.ts.map +0 -1
- package/dist/src/peer-store/metadata-book.d.ts +0 -58
- package/dist/src/peer-store/metadata-book.d.ts.map +0 -1
- package/dist/src/peer-store/pb/peer.d.ts +0 -222
- package/dist/src/peer-store/proto-book.d.ts +0 -43
- package/dist/src/peer-store/proto-book.d.ts.map +0 -1
- package/dist/src/peer-store/store.d.ts +0 -73
- package/dist/src/peer-store/store.d.ts.map +0 -1
- package/dist/src/peer-store/types.d.ts +0 -202
- package/dist/src/peer-store/types.d.ts.map +0 -1
- package/dist/src/ping/util.d.ts +0 -5
- package/dist/src/ping/util.d.ts.map +0 -1
- package/dist/src/pubsub-adapter.d.ts +0 -22
- package/dist/src/pubsub-adapter.d.ts.map +0 -1
- package/dist/src/record/envelope/envelope.d.ts +0 -77
- package/dist/src/record/envelope/index.d.ts +0 -80
- package/dist/src/record/envelope/index.d.ts.map +0 -1
- package/dist/src/record/peer-record/consts.d.ts +0 -4
- package/dist/src/record/peer-record/consts.d.ts.map +0 -1
- package/dist/src/record/peer-record/index.d.ts +0 -60
- package/dist/src/record/peer-record/index.d.ts.map +0 -1
- package/dist/src/record/peer-record/peer-record.d.ts +0 -133
- package/dist/src/record/utils.d.ts +0 -12
- package/dist/src/record/utils.d.ts.map +0 -1
- package/dist/src/types.d.ts +0 -90
- package/dist/src/types.d.ts.map +0 -1
- package/src/address-manager/index.js +0 -96
- package/src/circuit/auto-relay.js +0 -302
- package/src/circuit/circuit/hop.js +0 -205
- package/src/circuit/circuit/stop.js +0 -81
- package/src/circuit/circuit/stream-handler.js +0 -94
- package/src/circuit/constants.js +0 -12
- package/src/circuit/index.js +0 -102
- package/src/circuit/listener.js +0 -75
- package/src/circuit/multicodec.js +0 -5
- package/src/circuit/protocol/index.d.ts +0 -173
- package/src/circuit/protocol/index.js +0 -530
- package/src/circuit/transport.js +0 -229
- package/src/circuit/utils.js +0 -17
- package/src/config.js +0 -114
- package/src/connection-manager/auto-dialler.js +0 -132
- package/src/connection-manager/index.js +0 -374
- package/src/connection-manager/latency-monitor.js +0 -264
- package/src/constants.js +0 -18
- package/src/content-routing/index.js +0 -163
- package/src/content-routing/utils.js +0 -89
- package/src/dht/dht-content-routing.js +0 -44
- package/src/dht/dht-peer-routing.js +0 -51
- package/src/dialer/index.js +0 -376
- package/src/errors.js +0 -66
- package/src/fetch/constants.js +0 -6
- package/src/fetch/index.js +0 -159
- package/src/fetch/proto.d.ts +0 -134
- package/src/fetch/proto.js +0 -333
- package/src/get-peer.js +0 -49
- package/src/identify/consts.js +0 -15
- package/src/identify/index.js +0 -384
- package/src/identify/message.d.ts +0 -95
- package/src/identify/message.js +0 -328
- package/src/index.js +0 -813
- package/src/insecure/plaintext.js +0 -95
- package/src/insecure/proto.d.ts +0 -128
- package/src/insecure/proto.js +0 -371
- package/src/keychain/index.js +0 -561
- package/src/metrics/index.js +0 -290
- package/src/metrics/old-peers.js +0 -16
- package/src/metrics/stats.js +0 -270
- package/src/metrics/tracked-map.js +0 -94
- package/src/nat-manager.js +0 -197
- package/src/peer-routing.js +0 -176
- package/src/peer-store/README.md +0 -145
- package/src/peer-store/address-book.js +0 -382
- package/src/peer-store/index.js +0 -121
- package/src/peer-store/key-book.js +0 -141
- package/src/peer-store/metadata-book.js +0 -250
- package/src/peer-store/pb/peer.d.ts +0 -222
- package/src/peer-store/pb/peer.js +0 -643
- package/src/peer-store/pb/peer.proto +0 -31
- package/src/peer-store/proto-book.js +0 -237
- package/src/peer-store/store.js +0 -263
- package/src/peer-store/types.ts +0 -245
- package/src/ping/constants.js +0 -8
- package/src/ping/index.js +0 -84
- package/src/ping/util.js +0 -18
- package/src/pnet/crypto.js +0 -84
- package/src/pnet/errors.js +0 -7
- package/src/pnet/index.js +0 -86
- package/src/pnet/key-generator.js +0 -33
- package/src/pubsub-adapter.js +0 -61
- package/src/record/README.md +0 -130
- package/src/record/envelope/envelope.d.ts +0 -77
- package/src/record/envelope/envelope.js +0 -243
- package/src/record/envelope/envelope.proto +0 -19
- package/src/record/envelope/index.js +0 -183
- package/src/record/peer-record/consts.js +0 -14
- package/src/record/peer-record/index.js +0 -113
- package/src/record/peer-record/peer-record.d.ts +0 -133
- package/src/record/peer-record/peer-record.js +0 -367
- package/src/record/peer-record/peer-record.proto +0 -18
- package/src/record/utils.js +0 -25
- package/src/registrar.js +0 -127
- package/src/transport-manager.js +0 -269
- package/src/types.ts +0 -98
- package/src/upgrader.js +0 -492
package/src/registrar.js
DELETED
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
const debug = require('debug')
|
|
4
|
-
const log = Object.assign(debug('libp2p:registrar'), {
|
|
5
|
-
error: debug('libp2p:registrar:err')
|
|
6
|
-
})
|
|
7
|
-
const errcode = require('err-code')
|
|
8
|
-
|
|
9
|
-
const {
|
|
10
|
-
codes: { ERR_INVALID_PARAMETERS }
|
|
11
|
-
} = require('./errors')
|
|
12
|
-
const Topology = require('libp2p-interfaces/src/topology')
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* @typedef {import('peer-id')} PeerId
|
|
16
|
-
* @typedef {import('./peer-store/types').PeerStore} PeerStore
|
|
17
|
-
* @typedef {import('./connection-manager')} ConnectionManager
|
|
18
|
-
* @typedef {import('libp2p-interfaces/src/connection').Connection} Connection
|
|
19
|
-
* @typedef {import('./').HandlerProps} HandlerProps
|
|
20
|
-
*/
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
*
|
|
24
|
-
*/
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Responsible for notifying registered protocols of events in the network.
|
|
28
|
-
*/
|
|
29
|
-
class Registrar {
|
|
30
|
-
/**
|
|
31
|
-
* @param {Object} props
|
|
32
|
-
* @param {PeerStore} props.peerStore
|
|
33
|
-
* @param {ConnectionManager} props.connectionManager
|
|
34
|
-
* @class
|
|
35
|
-
*/
|
|
36
|
-
constructor ({ peerStore, connectionManager }) {
|
|
37
|
-
// Used on topology to listen for protocol changes
|
|
38
|
-
this.peerStore = peerStore
|
|
39
|
-
|
|
40
|
-
this.connectionManager = connectionManager
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Map of topologies
|
|
44
|
-
*
|
|
45
|
-
* @type {Map<string, Topology>}
|
|
46
|
-
*/
|
|
47
|
-
this.topologies = new Map()
|
|
48
|
-
|
|
49
|
-
/** @type {(protocols: string[]|string, handler: (props: HandlerProps) => void) => void} */
|
|
50
|
-
// @ts-ignore handle is not optional
|
|
51
|
-
this._handle = undefined
|
|
52
|
-
|
|
53
|
-
this._onDisconnect = this._onDisconnect.bind(this)
|
|
54
|
-
this.connectionManager.on('peer:disconnect', this._onDisconnect)
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* @returns {(protocols: string[]|string, handler: (props: HandlerProps) => void) => void}
|
|
59
|
-
*/
|
|
60
|
-
get handle () {
|
|
61
|
-
return this._handle
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* @param {(protocols: string[]|string, handler: (props: HandlerProps) => void) => void} handle
|
|
66
|
-
*/
|
|
67
|
-
set handle (handle) {
|
|
68
|
-
this._handle = handle
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* Get a connection with a peer.
|
|
73
|
-
*
|
|
74
|
-
* @param {PeerId} peerId
|
|
75
|
-
* @returns {Connection | null}
|
|
76
|
-
*/
|
|
77
|
-
getConnection (peerId) {
|
|
78
|
-
return this.connectionManager.get(peerId)
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* Register handlers for a set of multicodecs given
|
|
83
|
-
*
|
|
84
|
-
* @param {Topology} topology - protocol topology
|
|
85
|
-
* @returns {Promise<string>} registrar identifier
|
|
86
|
-
*/
|
|
87
|
-
async register (topology) {
|
|
88
|
-
if (!Topology.isTopology(topology)) {
|
|
89
|
-
log.error('topology must be an instance of interfaces/topology')
|
|
90
|
-
throw errcode(new Error('topology must be an instance of interfaces/topology'), ERR_INVALID_PARAMETERS)
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
// Create topology
|
|
94
|
-
const id = (Math.random() * 1e9).toString(36) + Date.now()
|
|
95
|
-
|
|
96
|
-
this.topologies.set(id, topology)
|
|
97
|
-
|
|
98
|
-
// Set registrar
|
|
99
|
-
await topology.setRegistrar(this)
|
|
100
|
-
|
|
101
|
-
return id
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
/**
|
|
105
|
-
* Unregister topology.
|
|
106
|
-
*
|
|
107
|
-
* @param {string} id - registrar identifier
|
|
108
|
-
* @returns {boolean} unregistered successfully
|
|
109
|
-
*/
|
|
110
|
-
unregister (id) {
|
|
111
|
-
return this.topologies.delete(id)
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* Remove a disconnected peer from the record
|
|
116
|
-
*
|
|
117
|
-
* @param {Connection} connection
|
|
118
|
-
* @returns {void}
|
|
119
|
-
*/
|
|
120
|
-
_onDisconnect (connection) {
|
|
121
|
-
for (const [, topology] of this.topologies) {
|
|
122
|
-
topology.disconnect(connection.remotePeer)
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
module.exports = Registrar
|
package/src/transport-manager.js
DELETED
|
@@ -1,269 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
const debug = require('debug')
|
|
4
|
-
const log = Object.assign(debug('libp2p:transports'), {
|
|
5
|
-
error: debug('libp2p:transports:err')
|
|
6
|
-
})
|
|
7
|
-
|
|
8
|
-
const pSettle = require('p-settle')
|
|
9
|
-
const { codes } = require('./errors')
|
|
10
|
-
const errCode = require('err-code')
|
|
11
|
-
|
|
12
|
-
const { updateSelfPeerRecord } = require('./record/utils')
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* @typedef {import('multiaddr').Multiaddr} Multiaddr
|
|
16
|
-
* @typedef {import('libp2p-interfaces/src/connection').Connection} Connection
|
|
17
|
-
* @typedef {import('libp2p-interfaces/src/transport/types').TransportFactory<any, any>} TransportFactory
|
|
18
|
-
* @typedef {import('libp2p-interfaces/src/transport/types').Transport<any, any>} Transport
|
|
19
|
-
*
|
|
20
|
-
* @typedef {Object} TransportManagerProperties
|
|
21
|
-
* @property {import('./')} libp2p
|
|
22
|
-
* @property {import('./upgrader')} upgrader
|
|
23
|
-
*
|
|
24
|
-
* @typedef {Object} TransportManagerOptions
|
|
25
|
-
* @property {number} [faultTolerance = FAULT_TOLERANCE.FATAL_ALL] - Address listen error tolerance.
|
|
26
|
-
*/
|
|
27
|
-
|
|
28
|
-
class TransportManager {
|
|
29
|
-
/**
|
|
30
|
-
* @class
|
|
31
|
-
* @param {TransportManagerProperties & TransportManagerOptions} options
|
|
32
|
-
*/
|
|
33
|
-
constructor ({ libp2p, upgrader, faultTolerance = FAULT_TOLERANCE.FATAL_ALL }) {
|
|
34
|
-
this.libp2p = libp2p
|
|
35
|
-
this.upgrader = upgrader
|
|
36
|
-
/** @type {Map<string, Transport>} */
|
|
37
|
-
this._transports = new Map()
|
|
38
|
-
this._listeners = new Map()
|
|
39
|
-
this._listenerOptions = new Map()
|
|
40
|
-
this.faultTolerance = faultTolerance
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Adds a `Transport` to the manager
|
|
45
|
-
*
|
|
46
|
-
* @param {string} key
|
|
47
|
-
* @param {TransportFactory} Transport
|
|
48
|
-
* @param {*} transportOptions - Additional options to pass to the transport
|
|
49
|
-
* @returns {void}
|
|
50
|
-
*/
|
|
51
|
-
add (key, Transport, transportOptions = {}) {
|
|
52
|
-
log('adding %s', key)
|
|
53
|
-
if (!key) {
|
|
54
|
-
throw errCode(new Error(`Transport must have a valid key, was given '${key}'`), codes.ERR_INVALID_KEY)
|
|
55
|
-
}
|
|
56
|
-
if (this._transports.has(key)) {
|
|
57
|
-
throw errCode(new Error('There is already a transport with this key'), codes.ERR_DUPLICATE_TRANSPORT)
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
const transport = new Transport({
|
|
61
|
-
...transportOptions,
|
|
62
|
-
libp2p: this.libp2p,
|
|
63
|
-
upgrader: this.upgrader
|
|
64
|
-
})
|
|
65
|
-
|
|
66
|
-
this._transports.set(key, transport)
|
|
67
|
-
this._listenerOptions.set(key, transportOptions.listenerOptions || {})
|
|
68
|
-
if (!this._listeners.has(key)) {
|
|
69
|
-
this._listeners.set(key, [])
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* Stops all listeners
|
|
75
|
-
*
|
|
76
|
-
* @async
|
|
77
|
-
*/
|
|
78
|
-
async close () {
|
|
79
|
-
const tasks = []
|
|
80
|
-
for (const [key, listeners] of this._listeners) {
|
|
81
|
-
log('closing listeners for %s', key)
|
|
82
|
-
while (listeners.length) {
|
|
83
|
-
const listener = listeners.pop()
|
|
84
|
-
listener.removeAllListeners('listening')
|
|
85
|
-
listener.removeAllListeners('close')
|
|
86
|
-
tasks.push(listener.close())
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
await Promise.all(tasks)
|
|
91
|
-
log('all listeners closed')
|
|
92
|
-
for (const key of this._listeners.keys()) {
|
|
93
|
-
this._listeners.set(key, [])
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
* Dials the given Multiaddr over it's supported transport
|
|
99
|
-
*
|
|
100
|
-
* @param {Multiaddr} ma
|
|
101
|
-
* @param {*} options
|
|
102
|
-
* @returns {Promise<Connection>}
|
|
103
|
-
*/
|
|
104
|
-
async dial (ma, options) {
|
|
105
|
-
const transport = this.transportForMultiaddr(ma)
|
|
106
|
-
if (!transport) {
|
|
107
|
-
throw errCode(new Error(`No transport available for address ${String(ma)}`), codes.ERR_TRANSPORT_UNAVAILABLE)
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
try {
|
|
111
|
-
return await transport.dial(ma, options)
|
|
112
|
-
} catch (/** @type {any} */ err) {
|
|
113
|
-
if (!err.code) err.code = codes.ERR_TRANSPORT_DIAL_FAILED
|
|
114
|
-
throw err
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
/**
|
|
119
|
-
* Returns all Multiaddr's the listeners are using
|
|
120
|
-
*
|
|
121
|
-
* @returns {Multiaddr[]}
|
|
122
|
-
*/
|
|
123
|
-
getAddrs () {
|
|
124
|
-
/** @type {Multiaddr[]} */
|
|
125
|
-
let addrs = []
|
|
126
|
-
for (const listeners of this._listeners.values()) {
|
|
127
|
-
for (const listener of listeners) {
|
|
128
|
-
addrs = [...addrs, ...listener.getAddrs()]
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
return addrs
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
/**
|
|
135
|
-
* Returns all the transports instances.
|
|
136
|
-
*
|
|
137
|
-
* @returns {IterableIterator<Transport>}
|
|
138
|
-
*/
|
|
139
|
-
getTransports () {
|
|
140
|
-
return this._transports.values()
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
/**
|
|
144
|
-
* Finds a transport that matches the given Multiaddr
|
|
145
|
-
*
|
|
146
|
-
* @param {Multiaddr} ma
|
|
147
|
-
* @returns {Transport|null}
|
|
148
|
-
*/
|
|
149
|
-
transportForMultiaddr (ma) {
|
|
150
|
-
for (const transport of this._transports.values()) {
|
|
151
|
-
const addrs = transport.filter([ma])
|
|
152
|
-
if (addrs.length) return transport
|
|
153
|
-
}
|
|
154
|
-
return null
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
/**
|
|
158
|
-
* Starts listeners for each listen Multiaddr.
|
|
159
|
-
*
|
|
160
|
-
* @async
|
|
161
|
-
* @param {Multiaddr[]} addrs - addresses to attempt to listen on
|
|
162
|
-
*/
|
|
163
|
-
async listen (addrs) {
|
|
164
|
-
if (!addrs || addrs.length === 0) {
|
|
165
|
-
log('no addresses were provided for listening, this node is dial only')
|
|
166
|
-
return
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
const couldNotListen = []
|
|
170
|
-
for (const [key, transport] of this._transports.entries()) {
|
|
171
|
-
const supportedAddrs = transport.filter(addrs)
|
|
172
|
-
const tasks = []
|
|
173
|
-
|
|
174
|
-
// For each supported multiaddr, create a listener
|
|
175
|
-
for (const addr of supportedAddrs) {
|
|
176
|
-
log('creating listener for %s on %s', key, addr)
|
|
177
|
-
const listener = transport.createListener(this._listenerOptions.get(key))
|
|
178
|
-
this._listeners.get(key).push(listener)
|
|
179
|
-
|
|
180
|
-
// Track listen/close events
|
|
181
|
-
listener.on('listening', () => updateSelfPeerRecord(this.libp2p))
|
|
182
|
-
listener.on('close', () => updateSelfPeerRecord(this.libp2p))
|
|
183
|
-
|
|
184
|
-
// We need to attempt to listen on everything
|
|
185
|
-
tasks.push(listener.listen(addr))
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
// Keep track of transports we had no addresses for
|
|
189
|
-
if (tasks.length === 0) {
|
|
190
|
-
couldNotListen.push(key)
|
|
191
|
-
continue
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
const results = await pSettle(tasks)
|
|
195
|
-
// If we are listening on at least 1 address, succeed.
|
|
196
|
-
// TODO: we should look at adding a retry (`p-retry`) here to better support
|
|
197
|
-
// listening on remote addresses as they may be offline. We could then potentially
|
|
198
|
-
// just wait for any (`p-any`) listener to succeed on each transport before returning
|
|
199
|
-
const isListening = results.find(r => r.isFulfilled === true)
|
|
200
|
-
if (!isListening && this.faultTolerance !== FAULT_TOLERANCE.NO_FATAL) {
|
|
201
|
-
throw errCode(new Error(`Transport (${key}) could not listen on any available address`), codes.ERR_NO_VALID_ADDRESSES)
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
// If no transports were able to listen, throw an error. This likely
|
|
206
|
-
// means we were given addresses we do not have transports for
|
|
207
|
-
if (couldNotListen.length === this._transports.size) {
|
|
208
|
-
const message = `no valid addresses were provided for transports [${couldNotListen}]`
|
|
209
|
-
if (this.faultTolerance === FAULT_TOLERANCE.FATAL_ALL) {
|
|
210
|
-
throw errCode(new Error(message), codes.ERR_NO_VALID_ADDRESSES)
|
|
211
|
-
}
|
|
212
|
-
log(`libp2p in dial mode only: ${message}`)
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
/**
|
|
217
|
-
* Removes the given transport from the manager.
|
|
218
|
-
* If a transport has any running listeners, they will be closed.
|
|
219
|
-
*
|
|
220
|
-
* @async
|
|
221
|
-
* @param {string} key
|
|
222
|
-
*/
|
|
223
|
-
async remove (key) {
|
|
224
|
-
log('removing %s', key)
|
|
225
|
-
if (this._listeners.has(key)) {
|
|
226
|
-
// Close any running listeners
|
|
227
|
-
for (const listener of this._listeners.get(key)) {
|
|
228
|
-
listener.removeAllListeners('listening')
|
|
229
|
-
listener.removeAllListeners('close')
|
|
230
|
-
await listener.close()
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
this._transports.delete(key)
|
|
235
|
-
this._listeners.delete(key)
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
/**
|
|
239
|
-
* Removes all transports from the manager.
|
|
240
|
-
* If any listeners are running, they will be closed.
|
|
241
|
-
*
|
|
242
|
-
* @async
|
|
243
|
-
*/
|
|
244
|
-
async removeAll () {
|
|
245
|
-
const tasks = []
|
|
246
|
-
for (const key of this._transports.keys()) {
|
|
247
|
-
tasks.push(this.remove(key))
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
await Promise.all(tasks)
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
/**
|
|
255
|
-
* Enum Transport Manager Fault Tolerance values.
|
|
256
|
-
* FATAL_ALL should be used for failing in any listen circumstance.
|
|
257
|
-
* NO_FATAL should be used for not failing when not listening.
|
|
258
|
-
*
|
|
259
|
-
* @readonly
|
|
260
|
-
* @enum {number}
|
|
261
|
-
*/
|
|
262
|
-
const FAULT_TOLERANCE = {
|
|
263
|
-
FATAL_ALL: 0,
|
|
264
|
-
NO_FATAL: 1
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
TransportManager.FaultTolerance = FAULT_TOLERANCE
|
|
268
|
-
|
|
269
|
-
module.exports = TransportManager
|
package/src/types.ts
DELETED
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
import type PeerId from 'peer-id'
|
|
2
|
-
import type { Multiaddr } from 'multiaddr'
|
|
3
|
-
import type { MultiaddrConnection } from 'libp2p-interfaces/src/transport/types'
|
|
4
|
-
|
|
5
|
-
export interface ConnectionGater {
|
|
6
|
-
/**
|
|
7
|
-
* denyDialMultiaddr tests whether we're permitted to Dial the
|
|
8
|
-
* specified peer.
|
|
9
|
-
*
|
|
10
|
-
* This is called by the dialer.connectToPeer implementation before
|
|
11
|
-
* dialling a peer.
|
|
12
|
-
*
|
|
13
|
-
* Return true to prevent dialing the passed peer.
|
|
14
|
-
*/
|
|
15
|
-
denyDialPeer: (peerId: PeerId) => Promise<boolean>
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* denyDialMultiaddr tests whether we're permitted to dial the specified
|
|
19
|
-
* multiaddr for the given peer.
|
|
20
|
-
*
|
|
21
|
-
* This is called by the dialer.connectToPeer implementation after it has
|
|
22
|
-
* resolved the peer's addrs, and prior to dialling each.
|
|
23
|
-
*
|
|
24
|
-
* Return true to prevent dialing the passed peer on the passed multiaddr.
|
|
25
|
-
*/
|
|
26
|
-
denyDialMultiaddr: (peerId: PeerId, multiaddr: Multiaddr) => Promise<boolean>
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* denyInboundConnection tests whether an incipient inbound connection is allowed.
|
|
30
|
-
*
|
|
31
|
-
* This is called by the upgrader, or by the transport directly (e.g. QUIC,
|
|
32
|
-
* Bluetooth), straight after it has accepted a connection from its socket.
|
|
33
|
-
*
|
|
34
|
-
* Return true to deny the incoming passed connection.
|
|
35
|
-
*/
|
|
36
|
-
denyInboundConnection: (maConn: MultiaddrConnection) => Promise<boolean>
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* denyOutboundConnection tests whether an incipient outbound connection is allowed.
|
|
40
|
-
*
|
|
41
|
-
* This is called by the upgrader, or by the transport directly (e.g. QUIC,
|
|
42
|
-
* Bluetooth), straight after it has created a connection with its socket.
|
|
43
|
-
*
|
|
44
|
-
* Return true to deny the incoming passed connection.
|
|
45
|
-
*/
|
|
46
|
-
denyOutboundConnection: (peerId: PeerId, maConn: MultiaddrConnection) => Promise<boolean>
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* denyInboundEncryptedConnection tests whether a given connection, now encrypted,
|
|
50
|
-
* is allowed.
|
|
51
|
-
*
|
|
52
|
-
* This is called by the upgrader, after it has performed the security
|
|
53
|
-
* handshake, and before it negotiates the muxer, or by the directly by the
|
|
54
|
-
* transport, at the exact same checkpoint.
|
|
55
|
-
*
|
|
56
|
-
* Return true to deny the passed secured connection.
|
|
57
|
-
*/
|
|
58
|
-
denyInboundEncryptedConnection: (peerId: PeerId, maConn: MultiaddrConnection) => Promise<boolean>
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* denyOutboundEncryptedConnection tests whether a given connection, now encrypted,
|
|
62
|
-
* is allowed.
|
|
63
|
-
*
|
|
64
|
-
* This is called by the upgrader, after it has performed the security
|
|
65
|
-
* handshake, and before it negotiates the muxer, or by the directly by the
|
|
66
|
-
* transport, at the exact same checkpoint.
|
|
67
|
-
*
|
|
68
|
-
* Return true to deny the passed secured connection.
|
|
69
|
-
*/
|
|
70
|
-
denyOutboundEncryptedConnection: (peerId: PeerId, maConn: MultiaddrConnection) => Promise<boolean>
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* denyInboundUpgradedConnection tests whether a fully capable connection is allowed.
|
|
74
|
-
*
|
|
75
|
-
* This is called after encryption has been negotiated and the connection has been
|
|
76
|
-
* multiplexed, if a multiplexer is configured.
|
|
77
|
-
*
|
|
78
|
-
* Return true to deny the passed upgraded connection.
|
|
79
|
-
*/
|
|
80
|
-
denyInboundUpgradedConnection: (peerId: PeerId, maConn: MultiaddrConnection) => Promise<boolean>
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* denyOutboundUpgradedConnection tests whether a fully capable connection is allowed.
|
|
84
|
-
*
|
|
85
|
-
* This is called after encryption has been negotiated and the connection has been
|
|
86
|
-
* multiplexed, if a multiplexer is configured.
|
|
87
|
-
*
|
|
88
|
-
* Return true to deny the passed upgraded connection.
|
|
89
|
-
*/
|
|
90
|
-
denyOutboundUpgradedConnection: (peerId: PeerId, maConn: MultiaddrConnection) => Promise<boolean>
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* Used by the address book to filter passed addresses.
|
|
94
|
-
*
|
|
95
|
-
* Return true to allow storing the passed multiaddr for the passed peer.
|
|
96
|
-
*/
|
|
97
|
-
filterMultiaddrForPeer: (peer: PeerId, multiaddr: Multiaddr) => Promise<boolean>
|
|
98
|
-
}
|