libp2p 0.46.21 → 1.0.0-551622a96
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +51 -47
- package/dist/index.min.js +40 -28
- package/dist/src/address-manager/index.d.ts +4 -5
- package/dist/src/address-manager/index.d.ts.map +1 -1
- package/dist/src/address-manager/index.js +3 -3
- package/dist/src/address-manager/index.js.map +1 -1
- package/dist/src/components.d.ts +4 -15
- package/dist/src/components.d.ts.map +1 -1
- package/dist/src/components.js +2 -2
- package/dist/src/components.js.map +1 -1
- package/dist/src/config/connection-gater.browser.d.ts +1 -1
- package/dist/src/config/connection-gater.browser.d.ts.map +1 -1
- package/dist/src/config/connection-gater.browser.js.map +1 -1
- package/dist/src/config/connection-gater.d.ts +1 -1
- package/dist/src/config/connection-gater.d.ts.map +1 -1
- package/dist/src/config.d.ts.map +1 -1
- package/dist/src/config.js +1 -2
- package/dist/src/config.js.map +1 -1
- package/dist/src/connection/index.d.ts +4 -6
- package/dist/src/connection/index.d.ts.map +1 -1
- package/dist/src/connection/index.js +11 -13
- package/dist/src/connection/index.js.map +1 -1
- package/dist/src/connection-manager/auto-dial.d.ts +3 -6
- package/dist/src/connection-manager/auto-dial.d.ts.map +1 -1
- package/dist/src/connection-manager/auto-dial.js +21 -21
- package/dist/src/connection-manager/auto-dial.js.map +1 -1
- package/dist/src/connection-manager/connection-pruner.d.ts +3 -5
- package/dist/src/connection-manager/connection-pruner.d.ts.map +1 -1
- package/dist/src/connection-manager/connection-pruner.js +8 -8
- package/dist/src/connection-manager/connection-pruner.js.map +1 -1
- package/dist/src/connection-manager/constants.defaults.d.ts +0 -4
- package/dist/src/connection-manager/constants.defaults.d.ts.map +1 -1
- package/dist/src/connection-manager/constants.defaults.js +0 -4
- package/dist/src/connection-manager/constants.defaults.js.map +1 -1
- package/dist/src/connection-manager/dial-queue.d.ts +3 -10
- package/dist/src/connection-manager/dial-queue.d.ts.map +1 -1
- package/dist/src/connection-manager/dial-queue.js +30 -38
- package/dist/src/connection-manager/dial-queue.js.map +1 -1
- package/dist/src/connection-manager/index.d.ts +3 -18
- package/dist/src/connection-manager/index.d.ts.map +1 -1
- package/dist/src/connection-manager/index.js +17 -18
- package/dist/src/connection-manager/index.js.map +1 -1
- package/dist/src/connection-manager/utils.js +1 -1
- package/dist/src/connection-manager/utils.js.map +1 -1
- package/dist/src/content-routing/index.d.ts +1 -5
- package/dist/src/content-routing/index.d.ts.map +1 -1
- package/dist/src/content-routing/index.js +2 -2
- package/dist/src/content-routing/index.js.map +1 -1
- package/dist/src/content-routing/utils.d.ts +1 -2
- package/dist/src/content-routing/utils.d.ts.map +1 -1
- package/dist/src/content-routing/utils.js +1 -1
- package/dist/src/content-routing/utils.js.map +1 -1
- package/dist/src/errors.d.ts +0 -2
- package/dist/src/errors.d.ts.map +1 -1
- package/dist/src/errors.js +0 -2
- package/dist/src/errors.js.map +1 -1
- package/dist/src/get-peer.d.ts +1 -1
- package/dist/src/get-peer.d.ts.map +1 -1
- package/dist/src/get-peer.js +1 -5
- package/dist/src/get-peer.js.map +1 -1
- package/dist/src/index.d.ts +5 -16
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/libp2p.d.ts +4 -12
- package/dist/src/libp2p.d.ts.map +1 -1
- package/dist/src/libp2p.js +31 -65
- package/dist/src/libp2p.js.map +1 -1
- package/dist/src/peer-routing.d.ts +6 -6
- package/dist/src/peer-routing.d.ts.map +1 -1
- package/dist/src/peer-routing.js +12 -9
- package/dist/src/peer-routing.js.map +1 -1
- package/dist/src/registrar.d.ts +5 -7
- package/dist/src/registrar.d.ts.map +1 -1
- package/dist/src/registrar.js +4 -4
- package/dist/src/registrar.js.map +1 -1
- package/dist/src/transport-manager.d.ts +5 -9
- package/dist/src/transport-manager.d.ts.map +1 -1
- package/dist/src/transport-manager.js +12 -13
- package/dist/src/transport-manager.js.map +1 -1
- package/dist/src/upgrader.d.ts +8 -19
- package/dist/src/upgrader.d.ts.map +1 -1
- package/dist/src/upgrader.js +75 -38
- package/dist/src/upgrader.js.map +1 -1
- package/dist/src/version.d.ts +1 -1
- package/dist/src/version.d.ts.map +1 -1
- package/dist/src/version.js +1 -1
- package/dist/src/version.js.map +1 -1
- package/package.json +37 -106
- package/src/address-manager/index.ts +6 -9
- package/src/components.ts +5 -16
- package/src/config/connection-gater.browser.ts +1 -1
- package/src/config/connection-gater.ts +1 -1
- package/src/config.ts +1 -2
- package/src/connection/index.ts +12 -17
- package/src/connection-manager/auto-dial.ts +23 -26
- package/src/connection-manager/connection-pruner.ts +10 -12
- package/src/connection-manager/constants.defaults.ts +0 -5
- package/src/connection-manager/dial-queue.ts +31 -46
- package/src/connection-manager/index.ts +19 -36
- package/src/connection-manager/utils.ts +1 -1
- package/src/content-routing/index.ts +3 -7
- package/src/content-routing/utils.ts +2 -3
- package/src/errors.ts +0 -2
- package/src/get-peer.ts +2 -7
- package/src/index.ts +6 -17
- package/src/libp2p.ts +32 -80
- package/src/peer-routing.ts +16 -15
- package/src/registrar.ts +8 -12
- package/src/transport-manager.ts +15 -22
- package/src/upgrader.ts +110 -64
- package/src/version.ts +1 -1
- package/dist/src/autonat/constants.d.ts +0 -18
- package/dist/src/autonat/constants.d.ts.map +0 -1
- package/dist/src/autonat/constants.js +0 -18
- package/dist/src/autonat/constants.js.map +0 -1
- package/dist/src/autonat/index.d.ts +0 -62
- package/dist/src/autonat/index.d.ts.map +0 -1
- package/dist/src/autonat/index.js +0 -447
- package/dist/src/autonat/index.js.map +0 -1
- package/dist/src/autonat/pb/index.d.ts +0 -57
- package/dist/src/autonat/pb/index.d.ts.map +0 -1
- package/dist/src/autonat/pb/index.js +0 -250
- package/dist/src/autonat/pb/index.js.map +0 -1
- package/dist/src/circuit-relay/constants.d.ts +0 -50
- package/dist/src/circuit-relay/constants.d.ts.map +0 -1
- package/dist/src/circuit-relay/constants.js +0 -56
- package/dist/src/circuit-relay/constants.js.map +0 -1
- package/dist/src/circuit-relay/index.d.ts +0 -55
- package/dist/src/circuit-relay/index.d.ts.map +0 -1
- package/dist/src/circuit-relay/index.js +0 -38
- package/dist/src/circuit-relay/index.js.map +0 -1
- package/dist/src/circuit-relay/pb/index.d.ts +0 -93
- package/dist/src/circuit-relay/pb/index.d.ts.map +0 -1
- package/dist/src/circuit-relay/pb/index.js +0 -425
- package/dist/src/circuit-relay/pb/index.js.map +0 -1
- package/dist/src/circuit-relay/server/advert-service.d.ts +0 -43
- package/dist/src/circuit-relay/server/advert-service.d.ts.map +0 -1
- package/dist/src/circuit-relay/server/advert-service.js +0 -73
- package/dist/src/circuit-relay/server/advert-service.js.map +0 -1
- package/dist/src/circuit-relay/server/index.d.ts +0 -65
- package/dist/src/circuit-relay/server/index.d.ts.map +0 -1
- package/dist/src/circuit-relay/server/index.js +0 -312
- package/dist/src/circuit-relay/server/index.js.map +0 -1
- package/dist/src/circuit-relay/server/reservation-store.d.ts +0 -49
- package/dist/src/circuit-relay/server/reservation-store.d.ts.map +0 -1
- package/dist/src/circuit-relay/server/reservation-store.js +0 -65
- package/dist/src/circuit-relay/server/reservation-store.js.map +0 -1
- package/dist/src/circuit-relay/server/reservation-voucher.d.ts +0 -18
- package/dist/src/circuit-relay/server/reservation-voucher.d.ts.map +0 -1
- package/dist/src/circuit-relay/server/reservation-voucher.js +0 -36
- package/dist/src/circuit-relay/server/reservation-voucher.js.map +0 -1
- package/dist/src/circuit-relay/transport/discovery.d.ts +0 -45
- package/dist/src/circuit-relay/transport/discovery.d.ts.map +0 -1
- package/dist/src/circuit-relay/transport/discovery.js +0 -97
- package/dist/src/circuit-relay/transport/discovery.js.map +0 -1
- package/dist/src/circuit-relay/transport/index.d.ts +0 -57
- package/dist/src/circuit-relay/transport/index.d.ts.map +0 -1
- package/dist/src/circuit-relay/transport/index.js +0 -276
- package/dist/src/circuit-relay/transport/index.js.map +0 -1
- package/dist/src/circuit-relay/transport/listener.d.ts +0 -9
- package/dist/src/circuit-relay/transport/listener.d.ts.map +0 -1
- package/dist/src/circuit-relay/transport/listener.js +0 -66
- package/dist/src/circuit-relay/transport/listener.js.map +0 -1
- package/dist/src/circuit-relay/transport/reservation-store.d.ts +0 -72
- package/dist/src/circuit-relay/transport/reservation-store.d.ts.map +0 -1
- package/dist/src/circuit-relay/transport/reservation-store.js +0 -209
- package/dist/src/circuit-relay/transport/reservation-store.js.map +0 -1
- package/dist/src/circuit-relay/utils.d.ts +0 -13
- package/dist/src/circuit-relay/utils.d.ts.map +0 -1
- package/dist/src/circuit-relay/utils.js +0 -108
- package/dist/src/circuit-relay/utils.js.map +0 -1
- package/dist/src/dcutr/dcutr.d.ts +0 -43
- package/dist/src/dcutr/dcutr.d.ts.map +0 -1
- package/dist/src/dcutr/dcutr.js +0 -313
- package/dist/src/dcutr/dcutr.js.map +0 -1
- package/dist/src/dcutr/index.d.ts +0 -92
- package/dist/src/dcutr/index.d.ts.map +0 -1
- package/dist/src/dcutr/index.js +0 -63
- package/dist/src/dcutr/index.js.map +0 -1
- package/dist/src/dcutr/pb/message.d.ts +0 -20
- package/dist/src/dcutr/pb/message.d.ts.map +0 -1
- package/dist/src/dcutr/pb/message.js +0 -77
- package/dist/src/dcutr/pb/message.js.map +0 -1
- package/dist/src/dcutr/utils.d.ts +0 -8
- package/dist/src/dcutr/utils.d.ts.map +0 -1
- package/dist/src/dcutr/utils.js +0 -27
- package/dist/src/dcutr/utils.js.map +0 -1
- package/dist/src/fetch/constants.d.ts +0 -3
- package/dist/src/fetch/constants.d.ts.map +0 -1
- package/dist/src/fetch/constants.js +0 -4
- package/dist/src/fetch/constants.js.map +0 -1
- package/dist/src/fetch/index.d.ts +0 -61
- package/dist/src/fetch/index.d.ts.map +0 -1
- package/dist/src/fetch/index.js +0 -205
- package/dist/src/fetch/index.js.map +0 -1
- package/dist/src/fetch/pb/proto.d.ts +0 -28
- package/dist/src/fetch/pb/proto.d.ts.map +0 -1
- package/dist/src/fetch/pb/proto.js +0 -120
- package/dist/src/fetch/pb/proto.js.map +0 -1
- package/dist/src/identify/consts.d.ts +0 -10
- package/dist/src/identify/consts.d.ts.map +0 -1
- package/dist/src/identify/consts.js +0 -11
- package/dist/src/identify/consts.js.map +0 -1
- package/dist/src/identify/identify.d.ts +0 -54
- package/dist/src/identify/identify.d.ts.map +0 -1
- package/dist/src/identify/identify.js +0 -447
- package/dist/src/identify/identify.js.map +0 -1
- package/dist/src/identify/index.d.ts +0 -72
- package/dist/src/identify/index.d.ts.map +0 -1
- package/dist/src/identify/index.js +0 -15
- package/dist/src/identify/index.js.map +0 -1
- package/dist/src/identify/pb/message.d.ts +0 -17
- package/dist/src/identify/pb/message.d.ts.map +0 -1
- package/dist/src/identify/pb/message.js +0 -98
- package/dist/src/identify/pb/message.js.map +0 -1
- package/dist/src/insecure/index.d.ts +0 -26
- package/dist/src/insecure/index.d.ts.map +0 -1
- package/dist/src/insecure/index.js +0 -110
- package/dist/src/insecure/index.js.map +0 -1
- package/dist/src/insecure/pb/proto.d.ts +0 -30
- package/dist/src/insecure/pb/proto.d.ts.map +0 -1
- package/dist/src/insecure/pb/proto.js +0 -127
- package/dist/src/insecure/pb/proto.js.map +0 -1
- package/dist/src/ping/constants.d.ts +0 -9
- package/dist/src/ping/constants.d.ts.map +0 -1
- package/dist/src/ping/constants.js +0 -15
- package/dist/src/ping/constants.js.map +0 -1
- package/dist/src/ping/index.d.ts +0 -24
- package/dist/src/ping/index.d.ts.map +0 -1
- package/dist/src/ping/index.js +0 -115
- package/dist/src/ping/index.js.map +0 -1
- package/dist/src/pnet/crypto.d.ts +0 -18
- package/dist/src/pnet/crypto.d.ts.map +0 -1
- package/dist/src/pnet/crypto.js +0 -60
- package/dist/src/pnet/crypto.js.map +0 -1
- package/dist/src/pnet/errors.d.ts +0 -6
- package/dist/src/pnet/errors.d.ts.map +0 -1
- package/dist/src/pnet/errors.js +0 -6
- package/dist/src/pnet/errors.js.map +0 -1
- package/dist/src/pnet/index.d.ts +0 -31
- package/dist/src/pnet/index.d.ts.map +0 -1
- package/dist/src/pnet/index.js +0 -97
- package/dist/src/pnet/index.js.map +0 -1
- package/dist/src/pnet/key-generator.d.ts +0 -11
- package/dist/src/pnet/key-generator.d.ts.map +0 -1
- package/dist/src/pnet/key-generator.js +0 -22
- package/dist/src/pnet/key-generator.js.map +0 -1
- package/dist/src/upnp-nat/index.d.ts +0 -71
- package/dist/src/upnp-nat/index.d.ts.map +0 -1
- package/dist/src/upnp-nat/index.js +0 -136
- package/dist/src/upnp-nat/index.js.map +0 -1
- package/dist/src/utils/peer-job-queue.d.ts +0 -33
- package/dist/src/utils/peer-job-queue.d.ts.map +0 -1
- package/dist/src/utils/peer-job-queue.js +0 -82
- package/dist/src/utils/peer-job-queue.js.map +0 -1
- package/dist/typedoc-urls.json +0 -71
- package/src/autonat/constants.ts +0 -19
- package/src/autonat/index.ts +0 -597
- package/src/autonat/pb/index.proto +0 -35
- package/src/autonat/pb/index.ts +0 -320
- package/src/circuit-relay/constants.ts +0 -72
- package/src/circuit-relay/index.ts +0 -59
- package/src/circuit-relay/pb/index.proto +0 -67
- package/src/circuit-relay/pb/index.ts +0 -539
- package/src/circuit-relay/server/advert-service.ts +0 -108
- package/src/circuit-relay/server/index.ts +0 -443
- package/src/circuit-relay/server/reservation-store.ts +0 -116
- package/src/circuit-relay/server/reservation-voucher.ts +0 -51
- package/src/circuit-relay/transport/discovery.ts +0 -136
- package/src/circuit-relay/transport/index.ts +0 -396
- package/src/circuit-relay/transport/listener.ts +0 -97
- package/src/circuit-relay/transport/reservation-store.ts +0 -312
- package/src/circuit-relay/utils.ts +0 -136
- package/src/dcutr/dcutr.ts +0 -378
- package/src/dcutr/index.ts +0 -102
- package/src/dcutr/pb/message.proto +0 -12
- package/src/dcutr/pb/message.ts +0 -96
- package/src/dcutr/utils.ts +0 -33
- package/src/fetch/README.md +0 -41
- package/src/fetch/constants.ts +0 -3
- package/src/fetch/index.ts +0 -315
- package/src/fetch/pb/proto.proto +0 -15
- package/src/fetch/pb/proto.ts +0 -153
- package/src/identify/README.md +0 -13
- package/src/identify/consts.ts +0 -12
- package/src/identify/identify.ts +0 -561
- package/src/identify/index.ts +0 -90
- package/src/identify/pb/message.proto +0 -30
- package/src/identify/pb/message.ts +0 -126
- package/src/insecure/index.ts +0 -138
- package/src/insecure/pb/proto.proto +0 -18
- package/src/insecure/pb/proto.ts +0 -161
- package/src/ping/constants.ts +0 -15
- package/src/ping/index.ts +0 -170
- package/src/pnet/README.md +0 -68
- package/src/pnet/crypto.ts +0 -67
- package/src/pnet/errors.ts +0 -5
- package/src/pnet/index.ts +0 -126
- package/src/pnet/key-generator.ts +0 -23
- package/src/upnp-nat/index.ts +0 -212
- package/src/utils/peer-job-queue.ts +0 -119
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
syntax = "proto3";
|
|
2
|
-
|
|
3
|
-
message Message {
|
|
4
|
-
enum MessageType {
|
|
5
|
-
DIAL = 0;
|
|
6
|
-
DIAL_RESPONSE = 1;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
enum ResponseStatus {
|
|
10
|
-
OK = 0;
|
|
11
|
-
E_DIAL_ERROR = 100;
|
|
12
|
-
E_DIAL_REFUSED = 101;
|
|
13
|
-
E_BAD_REQUEST = 200;
|
|
14
|
-
E_INTERNAL_ERROR = 300;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
message PeerInfo {
|
|
18
|
-
optional bytes id = 1;
|
|
19
|
-
repeated bytes addrs = 2;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
message Dial {
|
|
23
|
-
optional PeerInfo peer = 1;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
message DialResponse {
|
|
27
|
-
optional ResponseStatus status = 1;
|
|
28
|
-
optional string statusText = 2;
|
|
29
|
-
optional bytes addr = 3;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
optional MessageType type = 1;
|
|
33
|
-
optional Dial dial = 2;
|
|
34
|
-
optional DialResponse dialResponse = 3;
|
|
35
|
-
}
|
package/src/autonat/pb/index.ts
DELETED
|
@@ -1,320 +0,0 @@
|
|
|
1
|
-
/* eslint-disable import/export */
|
|
2
|
-
/* eslint-disable complexity */
|
|
3
|
-
/* eslint-disable @typescript-eslint/no-namespace */
|
|
4
|
-
/* eslint-disable @typescript-eslint/no-unnecessary-boolean-literal-compare */
|
|
5
|
-
/* eslint-disable @typescript-eslint/no-empty-interface */
|
|
6
|
-
|
|
7
|
-
import { enumeration, encodeMessage, decodeMessage, message } from 'protons-runtime'
|
|
8
|
-
import type { Codec } from 'protons-runtime'
|
|
9
|
-
import type { Uint8ArrayList } from 'uint8arraylist'
|
|
10
|
-
|
|
11
|
-
export interface Message {
|
|
12
|
-
type?: Message.MessageType
|
|
13
|
-
dial?: Message.Dial
|
|
14
|
-
dialResponse?: Message.DialResponse
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export namespace Message {
|
|
18
|
-
export enum MessageType {
|
|
19
|
-
DIAL = 'DIAL',
|
|
20
|
-
DIAL_RESPONSE = 'DIAL_RESPONSE'
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
enum __MessageTypeValues {
|
|
24
|
-
DIAL = 0,
|
|
25
|
-
DIAL_RESPONSE = 1
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export namespace MessageType {
|
|
29
|
-
export const codec = (): Codec<MessageType> => {
|
|
30
|
-
return enumeration<MessageType>(__MessageTypeValues)
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export enum ResponseStatus {
|
|
35
|
-
OK = 'OK',
|
|
36
|
-
E_DIAL_ERROR = 'E_DIAL_ERROR',
|
|
37
|
-
E_DIAL_REFUSED = 'E_DIAL_REFUSED',
|
|
38
|
-
E_BAD_REQUEST = 'E_BAD_REQUEST',
|
|
39
|
-
E_INTERNAL_ERROR = 'E_INTERNAL_ERROR'
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
enum __ResponseStatusValues {
|
|
43
|
-
OK = 0,
|
|
44
|
-
E_DIAL_ERROR = 100,
|
|
45
|
-
E_DIAL_REFUSED = 101,
|
|
46
|
-
E_BAD_REQUEST = 200,
|
|
47
|
-
E_INTERNAL_ERROR = 300
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export namespace ResponseStatus {
|
|
51
|
-
export const codec = (): Codec<ResponseStatus> => {
|
|
52
|
-
return enumeration<ResponseStatus>(__ResponseStatusValues)
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export interface PeerInfo {
|
|
57
|
-
id?: Uint8Array
|
|
58
|
-
addrs: Uint8Array[]
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
export namespace PeerInfo {
|
|
62
|
-
let _codec: Codec<PeerInfo>
|
|
63
|
-
|
|
64
|
-
export const codec = (): Codec<PeerInfo> => {
|
|
65
|
-
if (_codec == null) {
|
|
66
|
-
_codec = message<PeerInfo>((obj, w, opts = {}) => {
|
|
67
|
-
if (opts.lengthDelimited !== false) {
|
|
68
|
-
w.fork()
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
if (obj.id != null) {
|
|
72
|
-
w.uint32(10)
|
|
73
|
-
w.bytes(obj.id)
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
if (obj.addrs != null) {
|
|
77
|
-
for (const value of obj.addrs) {
|
|
78
|
-
w.uint32(18)
|
|
79
|
-
w.bytes(value)
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
if (opts.lengthDelimited !== false) {
|
|
84
|
-
w.ldelim()
|
|
85
|
-
}
|
|
86
|
-
}, (reader, length) => {
|
|
87
|
-
const obj: any = {
|
|
88
|
-
addrs: []
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
const end = length == null ? reader.len : reader.pos + length
|
|
92
|
-
|
|
93
|
-
while (reader.pos < end) {
|
|
94
|
-
const tag = reader.uint32()
|
|
95
|
-
|
|
96
|
-
switch (tag >>> 3) {
|
|
97
|
-
case 1:
|
|
98
|
-
obj.id = reader.bytes()
|
|
99
|
-
break
|
|
100
|
-
case 2:
|
|
101
|
-
obj.addrs.push(reader.bytes())
|
|
102
|
-
break
|
|
103
|
-
default:
|
|
104
|
-
reader.skipType(tag & 7)
|
|
105
|
-
break
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
return obj
|
|
110
|
-
})
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
return _codec
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
export const encode = (obj: Partial<PeerInfo>): Uint8Array => {
|
|
117
|
-
return encodeMessage(obj, PeerInfo.codec())
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
export const decode = (buf: Uint8Array | Uint8ArrayList): PeerInfo => {
|
|
121
|
-
return decodeMessage(buf, PeerInfo.codec())
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
export interface Dial {
|
|
126
|
-
peer?: Message.PeerInfo
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
export namespace Dial {
|
|
130
|
-
let _codec: Codec<Dial>
|
|
131
|
-
|
|
132
|
-
export const codec = (): Codec<Dial> => {
|
|
133
|
-
if (_codec == null) {
|
|
134
|
-
_codec = message<Dial>((obj, w, opts = {}) => {
|
|
135
|
-
if (opts.lengthDelimited !== false) {
|
|
136
|
-
w.fork()
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
if (obj.peer != null) {
|
|
140
|
-
w.uint32(10)
|
|
141
|
-
Message.PeerInfo.codec().encode(obj.peer, w)
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
if (opts.lengthDelimited !== false) {
|
|
145
|
-
w.ldelim()
|
|
146
|
-
}
|
|
147
|
-
}, (reader, length) => {
|
|
148
|
-
const obj: any = {}
|
|
149
|
-
|
|
150
|
-
const end = length == null ? reader.len : reader.pos + length
|
|
151
|
-
|
|
152
|
-
while (reader.pos < end) {
|
|
153
|
-
const tag = reader.uint32()
|
|
154
|
-
|
|
155
|
-
switch (tag >>> 3) {
|
|
156
|
-
case 1:
|
|
157
|
-
obj.peer = Message.PeerInfo.codec().decode(reader, reader.uint32())
|
|
158
|
-
break
|
|
159
|
-
default:
|
|
160
|
-
reader.skipType(tag & 7)
|
|
161
|
-
break
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
return obj
|
|
166
|
-
})
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
return _codec
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
export const encode = (obj: Partial<Dial>): Uint8Array => {
|
|
173
|
-
return encodeMessage(obj, Dial.codec())
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
export const decode = (buf: Uint8Array | Uint8ArrayList): Dial => {
|
|
177
|
-
return decodeMessage(buf, Dial.codec())
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
export interface DialResponse {
|
|
182
|
-
status?: Message.ResponseStatus
|
|
183
|
-
statusText?: string
|
|
184
|
-
addr?: Uint8Array
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
export namespace DialResponse {
|
|
188
|
-
let _codec: Codec<DialResponse>
|
|
189
|
-
|
|
190
|
-
export const codec = (): Codec<DialResponse> => {
|
|
191
|
-
if (_codec == null) {
|
|
192
|
-
_codec = message<DialResponse>((obj, w, opts = {}) => {
|
|
193
|
-
if (opts.lengthDelimited !== false) {
|
|
194
|
-
w.fork()
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
if (obj.status != null) {
|
|
198
|
-
w.uint32(8)
|
|
199
|
-
Message.ResponseStatus.codec().encode(obj.status, w)
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
if (obj.statusText != null) {
|
|
203
|
-
w.uint32(18)
|
|
204
|
-
w.string(obj.statusText)
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
if (obj.addr != null) {
|
|
208
|
-
w.uint32(26)
|
|
209
|
-
w.bytes(obj.addr)
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
if (opts.lengthDelimited !== false) {
|
|
213
|
-
w.ldelim()
|
|
214
|
-
}
|
|
215
|
-
}, (reader, length) => {
|
|
216
|
-
const obj: any = {}
|
|
217
|
-
|
|
218
|
-
const end = length == null ? reader.len : reader.pos + length
|
|
219
|
-
|
|
220
|
-
while (reader.pos < end) {
|
|
221
|
-
const tag = reader.uint32()
|
|
222
|
-
|
|
223
|
-
switch (tag >>> 3) {
|
|
224
|
-
case 1:
|
|
225
|
-
obj.status = Message.ResponseStatus.codec().decode(reader)
|
|
226
|
-
break
|
|
227
|
-
case 2:
|
|
228
|
-
obj.statusText = reader.string()
|
|
229
|
-
break
|
|
230
|
-
case 3:
|
|
231
|
-
obj.addr = reader.bytes()
|
|
232
|
-
break
|
|
233
|
-
default:
|
|
234
|
-
reader.skipType(tag & 7)
|
|
235
|
-
break
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
return obj
|
|
240
|
-
})
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
return _codec
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
export const encode = (obj: Partial<DialResponse>): Uint8Array => {
|
|
247
|
-
return encodeMessage(obj, DialResponse.codec())
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
export const decode = (buf: Uint8Array | Uint8ArrayList): DialResponse => {
|
|
251
|
-
return decodeMessage(buf, DialResponse.codec())
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
let _codec: Codec<Message>
|
|
256
|
-
|
|
257
|
-
export const codec = (): Codec<Message> => {
|
|
258
|
-
if (_codec == null) {
|
|
259
|
-
_codec = message<Message>((obj, w, opts = {}) => {
|
|
260
|
-
if (opts.lengthDelimited !== false) {
|
|
261
|
-
w.fork()
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
if (obj.type != null) {
|
|
265
|
-
w.uint32(8)
|
|
266
|
-
Message.MessageType.codec().encode(obj.type, w)
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
if (obj.dial != null) {
|
|
270
|
-
w.uint32(18)
|
|
271
|
-
Message.Dial.codec().encode(obj.dial, w)
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
if (obj.dialResponse != null) {
|
|
275
|
-
w.uint32(26)
|
|
276
|
-
Message.DialResponse.codec().encode(obj.dialResponse, w)
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
if (opts.lengthDelimited !== false) {
|
|
280
|
-
w.ldelim()
|
|
281
|
-
}
|
|
282
|
-
}, (reader, length) => {
|
|
283
|
-
const obj: any = {}
|
|
284
|
-
|
|
285
|
-
const end = length == null ? reader.len : reader.pos + length
|
|
286
|
-
|
|
287
|
-
while (reader.pos < end) {
|
|
288
|
-
const tag = reader.uint32()
|
|
289
|
-
|
|
290
|
-
switch (tag >>> 3) {
|
|
291
|
-
case 1:
|
|
292
|
-
obj.type = Message.MessageType.codec().decode(reader)
|
|
293
|
-
break
|
|
294
|
-
case 2:
|
|
295
|
-
obj.dial = Message.Dial.codec().decode(reader, reader.uint32())
|
|
296
|
-
break
|
|
297
|
-
case 3:
|
|
298
|
-
obj.dialResponse = Message.DialResponse.codec().decode(reader, reader.uint32())
|
|
299
|
-
break
|
|
300
|
-
default:
|
|
301
|
-
reader.skipType(tag & 7)
|
|
302
|
-
break
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
return obj
|
|
307
|
-
})
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
return _codec
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
export const encode = (obj: Partial<Message>): Uint8Array => {
|
|
314
|
-
return encodeMessage(obj, Message.codec())
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
export const decode = (buf: Uint8Array | Uint8ArrayList): Message => {
|
|
318
|
-
return decodeMessage(buf, Message.codec())
|
|
319
|
-
}
|
|
320
|
-
}
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
const second = 1000
|
|
2
|
-
const minute = 60 * second
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Delay before HOP relay service is advertised on the network
|
|
6
|
-
*/
|
|
7
|
-
export const ADVERTISE_BOOT_DELAY = 15 * minute
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Delay Between HOP relay service advertisements on the network
|
|
11
|
-
*/
|
|
12
|
-
export const ADVERTISE_TTL = 30 * minute
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Multicodec code
|
|
16
|
-
*/
|
|
17
|
-
export const CIRCUIT_PROTO_CODE = 290
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Relay HOP relay service namespace for discovery
|
|
21
|
-
*/
|
|
22
|
-
export const RELAY_RENDEZVOUS_NS = '/libp2p/relay'
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* The maximum number of relay reservations the relay server will accept
|
|
26
|
-
*/
|
|
27
|
-
export const DEFAULT_MAX_RESERVATION_STORE_SIZE = 15
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* How often to check for reservation expiry
|
|
31
|
-
*/
|
|
32
|
-
export const DEFAULT_MAX_RESERVATION_CLEAR_INTERVAL = 300 * second
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* How often to check for reservation expiry
|
|
36
|
-
*/
|
|
37
|
-
export const DEFAULT_MAX_RESERVATION_TTL = 2 * 60 * minute
|
|
38
|
-
|
|
39
|
-
export const DEFAULT_RESERVATION_CONCURRENCY = 1
|
|
40
|
-
|
|
41
|
-
export const RELAY_SOURCE_TAG = 'circuit-relay-source'
|
|
42
|
-
|
|
43
|
-
export const RELAY_TAG = 'circuit-relay-relay'
|
|
44
|
-
|
|
45
|
-
// circuit v2 connection limits
|
|
46
|
-
// https://github.com/libp2p/go-libp2p/blob/master/p2p/protocol/circuitv2/relay/resources.go#L61-L66
|
|
47
|
-
|
|
48
|
-
// 2 min is the default connection duration
|
|
49
|
-
export const DEFAULT_DURATION_LIMIT = 2 * minute
|
|
50
|
-
|
|
51
|
-
// 128k is the default data limit
|
|
52
|
-
export const DEFAULT_DATA_LIMIT = BigInt(1 << 17)
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* The hop protocol
|
|
56
|
-
*/
|
|
57
|
-
export const RELAY_V2_HOP_CODEC = '/libp2p/circuit/relay/0.2.0/hop'
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* the stop protocol
|
|
61
|
-
*/
|
|
62
|
-
export const RELAY_V2_STOP_CODEC = '/libp2p/circuit/relay/0.2.0/stop'
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Hop messages must be exchanged inside this timeout
|
|
66
|
-
*/
|
|
67
|
-
export const DEFAULT_HOP_TIMEOUT = 30 * second
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* How long to wait before starting to advertise the relay service
|
|
71
|
-
*/
|
|
72
|
-
export const DEFAULT_ADVERT_BOOT_DELAY = 30 * second
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @packageDocumentation
|
|
3
|
-
*
|
|
4
|
-
* The `circuitRelayTransport` allows libp2p to dial and listen on [Circuit Relay](https://docs.libp2p.io/concepts/nat/circuit-relay/)
|
|
5
|
-
* addresses.
|
|
6
|
-
*
|
|
7
|
-
* @example
|
|
8
|
-
*
|
|
9
|
-
* ```typescript
|
|
10
|
-
* import { createLibp2p } from 'libp2p'
|
|
11
|
-
* import { circuitRelayTransport } from 'libp2p/circuit-relay'
|
|
12
|
-
*
|
|
13
|
-
* const node = await createLibp2p({
|
|
14
|
-
* transports: [
|
|
15
|
-
* circuitRelayTransport()
|
|
16
|
-
* ]
|
|
17
|
-
* })
|
|
18
|
-
* ```
|
|
19
|
-
*
|
|
20
|
-
* The `circuitRelayServer` function allows libp2p to function as a [Circuit Relay](https://docs.libp2p.io/concepts/nat/circuit-relay/)
|
|
21
|
-
* server. This will not work in browsers.
|
|
22
|
-
*
|
|
23
|
-
* @example
|
|
24
|
-
*
|
|
25
|
-
* ```typescript
|
|
26
|
-
* import { createLibp2p } from 'libp2p'
|
|
27
|
-
* import { circuitRelayServer } from 'libp2p/circuit-relay'
|
|
28
|
-
*
|
|
29
|
-
* const node = await createLibp2p({
|
|
30
|
-
* services: [
|
|
31
|
-
* circuitRelay: circuitRelayServer()
|
|
32
|
-
* ]
|
|
33
|
-
* })
|
|
34
|
-
* ```
|
|
35
|
-
*/
|
|
36
|
-
|
|
37
|
-
import type { Limit } from './pb/index.js'
|
|
38
|
-
import type { TypedEventEmitter } from '@libp2p/interface/events'
|
|
39
|
-
import type { PeerMap } from '@libp2p/peer-collections'
|
|
40
|
-
import type { Multiaddr } from '@multiformats/multiaddr'
|
|
41
|
-
|
|
42
|
-
export interface RelayReservation {
|
|
43
|
-
expire: Date
|
|
44
|
-
addr: Multiaddr
|
|
45
|
-
limit?: Limit
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
export interface CircuitRelayServiceEvents {
|
|
49
|
-
'relay:reservation': CustomEvent<RelayReservation>
|
|
50
|
-
'relay:advert:success': CustomEvent<unknown>
|
|
51
|
-
'relay:advert:error': CustomEvent<Error>
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
export interface CircuitRelayService extends TypedEventEmitter<CircuitRelayServiceEvents> {
|
|
55
|
-
reservations: PeerMap<RelayReservation>
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
export { circuitRelayServer } from './server/index.js'
|
|
59
|
-
export { circuitRelayTransport } from './transport/index.js'
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
syntax = "proto3";
|
|
2
|
-
|
|
3
|
-
message HopMessage {
|
|
4
|
-
enum Type {
|
|
5
|
-
RESERVE = 0;
|
|
6
|
-
CONNECT = 1;
|
|
7
|
-
STATUS = 2;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
// the presence of this field is enforced at application level
|
|
11
|
-
optional Type type = 1;
|
|
12
|
-
|
|
13
|
-
optional Peer peer = 2;
|
|
14
|
-
optional Reservation reservation = 3;
|
|
15
|
-
optional Limit limit = 4;
|
|
16
|
-
|
|
17
|
-
optional Status status = 5;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
message StopMessage {
|
|
21
|
-
enum Type {
|
|
22
|
-
CONNECT = 0;
|
|
23
|
-
STATUS = 1;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
// the presence of this field is enforced at application level
|
|
27
|
-
optional Type type = 1;
|
|
28
|
-
|
|
29
|
-
optional Peer peer = 2;
|
|
30
|
-
optional Limit limit = 3;
|
|
31
|
-
|
|
32
|
-
optional Status status = 4;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
message Peer {
|
|
36
|
-
bytes id = 1;
|
|
37
|
-
repeated bytes addrs = 2;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
message Reservation {
|
|
41
|
-
uint64 expire = 1; // Unix expiration time (UTC)
|
|
42
|
-
repeated bytes addrs = 2; // relay addrs for reserving peer
|
|
43
|
-
optional bytes voucher = 3; // reservation voucher
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
message Limit {
|
|
47
|
-
optional uint32 duration = 1; // seconds
|
|
48
|
-
optional uint64 data = 2; // bytes
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
enum Status {
|
|
52
|
-
UNUSED = 0;
|
|
53
|
-
OK = 100;
|
|
54
|
-
RESERVATION_REFUSED = 200;
|
|
55
|
-
RESOURCE_LIMIT_EXCEEDED = 201;
|
|
56
|
-
PERMISSION_DENIED = 202;
|
|
57
|
-
CONNECTION_FAILED = 203;
|
|
58
|
-
NO_RESERVATION = 204;
|
|
59
|
-
MALFORMED_MESSAGE = 400;
|
|
60
|
-
UNEXPECTED_MESSAGE = 401;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
message ReservationVoucher {
|
|
64
|
-
bytes relay = 1;
|
|
65
|
-
bytes peer = 2;
|
|
66
|
-
uint64 expiration = 3;
|
|
67
|
-
}
|