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/LICENSE
CHANGED
|
@@ -1,22 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2015 David Dias
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
This project is dual licensed under MIT and Apache-2.0.
|
|
22
2
|
|
|
3
|
+
MIT: https://www.opensource.org/licenses/mit
|
|
4
|
+
Apache-2.0: https://www.apache.org/licenses/license-2.0
|
package/README.md
CHANGED
|
@@ -39,26 +39,22 @@ If you are looking for the documentation of the latest release, you can view the
|
|
|
39
39
|
|
|
40
40
|
**Want to update libp2p in your project?** Check our [migrations folder](./doc/migrations).
|
|
41
41
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
## Lead Maintainer
|
|
45
|
-
|
|
46
|
-
[Jacob Heun](https://github.com/jacobheun/)
|
|
47
|
-
|
|
48
|
-
## Table of Contents
|
|
42
|
+
## Table of Contents <!-- omit in toc -->
|
|
49
43
|
|
|
50
44
|
- [Background](#background)
|
|
51
45
|
- [Install](#install)
|
|
52
46
|
- [Usage](#usage)
|
|
53
47
|
- [Configuration](#configuration)
|
|
54
48
|
- [API](#api)
|
|
55
|
-
- [Getting
|
|
49
|
+
- [Getting started](#getting-started)
|
|
56
50
|
- [Tutorials and Examples](#tutorials-and-examples)
|
|
57
51
|
- [Development](#development)
|
|
58
52
|
- [Tests](#tests)
|
|
53
|
+
- [Run unit tests](#run-unit-tests)
|
|
59
54
|
- [Packages](#packages)
|
|
60
55
|
- [Contribute](#contribute)
|
|
61
56
|
- [License](#license)
|
|
57
|
+
- [Contribution](#contribution)
|
|
62
58
|
|
|
63
59
|
## Background
|
|
64
60
|
|
|
@@ -123,7 +119,7 @@ You can find multiple examples on the [examples folder](./examples) that will gu
|
|
|
123
119
|
> npm run test:node
|
|
124
120
|
|
|
125
121
|
# run just Browser tests (Chrome)
|
|
126
|
-
> npm run test:
|
|
122
|
+
> npm run test:chrome
|
|
127
123
|
```
|
|
128
124
|
|
|
129
125
|
### Packages
|
|
@@ -183,4 +179,11 @@ The libp2p implementation in JavaScript is a work in progress. As such, there ar
|
|
|
183
179
|
|
|
184
180
|
## License
|
|
185
181
|
|
|
186
|
-
|
|
182
|
+
Licensed under either of
|
|
183
|
+
|
|
184
|
+
* Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / http://www.apache.org/licenses/LICENSE-2.0)
|
|
185
|
+
* MIT ([LICENSE-MIT](LICENSE-MIT) / http://opensource.org/licenses/MIT)
|
|
186
|
+
|
|
187
|
+
### Contribution
|
|
188
|
+
|
|
189
|
+
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
|
|
@@ -1,72 +1,54 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
import type { AddressManagerEvents } from '@libp2p/interfaces/address-manager';
|
|
2
|
+
import { EventEmitter } from '@libp2p/interfaces/events';
|
|
3
|
+
import { Multiaddr } from '@multiformats/multiaddr';
|
|
4
|
+
import type { Components } from '@libp2p/interfaces/components';
|
|
5
|
+
export interface AddressManagerInit {
|
|
6
|
+
announceFilter?: AddressFilter;
|
|
7
|
+
/**
|
|
8
|
+
* list of multiaddrs string representation to listen
|
|
9
|
+
*/
|
|
10
|
+
listen?: string[];
|
|
11
|
+
/**
|
|
12
|
+
* list of multiaddrs string representation to announce
|
|
13
|
+
*/
|
|
14
|
+
announce?: string[];
|
|
15
|
+
/**
|
|
16
|
+
* list of multiaddrs string representation to never announce
|
|
17
|
+
*/
|
|
18
|
+
noAnnounce?: string[];
|
|
19
|
+
}
|
|
20
|
+
export interface AddressFilter {
|
|
21
|
+
(addrs: Multiaddr[]): Multiaddr[];
|
|
22
|
+
}
|
|
23
|
+
export declare class DefaultAddressManager extends EventEmitter<AddressManagerEvents> {
|
|
24
|
+
private readonly components;
|
|
25
|
+
private readonly listen;
|
|
26
|
+
private readonly announce;
|
|
27
|
+
private readonly observed;
|
|
28
|
+
private readonly announceFilter;
|
|
11
29
|
/**
|
|
12
30
|
* Responsible for managing the peer addresses.
|
|
13
31
|
* Peers can specify their listen and announce addresses.
|
|
14
32
|
* The listen addresses will be used by the libp2p transports to listen for new connections,
|
|
15
33
|
* while the announce addresses will be used for the peer addresses' to other peers in the network.
|
|
16
|
-
*
|
|
17
|
-
* @class
|
|
18
|
-
* @param {PeerId} peerId - The Peer ID of the node
|
|
19
|
-
* @param {object} [options]
|
|
20
|
-
* @param {Array<string>} [options.listen = []] - list of multiaddrs string representation to listen.
|
|
21
|
-
* @param {Array<string>} [options.announce = []] - list of multiaddrs string representation to announce.
|
|
22
34
|
*/
|
|
23
|
-
constructor(
|
|
24
|
-
listen?: string[] | undefined;
|
|
25
|
-
announce?: string[] | undefined;
|
|
26
|
-
} | undefined);
|
|
27
|
-
peerId: PeerId;
|
|
28
|
-
listen: Set<string>;
|
|
29
|
-
announce: Set<string>;
|
|
30
|
-
observed: Set<any>;
|
|
35
|
+
constructor(components: Components, init: AddressManagerInit);
|
|
31
36
|
/**
|
|
32
|
-
* Get peer listen multiaddrs
|
|
33
|
-
*
|
|
34
|
-
* @returns {Multiaddr[]}
|
|
37
|
+
* Get peer listen multiaddrs
|
|
35
38
|
*/
|
|
36
39
|
getListenAddrs(): Multiaddr[];
|
|
37
40
|
/**
|
|
38
|
-
* Get peer announcing multiaddrs
|
|
39
|
-
*
|
|
40
|
-
* @returns {Multiaddr[]}
|
|
41
|
+
* Get peer announcing multiaddrs
|
|
41
42
|
*/
|
|
42
43
|
getAnnounceAddrs(): Multiaddr[];
|
|
43
44
|
/**
|
|
44
|
-
* Get observed multiaddrs
|
|
45
|
-
*
|
|
46
|
-
* @returns {Array<Multiaddr>}
|
|
45
|
+
* Get observed multiaddrs
|
|
47
46
|
*/
|
|
48
|
-
getObservedAddrs():
|
|
47
|
+
getObservedAddrs(): Multiaddr[];
|
|
49
48
|
/**
|
|
50
49
|
* Add peer observed addresses
|
|
51
|
-
*
|
|
52
|
-
* @param {string | Multiaddr} addr
|
|
53
50
|
*/
|
|
54
51
|
addObservedAddr(addr: string | Multiaddr): void;
|
|
52
|
+
getAddresses(): Multiaddr[];
|
|
55
53
|
}
|
|
56
|
-
declare namespace AddressManager {
|
|
57
|
-
export { AddressManagerOptions };
|
|
58
|
-
}
|
|
59
|
-
import { EventEmitter } from "events";
|
|
60
|
-
import PeerId = require("peer-id");
|
|
61
|
-
import { Multiaddr } from "multiaddr";
|
|
62
|
-
type AddressManagerOptions = {
|
|
63
|
-
/**
|
|
64
|
-
* - list of multiaddrs string representation to listen.
|
|
65
|
-
*/
|
|
66
|
-
listen?: string[] | undefined;
|
|
67
|
-
/**
|
|
68
|
-
* - list of multiaddrs string representation to announce.
|
|
69
|
-
*/
|
|
70
|
-
announce?: string[] | undefined;
|
|
71
|
-
};
|
|
72
54
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/address-manager/index.
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/address-manager/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAA;AAC9E,OAAO,EAAe,YAAY,EAAE,MAAM,2BAA2B,CAAA;AACrE,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AAEnD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAA;AAE/D,MAAM,WAAW,kBAAkB;IACjC,cAAc,CAAC,EAAE,aAAa,CAAA;IAE9B;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,EAAE,CAAA;IAEjB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAA;IAEnB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,EAAE,CAAA;CACtB;AAED,MAAM,WAAW,aAAa;IAC5B,CAAC,KAAK,EAAE,SAAS,EAAE,GAAG,SAAS,EAAE,CAAA;CAClC;AAID,qBAAa,qBAAsB,SAAQ,YAAY,CAAC,oBAAoB,CAAC;IAC3E,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAY;IACvC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAa;IACpC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAa;IACtC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAa;IACtC,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAe;IAE9C;;;;;OAKG;gBACU,UAAU,EAAE,UAAU,EAAE,IAAI,EAAE,kBAAkB;IAY7D;;OAEG;IACH,cAAc,IAAK,SAAS,EAAE;IAI9B;;OAEG;IACH,gBAAgB,IAAK,SAAS,EAAE;IAIhC;;OAEG;IACH,gBAAgB,IAAK,SAAS,EAAE;IAIhC;;OAEG;IACH,eAAe,CAAE,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI;IAyBhD,YAAY,IAAK,SAAS,EAAE;CAwB7B"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { CustomEvent, EventEmitter } from '@libp2p/interfaces/events';
|
|
2
|
+
import { Multiaddr } from '@multiformats/multiaddr';
|
|
3
|
+
import { peerIdFromString } from '@libp2p/peer-id';
|
|
4
|
+
const defaultAddressFilter = (addrs) => addrs;
|
|
5
|
+
export class DefaultAddressManager extends EventEmitter {
|
|
6
|
+
/**
|
|
7
|
+
* Responsible for managing the peer addresses.
|
|
8
|
+
* Peers can specify their listen and announce addresses.
|
|
9
|
+
* The listen addresses will be used by the libp2p transports to listen for new connections,
|
|
10
|
+
* while the announce addresses will be used for the peer addresses' to other peers in the network.
|
|
11
|
+
*/
|
|
12
|
+
constructor(components, init) {
|
|
13
|
+
super();
|
|
14
|
+
const { listen = [], announce = [] } = init;
|
|
15
|
+
this.components = components;
|
|
16
|
+
this.listen = new Set(listen.map(ma => ma.toString()));
|
|
17
|
+
this.announce = new Set(announce.map(ma => ma.toString()));
|
|
18
|
+
this.observed = new Set();
|
|
19
|
+
this.announceFilter = init.announceFilter ?? defaultAddressFilter;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Get peer listen multiaddrs
|
|
23
|
+
*/
|
|
24
|
+
getListenAddrs() {
|
|
25
|
+
return Array.from(this.listen).map((a) => new Multiaddr(a));
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Get peer announcing multiaddrs
|
|
29
|
+
*/
|
|
30
|
+
getAnnounceAddrs() {
|
|
31
|
+
return Array.from(this.announce).map((a) => new Multiaddr(a));
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Get observed multiaddrs
|
|
35
|
+
*/
|
|
36
|
+
getObservedAddrs() {
|
|
37
|
+
return Array.from(this.observed).map((a) => new Multiaddr(a));
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Add peer observed addresses
|
|
41
|
+
*/
|
|
42
|
+
addObservedAddr(addr) {
|
|
43
|
+
let ma = new Multiaddr(addr);
|
|
44
|
+
const remotePeer = ma.getPeerId();
|
|
45
|
+
// strip our peer id if it has been passed
|
|
46
|
+
if (remotePeer != null) {
|
|
47
|
+
const remotePeerId = peerIdFromString(remotePeer);
|
|
48
|
+
// use same encoding for comparison
|
|
49
|
+
if (remotePeerId.equals(this.components.getPeerId())) {
|
|
50
|
+
ma = ma.decapsulate(new Multiaddr(`/p2p/${this.components.getPeerId().toString()}`));
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
const addrString = ma.toString();
|
|
54
|
+
// do not trigger the change:addresses event if we already know about this address
|
|
55
|
+
if (this.observed.has(addrString)) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
this.observed.add(addrString);
|
|
59
|
+
this.dispatchEvent(new CustomEvent('change:addresses'));
|
|
60
|
+
}
|
|
61
|
+
getAddresses() {
|
|
62
|
+
let addrs = this.getAnnounceAddrs().map(ma => ma.toString());
|
|
63
|
+
if (addrs.length === 0) {
|
|
64
|
+
// no configured announce addrs, add configured listen addresses
|
|
65
|
+
addrs = this.components.getTransportManager().getAddrs().map(ma => ma.toString());
|
|
66
|
+
}
|
|
67
|
+
addrs = addrs.concat(this.getObservedAddrs().map(ma => ma.toString()));
|
|
68
|
+
// dedupe multiaddrs
|
|
69
|
+
const addrSet = new Set(addrs);
|
|
70
|
+
// Create advertising list
|
|
71
|
+
return this.announceFilter(Array.from(addrSet)
|
|
72
|
+
.map(str => new Multiaddr(str)))
|
|
73
|
+
.map(ma => {
|
|
74
|
+
if (ma.getPeerId() === this.components.getPeerId().toString()) {
|
|
75
|
+
return ma;
|
|
76
|
+
}
|
|
77
|
+
return ma.encapsulate(`/p2p/${this.components.getPeerId().toString()}`);
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/address-manager/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AACrE,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AA0BlD,MAAM,oBAAoB,GAAG,CAAC,KAAkB,EAAe,EAAE,CAAC,KAAK,CAAA;AAEvE,MAAM,OAAO,qBAAsB,SAAQ,YAAkC;IAO3E;;;;;OAKG;IACH,YAAa,UAAsB,EAAE,IAAwB;QAC3D,KAAK,EAAE,CAAA;QAEP,MAAM,EAAE,MAAM,GAAG,EAAE,EAAE,QAAQ,GAAG,EAAE,EAAE,GAAG,IAAI,CAAA;QAE3C,IAAI,CAAC,UAAU,GAAG,UAAU,CAAA;QAC5B,IAAI,CAAC,MAAM,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAA;QACtD,IAAI,CAAC,QAAQ,GAAG,IAAI,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAA;QAC1D,IAAI,CAAC,QAAQ,GAAG,IAAI,GAAG,EA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AAC,UAAU,CAAC,SAAS,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAA;QACzE,CAAC,CAAC,CAAA;IACN,CAAC;CACF"}
|
|
@@ -1,107 +1,46 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
* Creates an instance of AutoRelay.
|
|
18
|
-
*
|
|
19
|
-
* @class
|
|
20
|
-
* @param {AutoRelayProperties & AutoRelayOptions} props
|
|
21
|
-
*/
|
|
22
|
-
constructor({ libp2p, maxListeners, onError }: AutoRelayProperties & AutoRelayOptions);
|
|
23
|
-
_libp2p: import("../");
|
|
24
|
-
_peerId: import("peer-id");
|
|
25
|
-
_peerStore: import("../peer-store/types").PeerStore;
|
|
26
|
-
_connectionManager: import("../connection-manager");
|
|
27
|
-
_transportManager: import("../transport-manager");
|
|
28
|
-
_addressSorter: (addresses: import("../peer-store/types").Address[]) => import("../peer-store/types").Address[];
|
|
29
|
-
maxListeners: number;
|
|
30
|
-
/**
|
|
31
|
-
* @type {Set<string>}
|
|
32
|
-
*/
|
|
33
|
-
_listenRelays: Set<string>;
|
|
1
|
+
import type { PeerId } from '@libp2p/interfaces/peer-id';
|
|
2
|
+
import type { AddressSorter, PeerProtocolsChangeData } from '@libp2p/interfaces/peer-store';
|
|
3
|
+
import type { Connection } from '@libp2p/interfaces/connection';
|
|
4
|
+
import type { Components } from '@libp2p/interfaces/components';
|
|
5
|
+
export interface AutoRelayInit {
|
|
6
|
+
addressSorter?: AddressSorter;
|
|
7
|
+
maxListeners?: number;
|
|
8
|
+
onError?: (error: Error, msg?: string) => void;
|
|
9
|
+
}
|
|
10
|
+
export declare class AutoRelay {
|
|
11
|
+
private readonly components;
|
|
12
|
+
private readonly addressSorter;
|
|
13
|
+
private readonly maxListeners;
|
|
14
|
+
private readonly listenRelays;
|
|
15
|
+
private readonly onError;
|
|
16
|
+
constructor(components: Components, init: AutoRelayInit);
|
|
34
17
|
/**
|
|
35
18
|
* Check if a peer supports the relay protocol.
|
|
36
19
|
* If the protocol is not supported, check if it was supported before and remove it as a listen relay.
|
|
37
20
|
* If the protocol is supported, check if the peer supports **HOP** and add it as a listener if
|
|
38
21
|
* inside the threshold.
|
|
39
|
-
*
|
|
40
|
-
* @param {Object} props
|
|
41
|
-
* @param {PeerId} props.peerId
|
|
42
|
-
* @param {string[]} props.protocols
|
|
43
|
-
* @returns {Promise<void>}
|
|
44
|
-
*/
|
|
45
|
-
_onProtocolChange({ peerId, protocols }: {
|
|
46
|
-
peerId: PeerId;
|
|
47
|
-
protocols: string[];
|
|
48
|
-
}): Promise<void>;
|
|
49
|
-
/**
|
|
50
|
-
* Peer disconnects.
|
|
51
|
-
*
|
|
52
|
-
* @param {Connection} connection - connection to the peer
|
|
53
22
|
*/
|
|
54
|
-
|
|
23
|
+
_onProtocolChange(evt: CustomEvent<PeerProtocolsChangeData>): Promise<void>;
|
|
55
24
|
/**
|
|
56
|
-
*
|
|
57
|
-
* @param {string} [msg]
|
|
25
|
+
* Peer disconnects
|
|
58
26
|
*/
|
|
59
|
-
|
|
27
|
+
_onPeerDisconnected(evt: CustomEvent<Connection>): void;
|
|
60
28
|
/**
|
|
61
|
-
* Attempt to listen on the given relay connection
|
|
62
|
-
*
|
|
63
|
-
* @private
|
|
64
|
-
* @param {Connection} connection - connection to the peer
|
|
65
|
-
* @param {string} id - peer identifier string
|
|
66
|
-
* @returns {Promise<void>}
|
|
29
|
+
* Attempt to listen on the given relay connection
|
|
67
30
|
*/
|
|
68
|
-
|
|
31
|
+
_addListenRelay(connection: Connection, id: string): Promise<void>;
|
|
69
32
|
/**
|
|
70
|
-
* Remove listen relay
|
|
71
|
-
*
|
|
72
|
-
* @private
|
|
73
|
-
* @param {string} id - peer identifier string.
|
|
33
|
+
* Remove listen relay
|
|
74
34
|
*/
|
|
75
|
-
|
|
35
|
+
_removeListenRelay(id: string): Promise<void>;
|
|
76
36
|
/**
|
|
77
37
|
* Try to listen on available hop relay connections.
|
|
78
38
|
* The following order will happen while we do not have enough relays.
|
|
79
39
|
* 1. Check the metadata store for known relays, try to listen on the ones we are already connected.
|
|
80
40
|
* 2. Dial and try to listen on the peers we know that support hop but are not connected.
|
|
81
41
|
* 3. Search the network.
|
|
82
|
-
*
|
|
83
|
-
* @param {string[]} [peersToIgnore]
|
|
84
|
-
*/
|
|
85
|
-
_listenOnAvailableHopRelays(peersToIgnore?: string[] | undefined): Promise<void>;
|
|
86
|
-
/**
|
|
87
|
-
* @param {PeerId} peerId
|
|
88
42
|
*/
|
|
43
|
+
_listenOnAvailableHopRelays(peersToIgnore?: string[]): Promise<void>;
|
|
89
44
|
_tryToListenOnRelay(peerId: PeerId): Promise<void>;
|
|
90
45
|
}
|
|
91
|
-
declare namespace AutoRelay {
|
|
92
|
-
export { Connection, Address, PeerId, AutoRelayProperties, AutoRelayOptions };
|
|
93
|
-
}
|
|
94
|
-
type PeerId = import('peer-id');
|
|
95
|
-
type Connection = import("libp2p-interfaces/src/connection/connection");
|
|
96
|
-
type AutoRelayProperties = {
|
|
97
|
-
libp2p: import('../');
|
|
98
|
-
};
|
|
99
|
-
type AutoRelayOptions = {
|
|
100
|
-
/**
|
|
101
|
-
* - maximum number of relays to listen.
|
|
102
|
-
*/
|
|
103
|
-
maxListeners?: number | undefined;
|
|
104
|
-
onError?: ((error: Error, msg?: string | undefined) => {}) | undefined;
|
|
105
|
-
};
|
|
106
|
-
type Address = import('../peer-store/types').Address;
|
|
107
46
|
//# sourceMappingURL=auto-relay.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auto-relay.d.ts","sourceRoot":"","sources":["../../../src/circuit/auto-relay.
|
|
1
|
+
{"version":3,"file":"auto-relay.d.ts","sourceRoot":"","sources":["../../../src/circuit/auto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';
|
|
2
|
+
import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string';
|
|
3
|
+
import { toString as uint8ArrayToString } from 'uint8arrays/to-string';
|
|
4
|
+
import { RELAY_CODEC } from './multicodec.js';
|
|
5
|
+
import { canHop } from './circuit/hop.js';
|
|
6
|
+
import { namespaceToCid } from './utils.js';
|
|
7
|
+
import { CIRCUIT_PROTO_CODE, HOP_METADATA_KEY, HOP_METADATA_VALUE, RELAY_RENDEZVOUS_NS } from './constants.js';
|
|
8
|
+
import sort from 'it-sort';
|
|
9
|
+
import all from 'it-all';
|
|
10
|
+
import { pipe } from 'it-pipe';
|
|
11
|
+
import { publicAddressesFirst } from '@libp2p/utils/address-sort';
|
|
12
|
+
const log = logger('libp2p:auto-relay');
|
|
13
|
+
const noop = () => { };
|
|
14
|
+
export class AutoRelay {
|
|
15
|
+
constructor(components, init) {
|
|
16
|
+
this.components = components;
|
|
17
|
+
this.addressSorter = init.addressSorter ?? publicAddressesFirst;
|
|
18
|
+
this.maxListeners = init.maxListeners ?? 1;
|
|
19
|
+
this.listenRelays = new Set();
|
|
20
|
+
this.onError = init.onError ?? noop;
|
|
21
|
+
this._onProtocolChange = this._onProtocolChange.bind(this);
|
|
22
|
+
this._onPeerDisconnected = this._onPeerDisconnected.bind(this);
|
|
23
|
+
this.components.getPeerStore().addEventListener('change:protocols', (evt) => {
|
|
24
|
+
void this._onProtocolChange(evt).catch(err => {
|
|
25
|
+
log.error(err);
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
this.components.getConnectionManager().addEventListener('peer:disconnect', this._onPeerDisconnected);
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Check if a peer supports the relay protocol.
|
|
32
|
+
* If the protocol is not supported, check if it was supported before and remove it as a listen relay.
|
|
33
|
+
* If the protocol is supported, check if the peer supports **HOP** and add it as a listener if
|
|
34
|
+
* inside the threshold.
|
|
35
|
+
*/
|
|
36
|
+
async _onProtocolChange(evt) {
|
|
37
|
+
const { peerId, protocols } = evt.detail;
|
|
38
|
+
const id = peerId.toString();
|
|
39
|
+
// Check if it has the protocol
|
|
40
|
+
const hasProtocol = protocols.find(protocol => protocol === RELAY_CODEC);
|
|
41
|
+
// If no protocol, check if we were keeping the peer before as a listenRelay
|
|
42
|
+
if (hasProtocol == null) {
|
|
43
|
+
if (this.listenRelays.has(id)) {
|
|
44
|
+
await this._removeListenRelay(id);
|
|
45
|
+
}
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
if (this.listenRelays.has(id)) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
// If protocol, check if can hop, store info in the metadataBook and listen on it
|
|
52
|
+
try {
|
|
53
|
+
const connections = this.components.getConnectionManager().getConnections(peerId);
|
|
54
|
+
if (connections.length === 0) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
const connection = connections[0];
|
|
58
|
+
// Do not hop on a relayed connection
|
|
59
|
+
if (connection.remoteAddr.protoCodes().includes(CIRCUIT_PROTO_CODE)) {
|
|
60
|
+
log(`relayed connection to ${id} will not be used to hop on`);
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
const supportsHop = await canHop({ connection });
|
|
64
|
+
if (supportsHop) {
|
|
65
|
+
await this.components.getPeerStore().metadataBook.setValue(peerId, HOP_METADATA_KEY, uint8ArrayFromString(HOP_METADATA_VALUE));
|
|
66
|
+
await this._addListenRelay(connection, id);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
catch (err) {
|
|
70
|
+
this.onError(err);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Peer disconnects
|
|
75
|
+
*/
|
|
76
|
+
_onPeerDisconnected(evt) {
|
|
77
|
+
const connection = evt.detail;
|
|
78
|
+
const peerId = connection.remotePeer;
|
|
79
|
+
const id = peerId.toString();
|
|
80
|
+
// Not listening on this relay
|
|
81
|
+
if (!this.listenRelays.has(id)) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
this._removeListenRelay(id).catch(err => {
|
|
85
|
+
log.error(err);
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Attempt to listen on the given relay connection
|
|
90
|
+
*/
|
|
91
|
+
async _addListenRelay(connection, id) {
|
|
92
|
+
try {
|
|
93
|
+
// Check if already listening on enough relays
|
|
94
|
+
if (this.listenRelays.size >= this.maxListeners) {
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
// Get peer known addresses and sort them with public addresses first
|
|
98
|
+
const remoteAddrs = await pipe(await this.components.getPeerStore().addressBook.get(connection.remotePeer), (source) => sort(source, this.addressSorter), async (source) => await all(source));
|
|
99
|
+
// Attempt to listen on relay
|
|
100
|
+
const result = await Promise.all(remoteAddrs.map(async (addr) => {
|
|
101
|
+
try {
|
|
102
|
+
let multiaddr = addr.multiaddr;
|
|
103
|
+
if (multiaddr.getPeerId() == null) {
|
|
104
|
+
multiaddr = multiaddr.encapsulate(`/p2p/${connection.remotePeer.toString()}`);
|
|
105
|
+
}
|
|
106
|
+
multiaddr = multiaddr.encapsulate('/p2p-circuit');
|
|
107
|
+
// Announce multiaddrs will update on listen success by TransportManager event being triggered
|
|
108
|
+
await this.components.getTransportManager().listen([multiaddr]);
|
|
109
|
+
return true;
|
|
110
|
+
}
|
|
111
|
+
catch (err) {
|
|
112
|
+
log.error('error listening on circuit address', err);
|
|
113
|
+
this.onError(err);
|
|
114
|
+
}
|
|
115
|
+
return false;
|
|
116
|
+
}));
|
|
117
|
+
if (result.includes(true)) {
|
|
118
|
+
this.listenRelays.add(id);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
catch (err) {
|
|
122
|
+
this.onError(err);
|
|
123
|
+
this.listenRelays.delete(id);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Remove listen relay
|
|
128
|
+
*/
|
|
129
|
+
async _removeListenRelay(id) {
|
|
130
|
+
if (this.listenRelays.delete(id)) {
|
|
131
|
+
// TODO: this should be responsibility of the connMgr
|
|
132
|
+
await this._listenOnAvailableHopRelays([id]);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Try to listen on available hop relay connections.
|
|
137
|
+
* The following order will happen while we do not have enough relays.
|
|
138
|
+
* 1. Check the metadata store for known relays, try to listen on the ones we are already connected.
|
|
139
|
+
* 2. Dial and try to listen on the peers we know that support hop but are not connected.
|
|
140
|
+
* 3. Search the network.
|
|
141
|
+
*/
|
|
142
|
+
async _listenOnAvailableHopRelays(peersToIgnore = []) {
|
|
143
|
+
// TODO: The peer redial issue on disconnect should be handled by connection gating
|
|
144
|
+
// Check if already listening on enough relays
|
|
145
|
+
if (this.listenRelays.size >= this.maxListeners) {
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
const knownHopsToDial = [];
|
|
149
|
+
const peers = await this.components.getPeerStore().all();
|
|
150
|
+
// Check if we have known hop peers to use and attempt to listen on the already connected
|
|
151
|
+
for (const { id, metadata } of peers) {
|
|
152
|
+
const idStr = id.toString();
|
|
153
|
+
// Continue to next if listening on this or peer to ignore
|
|
154
|
+
if (this.listenRelays.has(idStr)) {
|
|
155
|
+
continue;
|
|
156
|
+
}
|
|
157
|
+
if (peersToIgnore.includes(idStr)) {
|
|
158
|
+
continue;
|
|
159
|
+
}
|
|
160
|
+
const supportsHop = metadata.get(HOP_METADATA_KEY);
|
|
161
|
+
// Continue to next if it does not support Hop
|
|
162
|
+
if ((supportsHop == null) || uint8ArrayToString(supportsHop) !== HOP_METADATA_VALUE) {
|
|
163
|
+
continue;
|
|
164
|
+
}
|
|
165
|
+
const connections = this.components.getConnectionManager().getConnections(id);
|
|
166
|
+
// If not connected, store for possible later use.
|
|
167
|
+
if (connections.length === 0) {
|
|
168
|
+
knownHopsToDial.push(id);
|
|
169
|
+
continue;
|
|
170
|
+
}
|
|
171
|
+
await this._addListenRelay(connections[0], idStr);
|
|
172
|
+
// Check if already listening on enough relays
|
|
173
|
+
if (this.listenRelays.size >= this.maxListeners) {
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
// Try to listen on known peers that are not connected
|
|
178
|
+
for (const peerId of knownHopsToDial) {
|
|
179
|
+
await this._tryToListenOnRelay(peerId);
|
|
180
|
+
// Check if already listening on enough relays
|
|
181
|
+
if (this.listenRelays.size >= this.maxListeners) {
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
// Try to find relays to hop on the network
|
|
186
|
+
try {
|
|
187
|
+
const cid = await namespaceToCid(RELAY_RENDEZVOUS_NS);
|
|
188
|
+
for await (const provider of this.components.getContentRouting().findProviders(cid)) {
|
|
189
|
+
if (provider.multiaddrs.length === 0) {
|
|
190
|
+
continue;
|
|
191
|
+
}
|
|
192
|
+
const peerId = provider.id;
|
|
193
|
+
await this.components.getPeerStore().addressBook.add(peerId, provider.multiaddrs);
|
|
194
|
+
await this._tryToListenOnRelay(peerId);
|
|
195
|
+
// Check if already listening on enough relays
|
|
196
|
+
if (this.listenRelays.size >= this.maxListeners) {
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
catch (err) {
|
|
202
|
+
this.onError(err);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
async _tryToListenOnRelay(peerId) {
|
|
206
|
+
try {
|
|
207
|
+
const connection = await this.components.getConnectionManager().openConnection(peerId);
|
|
208
|
+
await this._addListenRelay(connection, peerId.toString());
|
|
209
|
+
}
|
|
210
|
+
catch (err) {
|
|
211
|
+
log.error('Could not use %p as relay', peerId, err);
|
|
212
|
+
this.onError(err, `could not connect and listen on known hop relay ${peerId.toString()}`);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
//# sourceMappingURL=auto-relay.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auto-relay.js","sourceRoot":"","sources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