libp2p 0.44.0 → 0.45.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/dist/index.min.js +30 -30
- package/dist/src/address-manager/index.d.ts +8 -4
- package/dist/src/address-manager/index.d.ts.map +1 -1
- package/dist/src/address-manager/index.js +37 -6
- package/dist/src/address-manager/index.js.map +1 -1
- package/dist/src/address-manager/utils.d.ts +2 -0
- package/dist/src/address-manager/utils.d.ts.map +1 -0
- package/dist/src/address-manager/utils.js +12 -0
- package/dist/src/address-manager/utils.js.map +1 -0
- package/dist/src/autonat/constants.d.ts +16 -2
- package/dist/src/autonat/constants.d.ts.map +1 -1
- package/dist/src/autonat/constants.js +16 -2
- package/dist/src/autonat/constants.js.map +1 -1
- package/dist/src/autonat/index.d.ts +12 -33
- package/dist/src/autonat/index.d.ts.map +1 -1
- package/dist/src/autonat/index.js +36 -30
- package/dist/src/autonat/index.js.map +1 -1
- package/dist/src/circuit-relay/server/advert-service.d.ts.map +1 -1
- package/dist/src/circuit-relay/server/advert-service.js +2 -2
- package/dist/src/circuit-relay/server/advert-service.js.map +1 -1
- package/dist/src/circuit-relay/server/index.d.ts.map +1 -1
- package/dist/src/circuit-relay/server/index.js +10 -3
- package/dist/src/circuit-relay/server/index.js.map +1 -1
- package/dist/src/circuit-relay/transport/discovery.d.ts.map +1 -1
- package/dist/src/circuit-relay/transport/discovery.js +4 -2
- package/dist/src/circuit-relay/transport/discovery.js.map +1 -1
- package/dist/src/circuit-relay/transport/index.d.ts +3 -0
- package/dist/src/circuit-relay/transport/index.d.ts.map +1 -1
- package/dist/src/circuit-relay/transport/index.js +6 -4
- package/dist/src/circuit-relay/transport/index.js.map +1 -1
- package/dist/src/circuit-relay/transport/listener.d.ts.map +1 -1
- package/dist/src/circuit-relay/transport/listener.js +30 -26
- package/dist/src/circuit-relay/transport/listener.js.map +1 -1
- package/dist/src/circuit-relay/transport/reservation-store.d.ts +5 -4
- package/dist/src/circuit-relay/transport/reservation-store.d.ts.map +1 -1
- package/dist/src/circuit-relay/transport/reservation-store.js +37 -30
- package/dist/src/circuit-relay/transport/reservation-store.js.map +1 -1
- package/dist/src/components.d.ts +6 -63
- package/dist/src/components.d.ts.map +1 -1
- package/dist/src/components.js +60 -164
- package/dist/src/components.js.map +1 -1
- package/dist/src/config/connection-gater.browser.d.ts +8 -0
- package/dist/src/config/connection-gater.browser.d.ts.map +1 -0
- package/dist/src/config/connection-gater.browser.js +27 -0
- package/dist/src/config/connection-gater.browser.js.map +1 -0
- package/dist/src/config/connection-gater.d.ts +6 -0
- package/dist/src/config/connection-gater.d.ts.map +1 -0
- package/dist/src/config/connection-gater.js +18 -0
- package/dist/src/config/connection-gater.js.map +1 -0
- package/dist/src/config.d.ts +2 -1
- package/dist/src/config.d.ts.map +1 -1
- package/dist/src/config.js +0 -62
- package/dist/src/config.js.map +1 -1
- package/dist/src/connection-manager/auto-dial.d.ts +3 -0
- package/dist/src/connection-manager/auto-dial.d.ts.map +1 -1
- package/dist/src/connection-manager/auto-dial.js +36 -13
- package/dist/src/connection-manager/auto-dial.js.map +1 -1
- package/dist/src/connection-manager/connection-pruner.d.ts +4 -0
- package/dist/src/connection-manager/connection-pruner.d.ts.map +1 -1
- package/dist/src/connection-manager/connection-pruner.js +23 -8
- package/dist/src/connection-manager/connection-pruner.js.map +1 -1
- package/dist/src/connection-manager/dial-queue.d.ts +2 -1
- package/dist/src/connection-manager/dial-queue.d.ts.map +1 -1
- package/dist/src/connection-manager/dial-queue.js +36 -14
- package/dist/src/connection-manager/dial-queue.js.map +1 -1
- package/dist/src/connection-manager/index.d.ts +8 -7
- package/dist/src/connection-manager/index.d.ts.map +1 -1
- package/dist/src/connection-manager/index.js +23 -34
- package/dist/src/connection-manager/index.js.map +1 -1
- package/dist/src/content-routing/index.d.ts +0 -10
- package/dist/src/content-routing/index.d.ts.map +1 -1
- package/dist/src/content-routing/index.js +7 -42
- package/dist/src/content-routing/index.js.map +1 -1
- package/dist/src/content-routing/utils.d.ts.map +1 -1
- package/dist/src/content-routing/utils.js +3 -1
- package/dist/src/content-routing/utils.js.map +1 -1
- package/dist/src/fetch/index.d.ts +13 -35
- package/dist/src/fetch/index.d.ts.map +1 -1
- package/dist/src/fetch/index.js +7 -9
- package/dist/src/fetch/index.js.map +1 -1
- package/dist/src/identify/identify.d.ts +53 -0
- package/dist/src/identify/identify.d.ts.map +1 -0
- package/dist/src/identify/identify.js +405 -0
- package/dist/src/identify/identify.js.map +1 -0
- package/dist/src/identify/index.d.ts +12 -58
- package/dist/src/identify/index.d.ts.map +1 -1
- package/dist/src/identify/index.js +5 -388
- package/dist/src/identify/index.js.map +1 -1
- package/dist/src/index.d.ts +13 -68
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +2 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/insecure/index.js.map +1 -1
- package/dist/src/libp2p.d.ts +11 -42
- package/dist/src/libp2p.d.ts.map +1 -1
- package/dist/src/libp2p.js +137 -196
- package/dist/src/libp2p.js.map +1 -1
- package/dist/src/peer-routing.d.ts +1 -38
- package/dist/src/peer-routing.d.ts.map +1 -1
- package/dist/src/peer-routing.js +0 -59
- package/dist/src/peer-routing.js.map +1 -1
- package/dist/src/ping/constants.d.ts +4 -0
- package/dist/src/ping/constants.d.ts.map +1 -1
- package/dist/src/ping/constants.js +10 -0
- package/dist/src/ping/constants.js.map +1 -1
- package/dist/src/ping/index.d.ts +10 -27
- package/dist/src/ping/index.d.ts.map +1 -1
- package/dist/src/ping/index.js +18 -21
- package/dist/src/ping/index.js.map +1 -1
- package/dist/src/registrar.d.ts +5 -2
- package/dist/src/registrar.d.ts.map +1 -1
- package/dist/src/registrar.js +27 -25
- package/dist/src/registrar.js.map +1 -1
- package/dist/src/transport-manager.d.ts +11 -4
- package/dist/src/transport-manager.d.ts.map +1 -1
- package/dist/src/transport-manager.js +19 -10
- package/dist/src/transport-manager.js.map +1 -1
- package/dist/src/upgrader.d.ts +15 -10
- package/dist/src/upgrader.d.ts.map +1 -1
- package/dist/src/upgrader.js +39 -48
- package/dist/src/upgrader.js.map +1 -1
- package/dist/src/upnp-nat/index.d.ts +42 -0
- package/dist/src/upnp-nat/index.d.ts.map +1 -0
- package/dist/src/{nat-manager.js → upnp-nat/index.js} +11 -7
- package/dist/src/upnp-nat/index.js.map +1 -0
- 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 +25 -10
- package/package.json +61 -45
- package/src/address-manager/index.ts +50 -8
- package/src/address-manager/utils.ts +14 -0
- package/src/autonat/constants.ts +17 -2
- package/src/autonat/index.ts +53 -45
- package/src/circuit-relay/server/advert-service.ts +2 -2
- package/src/circuit-relay/server/index.ts +11 -3
- package/src/circuit-relay/transport/discovery.ts +5 -3
- package/src/circuit-relay/transport/index.ts +9 -4
- package/src/circuit-relay/transport/listener.ts +38 -28
- package/src/circuit-relay/transport/reservation-store.ts +34 -20
- package/src/components.ts +71 -234
- package/src/config/connection-gater.browser.ts +31 -0
- package/src/config/connection-gater.ts +19 -0
- package/src/config.ts +3 -64
- package/src/connection-manager/auto-dial.ts +44 -15
- package/src/connection-manager/connection-pruner.ts +28 -8
- package/src/connection-manager/dial-queue.ts +41 -21
- package/src/connection-manager/index.ts +31 -43
- package/src/content-routing/index.ts +7 -55
- package/src/content-routing/utils.ts +3 -1
- package/src/fetch/index.ts +51 -14
- package/src/identify/identify.ts +518 -0
- package/src/identify/index.ts +17 -507
- package/src/index.ts +14 -77
- package/src/insecure/index.ts +4 -4
- package/src/libp2p.ts +139 -260
- package/src/peer-routing.ts +1 -101
- package/src/ping/constants.ts +11 -0
- package/src/ping/index.ts +32 -28
- package/src/registrar.ts +31 -27
- package/src/transport-manager.ts +27 -13
- package/src/upgrader.ts +62 -58
- package/src/{nat-manager.ts → upnp-nat/index.ts} +16 -17
- package/src/version.ts +1 -1
- package/dist/src/dht/dht-content-routing.d.ts +0 -17
- package/dist/src/dht/dht-content-routing.d.ts.map +0 -1
- package/dist/src/dht/dht-content-routing.js +0 -32
- package/dist/src/dht/dht-content-routing.js.map +0 -1
- package/dist/src/dht/dht-peer-routing.d.ts +0 -15
- package/dist/src/dht/dht-peer-routing.d.ts.map +0 -1
- package/dist/src/dht/dht-peer-routing.js +0 -26
- package/dist/src/dht/dht-peer-routing.js.map +0 -1
- package/dist/src/dht/dummy-dht.d.ts +0 -20
- package/dist/src/dht/dummy-dht.d.ts.map +0 -1
- package/dist/src/dht/dummy-dht.js +0 -46
- package/dist/src/dht/dummy-dht.js.map +0 -1
- package/dist/src/nat-manager.d.ts +0 -74
- package/dist/src/nat-manager.d.ts.map +0 -1
- package/dist/src/nat-manager.js.map +0 -1
- package/dist/src/peer-record-updater.d.ts +0 -24
- package/dist/src/peer-record-updater.d.ts.map +0 -1
- package/dist/src/peer-record-updater.js +0 -44
- package/dist/src/peer-record-updater.js.map +0 -1
- package/src/dht/dht-content-routing.ts +0 -44
- package/src/dht/dht-peer-routing.ts +0 -36
- package/src/dht/dummy-dht.ts +0 -60
- package/src/peer-record-updater.ts +0 -65
package/dist/typedoc-urls.json
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
{
|
|
2
|
+
"AutoNATComponents": "https://libp2p.github.io/js-libp2p/interfaces/autonat.AutoNATComponents.html",
|
|
3
|
+
"AutoNATServiceInit": "https://libp2p.github.io/js-libp2p/interfaces/autonat.AutoNATServiceInit.html",
|
|
4
|
+
"autoNATService": "https://libp2p.github.io/js-libp2p/functions/autonat.autoNATService.html",
|
|
2
5
|
"codec": "https://libp2p.github.io/js-libp2p/functions/circuit_relay._internal_.Limit.codec.html",
|
|
3
6
|
"decode": "https://libp2p.github.io/js-libp2p/functions/circuit_relay._internal_.Limit.decode.html",
|
|
4
7
|
"encode": "https://libp2p.github.io/js-libp2p/functions/circuit_relay._internal_.Limit.encode.html",
|
|
@@ -17,25 +20,37 @@
|
|
|
17
20
|
"RelayReservation": "https://libp2p.github.io/js-libp2p/interfaces/circuit_relay.RelayReservation.html",
|
|
18
21
|
"circuitRelayServer": "https://libp2p.github.io/js-libp2p/functions/circuit_relay.circuitRelayServer.html",
|
|
19
22
|
"circuitRelayTransport": "https://libp2p.github.io/js-libp2p/functions/circuit_relay.circuitRelayTransport.html",
|
|
23
|
+
"FetchService": "https://libp2p.github.io/js-libp2p/interfaces/fetch.FetchService.html",
|
|
24
|
+
"FetchServiceComponents": "https://libp2p.github.io/js-libp2p/interfaces/fetch.FetchServiceComponents.html",
|
|
25
|
+
"FetchServiceInit": "https://libp2p.github.io/js-libp2p/interfaces/fetch.FetchServiceInit.html",
|
|
26
|
+
"HandleMessageOptions": "https://libp2p.github.io/js-libp2p/interfaces/fetch.HandleMessageOptions.html",
|
|
27
|
+
"LookupFunction": "https://libp2p.github.io/js-libp2p/interfaces/fetch.LookupFunction.html",
|
|
28
|
+
"fetchService": "https://libp2p.github.io/js-libp2p/functions/fetch.fetchService-1.html",
|
|
29
|
+
"Identify": "https://libp2p.github.io/js-libp2p/interfaces/identify._internal_.Identify-1.html",
|
|
30
|
+
"IdentifyServiceComponents": "https://libp2p.github.io/js-libp2p/interfaces/identify.IdentifyServiceComponents.html",
|
|
31
|
+
"IdentifyServiceInit": "https://libp2p.github.io/js-libp2p/interfaces/identify.IdentifyServiceInit.html",
|
|
32
|
+
"Message": "https://libp2p.github.io/js-libp2p/variables/identify.Message.html",
|
|
33
|
+
"multicodecs": "https://libp2p.github.io/js-libp2p/variables/identify.multicodecs.html",
|
|
34
|
+
"identifyService": "https://libp2p.github.io/js-libp2p/functions/identify.identifyService.html",
|
|
20
35
|
"AddressFilter": "https://libp2p.github.io/js-libp2p/interfaces/index._internal_.AddressFilter.html",
|
|
21
36
|
"AddressManagerInit": "https://libp2p.github.io/js-libp2p/interfaces/index._internal_.AddressManagerInit.html",
|
|
22
|
-
"AutonatServiceInit": "https://libp2p.github.io/js-libp2p/interfaces/index._internal_.AutonatServiceInit.html",
|
|
23
37
|
"Components": "https://libp2p.github.io/js-libp2p/interfaces/index._internal_.Components.html",
|
|
24
38
|
"ConnectionManagerInit": "https://libp2p.github.io/js-libp2p/interfaces/index._internal_.ConnectionManagerInit.html",
|
|
25
|
-
"FetchServiceInit": "https://libp2p.github.io/js-libp2p/interfaces/index._internal_.FetchServiceInit.html",
|
|
26
|
-
"HostProperties": "https://libp2p.github.io/js-libp2p/interfaces/index._internal_.HostProperties.html",
|
|
27
|
-
"IdentifyServiceInit": "https://libp2p.github.io/js-libp2p/interfaces/index._internal_.IdentifyServiceInit.html",
|
|
28
|
-
"NatManagerInit": "https://libp2p.github.io/js-libp2p/interfaces/index._internal_.NatManagerInit.html",
|
|
29
|
-
"PeerRoutingInit": "https://libp2p.github.io/js-libp2p/interfaces/index._internal_.PeerRoutingInit.html",
|
|
30
|
-
"PingServiceInit": "https://libp2p.github.io/js-libp2p/interfaces/index._internal_.PingServiceInit.html",
|
|
31
|
-
"RefreshManagerInit": "https://libp2p.github.io/js-libp2p/interfaces/index._internal_.RefreshManagerInit.html",
|
|
32
39
|
"TransportManagerInit": "https://libp2p.github.io/js-libp2p/interfaces/index._internal_.TransportManagerInit.html",
|
|
33
|
-
"Libp2pEvents": "https://libp2p.github.io/js-libp2p/interfaces/index.Libp2pEvents.html",
|
|
34
40
|
"Libp2pInit": "https://libp2p.github.io/js-libp2p/interfaces/index.Libp2pInit.html",
|
|
35
41
|
"Libp2pOptions": "https://libp2p.github.io/js-libp2p/types/index.Libp2pOptions.html",
|
|
42
|
+
"ServiceFactoryMap": "https://libp2p.github.io/js-libp2p/types/index.ServiceFactoryMap.html",
|
|
36
43
|
"createLibp2p": "https://libp2p.github.io/js-libp2p/functions/index.createLibp2p.html",
|
|
37
44
|
"plaintext": "https://libp2p.github.io/js-libp2p/functions/insecure.plaintext.html",
|
|
45
|
+
"PingService": "https://libp2p.github.io/js-libp2p/interfaces/ping.PingService.html",
|
|
46
|
+
"PingServiceComponents": "https://libp2p.github.io/js-libp2p/interfaces/ping.PingServiceComponents.html",
|
|
47
|
+
"PingServiceInit": "https://libp2p.github.io/js-libp2p/interfaces/ping.PingServiceInit.html",
|
|
48
|
+
"pingService": "https://libp2p.github.io/js-libp2p/functions/ping.pingService-1.html",
|
|
38
49
|
"ProtectorInit": "https://libp2p.github.io/js-libp2p/interfaces/pnet.ProtectorInit.html",
|
|
39
50
|
"generateKey": "https://libp2p.github.io/js-libp2p/functions/pnet.generateKey.html",
|
|
40
|
-
"preSharedKey": "https://libp2p.github.io/js-libp2p/functions/pnet.preSharedKey.html"
|
|
51
|
+
"preSharedKey": "https://libp2p.github.io/js-libp2p/functions/pnet.preSharedKey.html",
|
|
52
|
+
"PMPOptions": "https://libp2p.github.io/js-libp2p/interfaces/upnp_nat.PMPOptions.html",
|
|
53
|
+
"UPnPNATComponents": "https://libp2p.github.io/js-libp2p/interfaces/upnp_nat.UPnPNATComponents.html",
|
|
54
|
+
"UPnPNATInit": "https://libp2p.github.io/js-libp2p/interfaces/upnp_nat.UPnPNATInit.html",
|
|
55
|
+
"uPnPNATService": "https://libp2p.github.io/js-libp2p/functions/upnp_nat.uPnPNATService.html"
|
|
41
56
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "libp2p",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.45.0",
|
|
4
4
|
"description": "JavaScript implementation of libp2p, a modular peer to peer network stack",
|
|
5
5
|
"license": "Apache-2.0 OR MIT",
|
|
6
6
|
"homepage": "https://github.com/libp2p/js-libp2p#readme",
|
|
@@ -52,14 +52,34 @@
|
|
|
52
52
|
"types": "./dist/src/index.d.ts",
|
|
53
53
|
"import": "./dist/src/index.js"
|
|
54
54
|
},
|
|
55
|
+
"./autonat": {
|
|
56
|
+
"types": "./dist/src/autonat/index.d.ts",
|
|
57
|
+
"import": "./dist/src/autonat/index.js"
|
|
58
|
+
},
|
|
55
59
|
"./circuit-relay": {
|
|
56
60
|
"types": "./dist/src/circuit-relay/index.d.ts",
|
|
57
61
|
"import": "./dist/src/circuit-relay/index.js"
|
|
58
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
|
+
},
|
|
59
71
|
"./insecure": {
|
|
60
72
|
"types": "./dist/src/insecure/index.d.ts",
|
|
61
73
|
"import": "./dist/src/insecure/index.js"
|
|
62
74
|
},
|
|
75
|
+
"./upnp-nat": {
|
|
76
|
+
"types": "./dist/src/upnp-nat/index.d.ts",
|
|
77
|
+
"import": "./dist/src/upnp-nat/index.js"
|
|
78
|
+
},
|
|
79
|
+
"./ping": {
|
|
80
|
+
"types": "./dist/src/ping/index.d.ts",
|
|
81
|
+
"import": "./dist/src/ping/index.js"
|
|
82
|
+
},
|
|
63
83
|
"./pnet": {
|
|
64
84
|
"types": "./dist/src/pnet/index.d.ts",
|
|
65
85
|
"import": "./dist/src/pnet/index.js"
|
|
@@ -80,7 +100,7 @@
|
|
|
80
100
|
"clean": "aegir clean",
|
|
81
101
|
"lint": "aegir lint",
|
|
82
102
|
"dep-check": "aegir dep-check -i protons",
|
|
83
|
-
"prepublishOnly": "node scripts/update-version.js",
|
|
103
|
+
"prepublishOnly": "node scripts/update-version.js && npm run build",
|
|
84
104
|
"build": "aegir build",
|
|
85
105
|
"docs": "aegir docs",
|
|
86
106
|
"generate": "run-s generate:proto:*",
|
|
@@ -101,41 +121,40 @@
|
|
|
101
121
|
"dependencies": {
|
|
102
122
|
"@achingbrain/nat-port-mapper": "^1.0.3",
|
|
103
123
|
"@libp2p/crypto": "^1.0.4",
|
|
104
|
-
"@libp2p/interface-address-manager": "^
|
|
105
|
-
"@libp2p/interface-connection": "^
|
|
106
|
-
"@libp2p/interface-connection-encrypter": "^
|
|
107
|
-
"@libp2p/interface-connection-gater": "^
|
|
108
|
-
"@libp2p/interface-connection-manager": "^
|
|
109
|
-
"@libp2p/interface-content-routing": "^2.
|
|
110
|
-
"@libp2p/interface-dht": "^2.0.0",
|
|
124
|
+
"@libp2p/interface-address-manager": "^3.0.0",
|
|
125
|
+
"@libp2p/interface-connection": "^5.0.0",
|
|
126
|
+
"@libp2p/interface-connection-encrypter": "^4.0.0",
|
|
127
|
+
"@libp2p/interface-connection-gater": "^3.0.0",
|
|
128
|
+
"@libp2p/interface-connection-manager": "^3.0.0",
|
|
129
|
+
"@libp2p/interface-content-routing": "^2.1.0",
|
|
111
130
|
"@libp2p/interface-keychain": "^2.0.4",
|
|
112
|
-
"@libp2p/interface-libp2p": "^1.0
|
|
131
|
+
"@libp2p/interface-libp2p": "^3.1.0",
|
|
113
132
|
"@libp2p/interface-metrics": "^4.0.0",
|
|
114
|
-
"@libp2p/interface-peer-discovery": "^
|
|
133
|
+
"@libp2p/interface-peer-discovery": "^2.0.0",
|
|
115
134
|
"@libp2p/interface-peer-id": "^2.0.1",
|
|
116
135
|
"@libp2p/interface-peer-info": "^1.0.3",
|
|
117
|
-
"@libp2p/interface-peer-routing": "^1.0
|
|
118
|
-
"@libp2p/interface-peer-store": "^
|
|
119
|
-
"@libp2p/interface-pubsub": "^
|
|
136
|
+
"@libp2p/interface-peer-routing": "^1.1.0",
|
|
137
|
+
"@libp2p/interface-peer-store": "^2.0.0",
|
|
138
|
+
"@libp2p/interface-pubsub": "^4.0.0",
|
|
120
139
|
"@libp2p/interface-record": "^2.0.6",
|
|
121
140
|
"@libp2p/interface-registrar": "^2.0.3",
|
|
122
|
-
"@libp2p/interface-stream-muxer": "^
|
|
123
|
-
"@libp2p/interface-transport": "^
|
|
141
|
+
"@libp2p/interface-stream-muxer": "^4.0.0",
|
|
142
|
+
"@libp2p/interface-transport": "^4.0.0",
|
|
124
143
|
"@libp2p/interfaces": "^3.2.0",
|
|
125
144
|
"@libp2p/keychain": "^2.0.0",
|
|
126
145
|
"@libp2p/logger": "^2.0.1",
|
|
127
|
-
"@libp2p/multistream-select": "^3.
|
|
146
|
+
"@libp2p/multistream-select": "^3.1.8",
|
|
128
147
|
"@libp2p/peer-collections": "^3.0.0",
|
|
129
148
|
"@libp2p/peer-id": "^2.0.0",
|
|
130
149
|
"@libp2p/peer-id-factory": "^2.0.0",
|
|
131
150
|
"@libp2p/peer-record": "^5.0.0",
|
|
132
|
-
"@libp2p/peer-store": "^
|
|
151
|
+
"@libp2p/peer-store": "^8.0.0",
|
|
133
152
|
"@libp2p/topology": "^4.0.1",
|
|
134
153
|
"@libp2p/tracked-map": "^3.0.0",
|
|
135
|
-
"@libp2p/utils": "^3.0.
|
|
154
|
+
"@libp2p/utils": "^3.0.10",
|
|
136
155
|
"@multiformats/mafmt": "^12.0.0",
|
|
137
156
|
"@multiformats/multiaddr": "^12.0.0",
|
|
138
|
-
"abortable-iterator": "^
|
|
157
|
+
"abortable-iterator": "^5.0.1",
|
|
139
158
|
"any-signal": "^4.1.1",
|
|
140
159
|
"datastore-core": "^9.0.0",
|
|
141
160
|
"interface-datastore": "^8.0.0",
|
|
@@ -143,52 +162,48 @@
|
|
|
143
162
|
"it-drain": "^3.0.1",
|
|
144
163
|
"it-filter": "^3.0.1",
|
|
145
164
|
"it-first": "^3.0.1",
|
|
146
|
-
"it-handshake": "^4.1.
|
|
147
|
-
"it-length-prefixed": "^9.0.
|
|
165
|
+
"it-handshake": "^4.1.3",
|
|
166
|
+
"it-length-prefixed": "^9.0.1",
|
|
148
167
|
"it-map": "^3.0.2",
|
|
149
168
|
"it-merge": "^3.0.0",
|
|
150
169
|
"it-pair": "^2.0.2",
|
|
151
170
|
"it-parallel": "^3.0.0",
|
|
152
|
-
"it-pb-stream": "^
|
|
171
|
+
"it-pb-stream": "^4.0.1",
|
|
153
172
|
"it-pipe": "^3.0.1",
|
|
154
|
-
"it-stream-types": "^
|
|
173
|
+
"it-stream-types": "^2.0.1",
|
|
155
174
|
"merge-options": "^3.0.4",
|
|
156
175
|
"multiformats": "^11.0.0",
|
|
157
176
|
"p-defer": "^4.0.0",
|
|
158
|
-
"p-fifo": "^1.0.0",
|
|
159
177
|
"p-queue": "^7.3.4",
|
|
160
178
|
"p-retry": "^5.0.0",
|
|
161
179
|
"private-ip": "^3.0.0",
|
|
162
180
|
"protons-runtime": "^5.0.0",
|
|
163
181
|
"rate-limiter-flexible": "^2.3.11",
|
|
164
|
-
"retimer": "^3.0.0",
|
|
165
182
|
"set-delayed-interval": "^1.0.0",
|
|
166
|
-
"timeout-abort-controller": "^3.0.0",
|
|
167
183
|
"uint8arraylist": "^2.3.2",
|
|
168
184
|
"uint8arrays": "^4.0.2",
|
|
169
185
|
"wherearewe": "^2.0.0",
|
|
170
186
|
"xsalsa20": "^1.1.0"
|
|
171
187
|
},
|
|
172
188
|
"devDependencies": {
|
|
173
|
-
"@chainsafe/libp2p-gossipsub": "^
|
|
189
|
+
"@chainsafe/libp2p-gossipsub": "^7.0.0",
|
|
174
190
|
"@chainsafe/libp2p-noise": "^11.0.0",
|
|
175
|
-
"@chainsafe/libp2p-yamux": "^
|
|
176
|
-
"@libp2p/bootstrap": "^
|
|
177
|
-
"@libp2p/daemon-client": "^
|
|
178
|
-
"@libp2p/daemon-server": "^
|
|
179
|
-
"@libp2p/floodsub": "^
|
|
180
|
-
"@libp2p/interface-compliance-tests": "^3.0.
|
|
181
|
-
"@libp2p/interface-connection-compliance-tests": "^2.0.
|
|
182
|
-
"@libp2p/interface-connection-encrypter-compliance-tests": "^
|
|
183
|
-
"@libp2p/interface-mocks": "^
|
|
184
|
-
"@libp2p/interop": "^
|
|
185
|
-
"@libp2p/kad-dht": "^
|
|
186
|
-
"@libp2p/mdns": "^
|
|
187
|
-
"@libp2p/mplex": "^
|
|
188
|
-
"@libp2p/pubsub": "^
|
|
189
|
-
"@libp2p/tcp": "^
|
|
190
|
-
"@libp2p/websockets": "^
|
|
191
|
-
"@types/p-fifo": "^1.0.0",
|
|
191
|
+
"@chainsafe/libp2p-yamux": "^4.0.1",
|
|
192
|
+
"@libp2p/bootstrap": "^8.0.0",
|
|
193
|
+
"@libp2p/daemon-client": "^6.0.2",
|
|
194
|
+
"@libp2p/daemon-server": "^5.0.2",
|
|
195
|
+
"@libp2p/floodsub": "^7.0.1",
|
|
196
|
+
"@libp2p/interface-compliance-tests": "^3.0.6",
|
|
197
|
+
"@libp2p/interface-connection-compliance-tests": "^2.0.8",
|
|
198
|
+
"@libp2p/interface-connection-encrypter-compliance-tests": "^5.0.0",
|
|
199
|
+
"@libp2p/interface-mocks": "^12.0.0",
|
|
200
|
+
"@libp2p/interop": "^8.0.0",
|
|
201
|
+
"@libp2p/kad-dht": "^9.2.0",
|
|
202
|
+
"@libp2p/mdns": "^8.0.0",
|
|
203
|
+
"@libp2p/mplex": "^8.0.1",
|
|
204
|
+
"@libp2p/pubsub": "^7.0.1",
|
|
205
|
+
"@libp2p/tcp": "^7.0.1",
|
|
206
|
+
"@libp2p/websockets": "^6.0.1",
|
|
192
207
|
"@types/varint": "^6.0.0",
|
|
193
208
|
"@types/xsalsa20": "^1.1.0",
|
|
194
209
|
"aegir": "^38.1.7",
|
|
@@ -207,6 +222,7 @@
|
|
|
207
222
|
"sinon-ts": "^1.0.0"
|
|
208
223
|
},
|
|
209
224
|
"browser": {
|
|
225
|
+
"./dist/src/config/connection-gater.js": "./dist/src/config/connection-gater.browser.js",
|
|
210
226
|
"nat-api": false
|
|
211
227
|
}
|
|
212
228
|
}
|
|
@@ -1,10 +1,15 @@
|
|
|
1
|
-
import type { AddressManagerEvents } from '@libp2p/interface-address-manager'
|
|
2
|
-
import { CustomEvent, EventEmitter } from '@libp2p/interfaces/events'
|
|
3
1
|
import type { Multiaddr } from '@multiformats/multiaddr'
|
|
4
2
|
import { multiaddr } from '@multiformats/multiaddr'
|
|
5
3
|
import { peerIdFromString } from '@libp2p/peer-id'
|
|
6
4
|
import type { PeerId } from '@libp2p/interface-peer-id'
|
|
7
5
|
import type { TransportManager } from '@libp2p/interface-transport'
|
|
6
|
+
import type { PeerStore } from '@libp2p/interface-peer-store'
|
|
7
|
+
import { logger } from '@libp2p/logger'
|
|
8
|
+
import type { EventEmitter } from '@libp2p/interfaces/dist/src/events'
|
|
9
|
+
import type { Libp2pEvents } from '@libp2p/interface-libp2p'
|
|
10
|
+
import { debounce } from './utils.js'
|
|
11
|
+
|
|
12
|
+
const log = logger('libp2p:address-manager')
|
|
8
13
|
|
|
9
14
|
export interface AddressManagerInit {
|
|
10
15
|
/**
|
|
@@ -32,6 +37,8 @@ export interface AddressManagerInit {
|
|
|
32
37
|
export interface DefaultAddressManagerComponents {
|
|
33
38
|
peerId: PeerId
|
|
34
39
|
transportManager: TransportManager
|
|
40
|
+
peerStore: PeerStore
|
|
41
|
+
events: EventEmitter<Libp2pEvents>
|
|
35
42
|
}
|
|
36
43
|
|
|
37
44
|
/**
|
|
@@ -67,7 +74,7 @@ function stripPeerId (ma: Multiaddr, peerId: PeerId): Multiaddr {
|
|
|
67
74
|
return ma
|
|
68
75
|
}
|
|
69
76
|
|
|
70
|
-
export class DefaultAddressManager
|
|
77
|
+
export class DefaultAddressManager {
|
|
71
78
|
private readonly components: DefaultAddressManagerComponents
|
|
72
79
|
// this is an array to allow for duplicates, e.g. multiples of `/ip4/0.0.0.0/tcp/0`
|
|
73
80
|
private readonly listen: string[]
|
|
@@ -81,9 +88,7 @@ export class DefaultAddressManager extends EventEmitter<AddressManagerEvents> {
|
|
|
81
88
|
* The listen addresses will be used by the libp2p transports to listen for new connections,
|
|
82
89
|
* while the announce addresses will be used for the peer addresses' to other peers in the network.
|
|
83
90
|
*/
|
|
84
|
-
constructor (components: DefaultAddressManagerComponents, init: AddressManagerInit) {
|
|
85
|
-
super()
|
|
86
|
-
|
|
91
|
+
constructor (components: DefaultAddressManagerComponents, init: AddressManagerInit = {}) {
|
|
87
92
|
const { listen = [], announce = [] } = init
|
|
88
93
|
|
|
89
94
|
this.components = components
|
|
@@ -91,6 +96,43 @@ export class DefaultAddressManager extends EventEmitter<AddressManagerEvents> {
|
|
|
91
96
|
this.announce = new Set(announce.map(ma => ma.toString()))
|
|
92
97
|
this.observed = new Map()
|
|
93
98
|
this.announceFilter = init.announceFilter ?? defaultAddressFilter
|
|
99
|
+
|
|
100
|
+
// this method gets called repeatedly on startup when transports start listening so
|
|
101
|
+
// debounce it so we don't cause multiple self:peer:update events to be emitted
|
|
102
|
+
this._updatePeerStoreAddresses = debounce(this._updatePeerStoreAddresses.bind(this), 1000)
|
|
103
|
+
|
|
104
|
+
// update our stored addresses when new transports listen
|
|
105
|
+
components.events.addEventListener('transport:listening', () => {
|
|
106
|
+
this._updatePeerStoreAddresses()
|
|
107
|
+
})
|
|
108
|
+
// update our stored addresses when existing transports stop listening
|
|
109
|
+
components.events.addEventListener('transport:close', () => {
|
|
110
|
+
this._updatePeerStoreAddresses()
|
|
111
|
+
})
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
_updatePeerStoreAddresses (): void {
|
|
115
|
+
// if announce addresses have been configured, ensure they make it into our peer
|
|
116
|
+
// record for things like identify
|
|
117
|
+
const addrs = this.getAnnounceAddrs()
|
|
118
|
+
.concat(this.components.transportManager.getAddrs())
|
|
119
|
+
.concat(
|
|
120
|
+
[...this.observed.entries()]
|
|
121
|
+
.filter(([_, metadata]) => metadata.confident)
|
|
122
|
+
.map(([str]) => multiaddr(str))
|
|
123
|
+
).map(ma => {
|
|
124
|
+
// strip our peer id if it is present
|
|
125
|
+
if (ma.getPeerId() === this.components.peerId.toString()) {
|
|
126
|
+
return ma.decapsulate(`/p2p/${this.components.peerId.toString()}`)
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
return ma
|
|
130
|
+
})
|
|
131
|
+
|
|
132
|
+
this.components.peerStore.patch(this.components.peerId, {
|
|
133
|
+
multiaddrs: addrs
|
|
134
|
+
})
|
|
135
|
+
.catch(err => { log.error('error updating addresses', err) })
|
|
94
136
|
}
|
|
95
137
|
|
|
96
138
|
/**
|
|
@@ -145,9 +187,9 @@ export class DefaultAddressManager extends EventEmitter<AddressManagerEvents> {
|
|
|
145
187
|
confident: true
|
|
146
188
|
})
|
|
147
189
|
|
|
148
|
-
// only trigger the
|
|
190
|
+
// only trigger the 'self:peer:update' event if our confidence in an address has changed
|
|
149
191
|
if (!startingConfidence) {
|
|
150
|
-
this.
|
|
192
|
+
this._updatePeerStoreAddresses()
|
|
151
193
|
}
|
|
152
194
|
}
|
|
153
195
|
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
|
|
2
|
+
export function debounce (func: () => void, wait: number): () => void {
|
|
3
|
+
let timeout: ReturnType<typeof setTimeout> | undefined
|
|
4
|
+
|
|
5
|
+
return function () {
|
|
6
|
+
const later = function (): void {
|
|
7
|
+
timeout = undefined
|
|
8
|
+
func()
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
clearTimeout(timeout)
|
|
12
|
+
timeout = setTimeout(later, wait)
|
|
13
|
+
}
|
|
14
|
+
}
|
package/src/autonat/constants.ts
CHANGED
|
@@ -1,4 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The prefix to use in the protocol
|
|
3
|
+
*/
|
|
4
|
+
export const PROTOCOL_PREFIX = 'libp2p'
|
|
1
5
|
|
|
2
|
-
|
|
3
|
-
|
|
6
|
+
/**
|
|
7
|
+
* The name to use in the protocol
|
|
8
|
+
*/
|
|
4
9
|
export const PROTOCOL_NAME = 'autonat'
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* The version to use in the protocol
|
|
13
|
+
*/
|
|
14
|
+
export const PROTOCOL_VERSION = '1.0.0'
|
|
15
|
+
export const TIMEOUT = 30000
|
|
16
|
+
export const STARTUP_DELAY = 5000
|
|
17
|
+
export const REFRESH_INTERVAL = 60000
|
|
18
|
+
export const MAX_INBOUND_STREAMS = 1
|
|
19
|
+
export const MAX_OUTBOUND_STREAMS = 1
|
package/src/autonat/index.ts
CHANGED
|
@@ -19,11 +19,13 @@ import map from 'it-map'
|
|
|
19
19
|
import parallel from 'it-parallel'
|
|
20
20
|
import { pipe } from 'it-pipe'
|
|
21
21
|
import isPrivateIp from 'private-ip'
|
|
22
|
-
import { TimeoutController } from 'timeout-abort-controller'
|
|
23
22
|
import {
|
|
24
|
-
|
|
23
|
+
MAX_INBOUND_STREAMS,
|
|
24
|
+
MAX_OUTBOUND_STREAMS,
|
|
25
|
+
PROTOCOL_NAME, PROTOCOL_PREFIX, PROTOCOL_VERSION, REFRESH_INTERVAL, STARTUP_DELAY, TIMEOUT
|
|
25
26
|
} from './constants.js'
|
|
26
27
|
import { Message } from './pb/index.js'
|
|
28
|
+
import { anySignal } from 'any-signal'
|
|
27
29
|
|
|
28
30
|
const log = logger('libp2p:autonat')
|
|
29
31
|
|
|
@@ -32,45 +34,39 @@ const log = logger('libp2p:autonat')
|
|
|
32
34
|
// https://github.com/libp2p/specs/blob/master/autonat/README.md#autonat-protocol
|
|
33
35
|
const REQUIRED_SUCCESSFUL_DIALS = 4
|
|
34
36
|
|
|
35
|
-
|
|
36
|
-
const AUTONAT_STARTUP_DELAY = 5000
|
|
37
|
-
|
|
38
|
-
// Only try to verify our external address this often
|
|
39
|
-
const AUTONAT_REFRESH_INTERVAL = 60000
|
|
40
|
-
|
|
41
|
-
export interface AutonatServiceInit {
|
|
37
|
+
export interface AutoNATServiceInit {
|
|
42
38
|
/**
|
|
43
39
|
* Allows overriding the protocol prefix used
|
|
44
40
|
*/
|
|
45
|
-
protocolPrefix
|
|
41
|
+
protocolPrefix?: string
|
|
46
42
|
|
|
47
43
|
/**
|
|
48
44
|
* How long we should wait for a remote peer to verify our external address
|
|
49
45
|
*/
|
|
50
|
-
timeout
|
|
46
|
+
timeout?: number
|
|
51
47
|
|
|
52
48
|
/**
|
|
53
49
|
* How long to wait after startup before trying to verify our external address
|
|
54
50
|
*/
|
|
55
|
-
startupDelay
|
|
51
|
+
startupDelay?: number
|
|
56
52
|
|
|
57
53
|
/**
|
|
58
54
|
* Verify our external addresses this often
|
|
59
55
|
*/
|
|
60
|
-
refreshInterval
|
|
56
|
+
refreshInterval?: number
|
|
61
57
|
|
|
62
58
|
/**
|
|
63
|
-
* How many parallel inbound
|
|
59
|
+
* How many parallel inbound autoNAT streams we allow per-connection
|
|
64
60
|
*/
|
|
65
|
-
maxInboundStreams
|
|
61
|
+
maxInboundStreams?: number
|
|
66
62
|
|
|
67
63
|
/**
|
|
68
|
-
* How many parallel outbound
|
|
64
|
+
* How many parallel outbound autoNAT streams we allow per-connection
|
|
69
65
|
*/
|
|
70
|
-
maxOutboundStreams
|
|
66
|
+
maxOutboundStreams?: number
|
|
71
67
|
}
|
|
72
68
|
|
|
73
|
-
export interface
|
|
69
|
+
export interface AutoNATComponents {
|
|
74
70
|
registrar: Registrar
|
|
75
71
|
addressManager: AddressManager
|
|
76
72
|
transportManager: TransportManager
|
|
@@ -79,21 +75,26 @@ export interface DefaultAutonatComponents {
|
|
|
79
75
|
peerRouting: PeerRouting
|
|
80
76
|
}
|
|
81
77
|
|
|
82
|
-
|
|
83
|
-
private readonly components:
|
|
84
|
-
private readonly _init: AutonatServiceInit
|
|
78
|
+
class DefaultAutoNATService implements Startable {
|
|
79
|
+
private readonly components: AutoNATComponents
|
|
85
80
|
private readonly startupDelay: number
|
|
86
81
|
private readonly refreshInterval: number
|
|
82
|
+
private readonly protocol: string
|
|
83
|
+
private readonly timeout: number
|
|
84
|
+
private readonly maxInboundStreams: number
|
|
85
|
+
private readonly maxOutboundStreams: number
|
|
87
86
|
private verifyAddressTimeout?: ReturnType<typeof setTimeout>
|
|
88
87
|
private started: boolean
|
|
89
88
|
|
|
90
|
-
constructor (components:
|
|
89
|
+
constructor (components: AutoNATComponents, init: AutoNATServiceInit) {
|
|
91
90
|
this.components = components
|
|
92
91
|
this.started = false
|
|
93
|
-
this.
|
|
94
|
-
this.
|
|
95
|
-
this.
|
|
96
|
-
|
|
92
|
+
this.protocol = `/${init.protocolPrefix ?? PROTOCOL_PREFIX}/${PROTOCOL_NAME}/${PROTOCOL_VERSION}`
|
|
93
|
+
this.timeout = init.timeout ?? TIMEOUT
|
|
94
|
+
this.maxInboundStreams = init.maxInboundStreams ?? MAX_INBOUND_STREAMS
|
|
95
|
+
this.maxOutboundStreams = init.maxOutboundStreams ?? MAX_OUTBOUND_STREAMS
|
|
96
|
+
this.startupDelay = init.startupDelay ?? STARTUP_DELAY
|
|
97
|
+
this.refreshInterval = init.refreshInterval ?? REFRESH_INTERVAL
|
|
97
98
|
this._verifyExternalAddresses = this._verifyExternalAddresses.bind(this)
|
|
98
99
|
}
|
|
99
100
|
|
|
@@ -106,14 +107,14 @@ export class AutonatService implements Startable {
|
|
|
106
107
|
return
|
|
107
108
|
}
|
|
108
109
|
|
|
109
|
-
await this.components.registrar.handle(
|
|
110
|
+
await this.components.registrar.handle(this.protocol, (data) => {
|
|
110
111
|
void this.handleIncomingAutonatStream(data)
|
|
111
112
|
.catch(err => {
|
|
112
113
|
log.error(err)
|
|
113
114
|
})
|
|
114
115
|
}, {
|
|
115
|
-
maxInboundStreams: this.
|
|
116
|
-
maxOutboundStreams: this.
|
|
116
|
+
maxInboundStreams: this.maxInboundStreams,
|
|
117
|
+
maxOutboundStreams: this.maxOutboundStreams
|
|
117
118
|
})
|
|
118
119
|
|
|
119
120
|
this.verifyAddressTimeout = setTimeout(this._verifyExternalAddresses, this.startupDelay)
|
|
@@ -122,30 +123,30 @@ export class AutonatService implements Startable {
|
|
|
122
123
|
}
|
|
123
124
|
|
|
124
125
|
async stop (): Promise<void> {
|
|
125
|
-
await this.components.registrar.unhandle(
|
|
126
|
+
await this.components.registrar.unhandle(this.protocol)
|
|
126
127
|
clearTimeout(this.verifyAddressTimeout)
|
|
127
128
|
|
|
128
129
|
this.started = false
|
|
129
130
|
}
|
|
130
131
|
|
|
131
132
|
/**
|
|
132
|
-
* Handle an incoming
|
|
133
|
+
* Handle an incoming AutoNAT request
|
|
133
134
|
*/
|
|
134
135
|
async handleIncomingAutonatStream (data: IncomingStreamData): Promise<void> {
|
|
135
|
-
const
|
|
136
|
+
const signal = anySignal([AbortSignal.timeout(this.timeout)])
|
|
136
137
|
|
|
137
138
|
// this controller may be used while dialing lots of peers so prevent MaxListenersExceededWarning
|
|
138
139
|
// appearing in the console
|
|
139
140
|
try {
|
|
140
141
|
// fails on node < 15.4
|
|
141
|
-
setMaxListeners?.(Infinity,
|
|
142
|
+
setMaxListeners?.(Infinity, signal)
|
|
142
143
|
} catch {}
|
|
143
144
|
|
|
144
145
|
const ourHosts = this.components.addressManager.getAddresses()
|
|
145
146
|
.map(ma => ma.toOptions().host)
|
|
146
147
|
|
|
147
148
|
try {
|
|
148
|
-
const source = abortableDuplex(data.stream,
|
|
149
|
+
const source = abortableDuplex(data.stream, signal)
|
|
149
150
|
const self = this
|
|
150
151
|
|
|
151
152
|
await pipe(
|
|
@@ -319,7 +320,7 @@ export class AutonatService implements Startable {
|
|
|
319
320
|
|
|
320
321
|
try {
|
|
321
322
|
connection = await self.components.connectionManager.openConnection(multiaddr, {
|
|
322
|
-
signal
|
|
323
|
+
signal
|
|
323
324
|
})
|
|
324
325
|
|
|
325
326
|
if (!connection.remoteAddr.equals(multiaddr)) {
|
|
@@ -362,8 +363,10 @@ export class AutonatService implements Startable {
|
|
|
362
363
|
// can't tell the remote when a dial timed out..
|
|
363
364
|
data.stream
|
|
364
365
|
)
|
|
366
|
+
} catch (err) {
|
|
367
|
+
log.error(err)
|
|
365
368
|
} finally {
|
|
366
|
-
|
|
369
|
+
signal.clear()
|
|
367
370
|
}
|
|
368
371
|
}
|
|
369
372
|
|
|
@@ -401,13 +404,13 @@ export class AutonatService implements Startable {
|
|
|
401
404
|
return
|
|
402
405
|
}
|
|
403
406
|
|
|
404
|
-
const
|
|
407
|
+
const signal = AbortSignal.timeout(this.timeout)
|
|
405
408
|
|
|
406
409
|
// this controller may be used while dialing lots of peers so prevent MaxListenersExceededWarning
|
|
407
410
|
// appearing in the console
|
|
408
411
|
try {
|
|
409
412
|
// fails on node < 15.4
|
|
410
|
-
setMaxListeners?.(Infinity,
|
|
413
|
+
setMaxListeners?.(Infinity, signal)
|
|
411
414
|
} catch {}
|
|
412
415
|
|
|
413
416
|
const self = this
|
|
@@ -431,18 +434,18 @@ export class AutonatService implements Startable {
|
|
|
431
434
|
const results: Record<string, { success: number, failure: number }> = {}
|
|
432
435
|
const networkSegments: string[] = []
|
|
433
436
|
|
|
434
|
-
|
|
437
|
+
const verifyAddress = async (peer: PeerInfo): Promise<Message.DialResponse | undefined> => {
|
|
435
438
|
try {
|
|
436
439
|
log('Asking %p to verify multiaddr', peer.id)
|
|
437
440
|
|
|
438
441
|
const connection = await self.components.connectionManager.openConnection(peer.id, {
|
|
439
|
-
signal
|
|
442
|
+
signal
|
|
440
443
|
})
|
|
441
444
|
|
|
442
|
-
const stream = await connection.newStream(
|
|
443
|
-
signal
|
|
445
|
+
const stream = await connection.newStream(this.protocol, {
|
|
446
|
+
signal
|
|
444
447
|
})
|
|
445
|
-
const source = abortableDuplex(stream,
|
|
448
|
+
const source = abortableDuplex(stream, signal)
|
|
446
449
|
|
|
447
450
|
const buf = await pipe(
|
|
448
451
|
[request],
|
|
@@ -493,7 +496,7 @@ export class AutonatService implements Startable {
|
|
|
493
496
|
}
|
|
494
497
|
|
|
495
498
|
for await (const dialResponse of parallel(map(this.components.peerRouting.getClosestPeers(randomCid, {
|
|
496
|
-
signal
|
|
499
|
+
signal
|
|
497
500
|
}), (peer) => async () => await verifyAddress(peer)), {
|
|
498
501
|
concurrency: REQUIRED_SUCCESSFUL_DIALS
|
|
499
502
|
})) {
|
|
@@ -557,8 +560,13 @@ export class AutonatService implements Startable {
|
|
|
557
560
|
}
|
|
558
561
|
}
|
|
559
562
|
} finally {
|
|
560
|
-
controller.clear()
|
|
561
563
|
this.verifyAddressTimeout = setTimeout(this._verifyExternalAddresses, this.refreshInterval)
|
|
562
564
|
}
|
|
563
565
|
}
|
|
564
566
|
}
|
|
567
|
+
|
|
568
|
+
export function autoNATService (init: AutoNATServiceInit = {}): (components: AutoNATComponents) => {} {
|
|
569
|
+
return (components) => {
|
|
570
|
+
return new DefaultAutoNATService(components, init)
|
|
571
|
+
}
|
|
572
|
+
}
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
} from '../constants.js'
|
|
8
8
|
import type { Startable } from '@libp2p/interfaces/startable'
|
|
9
9
|
import type { ContentRouting } from '@libp2p/interface-content-routing'
|
|
10
|
-
import {
|
|
10
|
+
import { EventEmitter } from '@libp2p/interfaces/events'
|
|
11
11
|
import pRetry from 'p-retry'
|
|
12
12
|
|
|
13
13
|
const log = logger('libp2p:circuit-relay:advert-service')
|
|
@@ -90,7 +90,7 @@ export class AdvertService extends EventEmitter<AdvertServiceEvents> implements
|
|
|
90
90
|
const cid = await namespaceToCid(RELAY_RENDEZVOUS_NS)
|
|
91
91
|
await this.contentRouting.provide(cid)
|
|
92
92
|
|
|
93
|
-
this.
|
|
93
|
+
this.safeDispatchEvent('advert:success', { detail: undefined })
|
|
94
94
|
} catch (err: any) {
|
|
95
95
|
this.safeDispatchEvent('advert:error', { detail: err })
|
|
96
96
|
|