libp2p 0.36.2-8cca8e4 → 0.36.2-fab4f13
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/src/circuit/circuit/hop.d.ts +3 -3
- package/dist/src/circuit/circuit/hop.d.ts.map +1 -1
- package/dist/src/circuit/circuit/hop.js +1 -1
- package/dist/src/circuit/circuit/hop.js.map +1 -1
- package/dist/src/circuit/circuit/stop.d.ts +3 -3
- package/dist/src/circuit/circuit/stop.d.ts.map +1 -1
- package/dist/src/circuit/circuit/stop.js.map +1 -1
- package/dist/src/circuit/circuit/stream-handler.d.ts +4 -4
- package/dist/src/circuit/circuit/stream-handler.d.ts.map +1 -1
- package/dist/src/circuit/circuit/stream-handler.js +2 -3
- package/dist/src/circuit/circuit/stream-handler.js.map +1 -1
- package/dist/src/circuit/circuit/utils.d.ts +2 -2
- package/dist/src/circuit/circuit/utils.d.ts.map +1 -1
- package/dist/src/circuit/circuit/utils.js.map +1 -1
- package/dist/src/circuit/pb/index.d.ts +42 -164
- package/dist/src/circuit/pb/index.d.ts.map +1 -0
- package/dist/src/circuit/pb/index.js +67 -523
- package/dist/src/circuit/pb/index.js.map +1 -0
- package/dist/src/config.js +2 -2
- package/dist/src/config.js.map +1 -1
- package/dist/src/dht/dummy-dht.d.ts +17 -0
- package/dist/src/dht/dummy-dht.d.ts.map +1 -0
- package/dist/src/dht/dummy-dht.js +39 -0
- package/dist/src/dht/dummy-dht.js.map +1 -0
- package/dist/src/dialer/index.d.ts.map +1 -1
- package/dist/src/dialer/index.js +0 -1
- package/dist/src/dialer/index.js.map +1 -1
- package/dist/src/errors.d.ts +2 -0
- package/dist/src/errors.d.ts.map +1 -1
- package/dist/src/errors.js +2 -0
- package/dist/src/errors.js.map +1 -1
- package/dist/src/fetch/index.d.ts.map +1 -1
- package/dist/src/fetch/index.js +5 -6
- package/dist/src/fetch/index.js.map +1 -1
- package/dist/src/fetch/pb/proto.d.ts +20 -128
- package/dist/src/fetch/pb/proto.d.ts.map +1 -0
- package/dist/src/fetch/pb/proto.js +44 -331
- package/dist/src/fetch/pb/proto.js.map +1 -0
- package/dist/src/identify/index.d.ts +4 -2
- package/dist/src/identify/index.d.ts.map +1 -1
- package/dist/src/identify/index.js +8 -8
- package/dist/src/identify/index.js.map +1 -1
- package/dist/src/identify/pb/message.d.ts +13 -108
- package/dist/src/identify/pb/message.d.ts.map +1 -0
- package/dist/src/identify/pb/message.js +21 -366
- package/dist/src/identify/pb/message.js.map +1 -0
- package/dist/src/index.d.ts +13 -6
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/insecure/index.d.ts.map +1 -1
- package/dist/src/insecure/index.js +5 -2
- package/dist/src/insecure/index.js.map +1 -1
- package/dist/src/insecure/pb/proto.d.ts +24 -130
- package/dist/src/insecure/pb/proto.d.ts.map +1 -0
- package/dist/src/insecure/pb/proto.js +46 -388
- package/dist/src/insecure/pb/proto.js.map +1 -0
- package/dist/src/keychain/index.d.ts +3 -3
- package/dist/src/keychain/index.js +2 -2
- package/dist/src/keychain/util.d.ts +1 -1
- package/dist/src/keychain/util.d.ts.map +1 -1
- package/dist/src/libp2p.d.ts +7 -4
- package/dist/src/libp2p.d.ts.map +1 -1
- package/dist/src/libp2p.js +20 -5
- package/dist/src/libp2p.js.map +1 -1
- package/dist/src/metrics/stats.d.ts +1 -5
- package/dist/src/metrics/stats.d.ts.map +1 -1
- package/dist/src/metrics/stats.js.map +1 -1
- 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/transport-manager.d.ts +2 -2
- package/dist/src/transport-manager.d.ts.map +1 -1
- package/dist/src/transport-manager.js +8 -8
- package/dist/src/transport-manager.js.map +1 -1
- package/package.json +48 -44
- package/src/circuit/circuit/hop.ts +4 -4
- package/src/circuit/circuit/stop.ts +3 -3
- package/src/circuit/circuit/stream-handler.ts +5 -6
- package/src/circuit/circuit/utils.ts +2 -2
- package/src/circuit/pb/index.proto +1 -1
- package/src/circuit/pb/index.ts +88 -0
- package/src/config.ts +2 -2
- package/src/dht/dummy-dht.ts +51 -0
- package/src/dialer/index.ts +0 -3
- package/src/errors.ts +2 -0
- package/src/fetch/index.ts +6 -7
- package/src/fetch/pb/proto.ts +58 -0
- package/src/identify/index.ts +10 -10
- package/src/identify/pb/message.ts +36 -0
- package/src/index.ts +14 -7
- package/src/insecure/index.ts +8 -4
- package/src/insecure/pb/proto.ts +61 -0
- package/src/keychain/index.ts +2 -2
- package/src/libp2p.ts +27 -9
- package/src/metrics/stats.ts +1 -6
- package/src/pubsub/dummy-pubsub.ts +51 -0
- package/src/transport-manager.ts +6 -6
- package/src/circuit/pb/index.d.ts +0 -173
- package/src/circuit/pb/index.js +0 -528
- package/src/fetch/pb/proto.d.ts +0 -134
- package/src/fetch/pb/proto.js +0 -331
- package/src/identify/pb/message.d.ts +0 -110
- package/src/identify/pb/message.js +0 -369
- package/src/insecure/pb/proto.d.ts +0 -134
- package/src/insecure/pb/proto.js +0 -388
package/src/keychain/index.ts
CHANGED
|
@@ -171,7 +171,7 @@ export class KeyChain {
|
|
|
171
171
|
/**
|
|
172
172
|
* Generates the options for a keychain. A random salt is produced.
|
|
173
173
|
*
|
|
174
|
-
* @returns {
|
|
174
|
+
* @returns {object}
|
|
175
175
|
*/
|
|
176
176
|
static generateOptions (): KeyChainInit {
|
|
177
177
|
const options = Object.assign({}, defaultOptions)
|
|
@@ -184,7 +184,7 @@ export class KeyChain {
|
|
|
184
184
|
* Gets an object that can encrypt/decrypt protected data.
|
|
185
185
|
* The default options for a keychain.
|
|
186
186
|
*
|
|
187
|
-
* @returns {
|
|
187
|
+
* @returns {object}
|
|
188
188
|
*/
|
|
189
189
|
static get options () {
|
|
190
190
|
return defaultOptions
|
package/src/libp2p.ts
CHANGED
|
@@ -32,7 +32,7 @@ import type { Connection } from '@libp2p/interfaces/connection'
|
|
|
32
32
|
import type { PeerRouting } from '@libp2p/interfaces/peer-routing'
|
|
33
33
|
import type { ContentRouting } from '@libp2p/interfaces/content-routing'
|
|
34
34
|
import type { PubSub } from '@libp2p/interfaces/pubsub'
|
|
35
|
-
import type { ConnectionManager, StreamHandler } from '@libp2p/interfaces/registrar'
|
|
35
|
+
import type { ConnectionManager, Registrar, StreamHandler } from '@libp2p/interfaces/registrar'
|
|
36
36
|
import type { PeerInfo } from '@libp2p/interfaces/peer-info'
|
|
37
37
|
import type { Libp2p, Libp2pEvents, Libp2pInit, Libp2pOptions } from './index.js'
|
|
38
38
|
import { validateConfig } from './config.js'
|
|
@@ -43,13 +43,16 @@ import { concat as uint8ArrayConcat } from 'uint8arrays/concat'
|
|
|
43
43
|
import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string'
|
|
44
44
|
import errCode from 'err-code'
|
|
45
45
|
import { unmarshalPublicKey } from '@libp2p/crypto/keys'
|
|
46
|
+
import type { Metrics } from '@libp2p/interfaces/metrics'
|
|
47
|
+
import { DummyDHT } from './dht/dummy-dht.js'
|
|
48
|
+
import { DummyPubSub } from './pubsub/dummy-pubsub.js'
|
|
46
49
|
|
|
47
50
|
const log = logger('libp2p')
|
|
48
51
|
|
|
49
52
|
export class Libp2pNode extends EventEmitter<Libp2pEvents> implements Libp2p {
|
|
50
53
|
public peerId: PeerId
|
|
51
|
-
public dht
|
|
52
|
-
public pubsub
|
|
54
|
+
public dht: DualDHT
|
|
55
|
+
public pubsub: PubSub
|
|
53
56
|
public identifyService?: IdentifyService
|
|
54
57
|
public fetchService: FetchService
|
|
55
58
|
public pingService: PingService
|
|
@@ -59,6 +62,8 @@ export class Libp2pNode extends EventEmitter<Libp2pEvents> implements Libp2p {
|
|
|
59
62
|
public peerRouting: PeerRouting
|
|
60
63
|
public keychain: KeyChain
|
|
61
64
|
public connectionManager: ConnectionManager
|
|
65
|
+
public registrar: Registrar
|
|
66
|
+
public metrics?: Metrics
|
|
62
67
|
|
|
63
68
|
private started: boolean
|
|
64
69
|
private readonly services: Startable[]
|
|
@@ -78,7 +83,7 @@ export class Libp2pNode extends EventEmitter<Libp2pEvents> implements Libp2p {
|
|
|
78
83
|
|
|
79
84
|
// Create Metrics
|
|
80
85
|
if (init.metrics.enabled) {
|
|
81
|
-
this.components.setMetrics(this.configureComponent(new DefaultMetrics(init.metrics)))
|
|
86
|
+
this.metrics = this.components.setMetrics(this.configureComponent(new DefaultMetrics(init.metrics)))
|
|
82
87
|
}
|
|
83
88
|
|
|
84
89
|
this.components.setConnectionGater(this.configureComponent({
|
|
@@ -117,7 +122,7 @@ export class Libp2pNode extends EventEmitter<Libp2pEvents> implements Libp2p {
|
|
|
117
122
|
this.connectionManager = this.components.setConnectionManager(this.configureComponent(new DefaultConnectionManager(this.components, init.connectionManager)))
|
|
118
123
|
|
|
119
124
|
// Create the Registrar
|
|
120
|
-
this.components.setRegistrar(this.configureComponent(new DefaultRegistrar(this.components)))
|
|
125
|
+
this.registrar = this.components.setRegistrar(this.configureComponent(new DefaultRegistrar(this.components)))
|
|
121
126
|
|
|
122
127
|
// Setup the transport manager
|
|
123
128
|
this.components.setTransportManager(this.configureComponent(new DefaultTransportManager(this.components, init.transportManager)))
|
|
@@ -165,11 +170,15 @@ export class Libp2pNode extends EventEmitter<Libp2pEvents> implements Libp2p {
|
|
|
165
170
|
// dht provided components (peerRouting, contentRouting, dht)
|
|
166
171
|
if (init.dht != null) {
|
|
167
172
|
this.dht = this.components.setDHT(this.configureComponent(init.dht))
|
|
173
|
+
} else {
|
|
174
|
+
this.dht = new DummyDHT()
|
|
168
175
|
}
|
|
169
176
|
|
|
170
177
|
// Create pubsub if provided
|
|
171
178
|
if (init.pubsub != null) {
|
|
172
179
|
this.pubsub = this.components.setPubSub(this.configureComponent(init.pubsub))
|
|
180
|
+
} else {
|
|
181
|
+
this.pubsub = new DummyPubSub()
|
|
173
182
|
}
|
|
174
183
|
|
|
175
184
|
// Attach remaining APIs
|
|
@@ -177,9 +186,14 @@ export class Libp2pNode extends EventEmitter<Libp2pEvents> implements Libp2p {
|
|
|
177
186
|
|
|
178
187
|
const peerRouters: PeerRouting[] = (init.peerRouters ?? []).map(component => this.configureComponent(component))
|
|
179
188
|
|
|
180
|
-
if (
|
|
189
|
+
if (init.dht != null) {
|
|
181
190
|
// add dht to routers
|
|
182
191
|
peerRouters.push(this.configureComponent(new DHTPeerRouting(this.dht)))
|
|
192
|
+
|
|
193
|
+
// use dht for peer discovery
|
|
194
|
+
this.dht.addEventListener('peer', (evt) => {
|
|
195
|
+
this.onDiscoveryPeer(evt)
|
|
196
|
+
})
|
|
183
197
|
}
|
|
184
198
|
|
|
185
199
|
this.peerRouting = this.components.setPeerRouting(this.configureComponent(new DefaultPeerRouting(this.components, {
|
|
@@ -189,7 +203,7 @@ export class Libp2pNode extends EventEmitter<Libp2pEvents> implements Libp2p {
|
|
|
189
203
|
|
|
190
204
|
const contentRouters: ContentRouting[] = (init.contentRouters ?? []).map(component => this.configureComponent(component))
|
|
191
205
|
|
|
192
|
-
if (
|
|
206
|
+
if (init.dht != null) {
|
|
193
207
|
// add dht to routers
|
|
194
208
|
contentRouters.push(this.configureComponent(new DHTContentRouting(this.dht)))
|
|
195
209
|
}
|
|
@@ -404,9 +418,13 @@ export class Libp2pNode extends EventEmitter<Libp2pEvents> implements Libp2p {
|
|
|
404
418
|
/**
|
|
405
419
|
* Get the public key for the given peer id
|
|
406
420
|
*/
|
|
407
|
-
async getPublicKey (peer: PeerId, options: AbortOptions = {}) {
|
|
421
|
+
async getPublicKey (peer: PeerId, options: AbortOptions = {}): Promise<Uint8Array> {
|
|
408
422
|
log('getPublicKey %p', peer)
|
|
409
423
|
|
|
424
|
+
if (peer.publicKey != null) {
|
|
425
|
+
return peer.publicKey
|
|
426
|
+
}
|
|
427
|
+
|
|
410
428
|
const peerInfo = await this.peerStore.get(peer)
|
|
411
429
|
|
|
412
430
|
if (peerInfo.pubKey != null) {
|
|
@@ -429,7 +447,7 @@ export class Libp2pNode extends EventEmitter<Libp2pEvents> implements Libp2p {
|
|
|
429
447
|
|
|
430
448
|
await this.peerStore.keyBook.set(peer, event.value)
|
|
431
449
|
|
|
432
|
-
return key
|
|
450
|
+
return key.bytes
|
|
433
451
|
}
|
|
434
452
|
}
|
|
435
453
|
|
package/src/metrics/stats.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { CustomEvent, EventEmitter } from '@libp2p/interfaces'
|
|
|
2
2
|
import { createMovingAverage } from './moving-average.js'
|
|
3
3
|
// @ts-expect-error no types
|
|
4
4
|
import retimer from 'retimer'
|
|
5
|
-
import type { MovingAverages, Stats } from '@libp2p/interfaces/metrics'
|
|
5
|
+
import type { MovingAverages, Stats, TransferStats } from '@libp2p/interfaces/metrics'
|
|
6
6
|
|
|
7
7
|
export interface StatsEvents {
|
|
8
8
|
'update': CustomEvent<TransferStats>
|
|
@@ -16,11 +16,6 @@ export interface StatsInit {
|
|
|
16
16
|
computeThrottleTimeout: number
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
export interface TransferStats {
|
|
20
|
-
dataReceived: BigInt
|
|
21
|
-
dataSent: BigInt
|
|
22
|
-
}
|
|
23
|
-
|
|
24
19
|
export class DefaultStats extends EventEmitter<StatsEvents> implements Stats {
|
|
25
20
|
private readonly enabled: boolean
|
|
26
21
|
public queue: Array<[string, number, number]>
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { EventEmitter } from '@libp2p/interfaces'
|
|
2
|
+
import type { PeerId } from '@libp2p/interfaces/peer-id'
|
|
3
|
+
import type { PublishResult, PubSub, PubSubEvents, StrictNoSign, StrictSign } from '@libp2p/interfaces/pubsub'
|
|
4
|
+
import errCode from 'err-code'
|
|
5
|
+
import { messages, codes } from '../errors.js'
|
|
6
|
+
|
|
7
|
+
export class DummyPubSub extends EventEmitter<PubSubEvents> implements PubSub {
|
|
8
|
+
isStarted (): boolean {
|
|
9
|
+
return false
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
start (): void | Promise<void> {
|
|
13
|
+
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
stop (): void | Promise<void> {
|
|
17
|
+
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
get globalSignaturePolicy (): typeof StrictSign | typeof StrictNoSign {
|
|
21
|
+
throw errCode(new Error(messages.PUBSUB_DISABLED), codes.ERR_PUBSUB_DISABLED)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
get multicodecs (): string[] {
|
|
25
|
+
throw errCode(new Error(messages.PUBSUB_DISABLED), codes.ERR_PUBSUB_DISABLED)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
getPeers (): PeerId[] {
|
|
29
|
+
throw errCode(new Error(messages.PUBSUB_DISABLED), codes.ERR_PUBSUB_DISABLED)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
getTopics (): string[] {
|
|
33
|
+
throw errCode(new Error(messages.PUBSUB_DISABLED), codes.ERR_PUBSUB_DISABLED)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
subscribe (): void {
|
|
37
|
+
throw errCode(new Error(messages.PUBSUB_DISABLED), codes.ERR_PUBSUB_DISABLED)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
unsubscribe (): void {
|
|
41
|
+
throw errCode(new Error(messages.PUBSUB_DISABLED), codes.ERR_PUBSUB_DISABLED)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
getSubscribers (): PeerId[] {
|
|
45
|
+
throw errCode(new Error(messages.PUBSUB_DISABLED), codes.ERR_PUBSUB_DISABLED)
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
async publish (): Promise<PublishResult> {
|
|
49
|
+
throw errCode(new Error(messages.PUBSUB_DISABLED), codes.ERR_PUBSUB_DISABLED)
|
|
50
|
+
}
|
|
51
|
+
}
|
package/src/transport-manager.ts
CHANGED
|
@@ -12,14 +12,14 @@ import { trackedMap } from '@libp2p/tracked-map'
|
|
|
12
12
|
const log = logger('libp2p:transports')
|
|
13
13
|
|
|
14
14
|
export interface TransportManagerInit {
|
|
15
|
-
faultTolerance?:
|
|
15
|
+
faultTolerance?: FaultTolerance
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
export class DefaultTransportManager extends EventEmitter<TransportManagerEvents> implements TransportManager, Startable {
|
|
19
19
|
private readonly components: Components
|
|
20
20
|
private readonly transports: Map<string, Transport>
|
|
21
21
|
private readonly listeners: Map<string, Listener[]>
|
|
22
|
-
private readonly faultTolerance:
|
|
22
|
+
private readonly faultTolerance: FaultTolerance
|
|
23
23
|
private started: boolean
|
|
24
24
|
|
|
25
25
|
constructor (components: Components, init: TransportManagerInit = {}) {
|
|
@@ -33,7 +33,7 @@ export class DefaultTransportManager extends EventEmitter<TransportManagerEvents
|
|
|
33
33
|
metric: 'listeners',
|
|
34
34
|
metrics: this.components.getMetrics()
|
|
35
35
|
})
|
|
36
|
-
this.faultTolerance = init.faultTolerance ??
|
|
36
|
+
this.faultTolerance = init.faultTolerance ?? FaultTolerance.FATAL_ALL
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
/**
|
|
@@ -215,7 +215,7 @@ export class DefaultTransportManager extends EventEmitter<TransportManagerEvents
|
|
|
215
215
|
// listening on remote addresses as they may be offline. We could then potentially
|
|
216
216
|
// just wait for any (`p-any`) listener to succeed on each transport before returning
|
|
217
217
|
const isListening = results.find(r => r.isFulfilled)
|
|
218
|
-
if ((isListening == null) && this.faultTolerance !==
|
|
218
|
+
if ((isListening == null) && this.faultTolerance !== FaultTolerance.NO_FATAL) {
|
|
219
219
|
throw errCode(new Error(`Transport (${key}) could not listen on any available address`), codes.ERR_NO_VALID_ADDRESSES)
|
|
220
220
|
}
|
|
221
221
|
}
|
|
@@ -224,7 +224,7 @@ export class DefaultTransportManager extends EventEmitter<TransportManagerEvents
|
|
|
224
224
|
// means we were given addresses we do not have transports for
|
|
225
225
|
if (couldNotListen.length === this.transports.size) {
|
|
226
226
|
const message = `no valid addresses were provided for transports [${couldNotListen.join(', ')}]`
|
|
227
|
-
if (this.faultTolerance ===
|
|
227
|
+
if (this.faultTolerance === FaultTolerance.FATAL_ALL) {
|
|
228
228
|
throw errCode(new Error(message), codes.ERR_NO_VALID_ADDRESSES)
|
|
229
229
|
}
|
|
230
230
|
log(`libp2p in dial mode only: ${message}`)
|
|
@@ -266,7 +266,7 @@ export class DefaultTransportManager extends EventEmitter<TransportManagerEvents
|
|
|
266
266
|
/**
|
|
267
267
|
* Enum Transport Manager Fault Tolerance values
|
|
268
268
|
*/
|
|
269
|
-
export enum
|
|
269
|
+
export enum FaultTolerance {
|
|
270
270
|
/**
|
|
271
271
|
* should be used for failing in any listen circumstance
|
|
272
272
|
*/
|
|
@@ -1,173 +0,0 @@
|
|
|
1
|
-
import * as $protobuf from "protobufjs";
|
|
2
|
-
/** Properties of a CircuitRelay. */
|
|
3
|
-
export interface ICircuitRelay {
|
|
4
|
-
|
|
5
|
-
/** CircuitRelay type */
|
|
6
|
-
type?: (CircuitRelay.Type|null);
|
|
7
|
-
|
|
8
|
-
/** CircuitRelay srcPeer */
|
|
9
|
-
srcPeer?: (CircuitRelay.IPeer|null);
|
|
10
|
-
|
|
11
|
-
/** CircuitRelay dstPeer */
|
|
12
|
-
dstPeer?: (CircuitRelay.IPeer|null);
|
|
13
|
-
|
|
14
|
-
/** CircuitRelay code */
|
|
15
|
-
code?: (CircuitRelay.Status|null);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
/** Represents a CircuitRelay. */
|
|
19
|
-
export class CircuitRelay implements ICircuitRelay {
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Constructs a new CircuitRelay.
|
|
23
|
-
* @param [p] Properties to set
|
|
24
|
-
*/
|
|
25
|
-
constructor(p?: ICircuitRelay);
|
|
26
|
-
|
|
27
|
-
/** CircuitRelay type. */
|
|
28
|
-
public type: CircuitRelay.Type;
|
|
29
|
-
|
|
30
|
-
/** CircuitRelay srcPeer. */
|
|
31
|
-
public srcPeer?: (CircuitRelay.IPeer|null);
|
|
32
|
-
|
|
33
|
-
/** CircuitRelay dstPeer. */
|
|
34
|
-
public dstPeer?: (CircuitRelay.IPeer|null);
|
|
35
|
-
|
|
36
|
-
/** CircuitRelay code. */
|
|
37
|
-
public code: CircuitRelay.Status;
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Encodes the specified CircuitRelay message. Does not implicitly {@link CircuitRelay.verify|verify} messages.
|
|
41
|
-
* @param m CircuitRelay message or plain object to encode
|
|
42
|
-
* @param [w] Writer to encode to
|
|
43
|
-
* @returns Writer
|
|
44
|
-
*/
|
|
45
|
-
public static encode(m: ICircuitRelay, w?: $protobuf.Writer): $protobuf.Writer;
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Decodes a CircuitRelay message from the specified reader or buffer.
|
|
49
|
-
* @param r Reader or buffer to decode from
|
|
50
|
-
* @param [l] Message length if known beforehand
|
|
51
|
-
* @returns CircuitRelay
|
|
52
|
-
* @throws {Error} If the payload is not a reader or valid buffer
|
|
53
|
-
* @throws {$protobuf.util.ProtocolError} If required fields are missing
|
|
54
|
-
*/
|
|
55
|
-
public static decode(r: ($protobuf.Reader|Uint8Array), l?: number): CircuitRelay;
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Creates a CircuitRelay message from a plain object. Also converts values to their respective internal types.
|
|
59
|
-
* @param d Plain object
|
|
60
|
-
* @returns CircuitRelay
|
|
61
|
-
*/
|
|
62
|
-
public static fromObject(d: { [k: string]: any }): CircuitRelay;
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Creates a plain object from a CircuitRelay message. Also converts values to other types if specified.
|
|
66
|
-
* @param m CircuitRelay
|
|
67
|
-
* @param [o] Conversion options
|
|
68
|
-
* @returns Plain object
|
|
69
|
-
*/
|
|
70
|
-
public static toObject(m: CircuitRelay, o?: $protobuf.IConversionOptions): { [k: string]: any };
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* Converts this CircuitRelay to JSON.
|
|
74
|
-
* @returns JSON object
|
|
75
|
-
*/
|
|
76
|
-
public toJSON(): { [k: string]: any };
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
export namespace CircuitRelay {
|
|
80
|
-
|
|
81
|
-
/** Status enum. */
|
|
82
|
-
enum Status {
|
|
83
|
-
SUCCESS = 100,
|
|
84
|
-
HOP_SRC_ADDR_TOO_LONG = 220,
|
|
85
|
-
HOP_DST_ADDR_TOO_LONG = 221,
|
|
86
|
-
HOP_SRC_MULTIADDR_INVALID = 250,
|
|
87
|
-
HOP_DST_MULTIADDR_INVALID = 251,
|
|
88
|
-
HOP_NO_CONN_TO_DST = 260,
|
|
89
|
-
HOP_CANT_DIAL_DST = 261,
|
|
90
|
-
HOP_CANT_OPEN_DST_STREAM = 262,
|
|
91
|
-
HOP_CANT_SPEAK_RELAY = 270,
|
|
92
|
-
HOP_CANT_RELAY_TO_SELF = 280,
|
|
93
|
-
STOP_SRC_ADDR_TOO_LONG = 320,
|
|
94
|
-
STOP_DST_ADDR_TOO_LONG = 321,
|
|
95
|
-
STOP_SRC_MULTIADDR_INVALID = 350,
|
|
96
|
-
STOP_DST_MULTIADDR_INVALID = 351,
|
|
97
|
-
STOP_RELAY_REFUSED = 390,
|
|
98
|
-
MALFORMED_MESSAGE = 400
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
/** Type enum. */
|
|
102
|
-
enum Type {
|
|
103
|
-
HOP = 1,
|
|
104
|
-
STOP = 2,
|
|
105
|
-
STATUS = 3,
|
|
106
|
-
CAN_HOP = 4
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
/** Properties of a Peer. */
|
|
110
|
-
interface IPeer {
|
|
111
|
-
|
|
112
|
-
/** Peer id */
|
|
113
|
-
id: Uint8Array;
|
|
114
|
-
|
|
115
|
-
/** Peer addrs */
|
|
116
|
-
addrs?: (Uint8Array[]|null);
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
/** Represents a Peer. */
|
|
120
|
-
class Peer implements IPeer {
|
|
121
|
-
|
|
122
|
-
/**
|
|
123
|
-
* Constructs a new Peer.
|
|
124
|
-
* @param [p] Properties to set
|
|
125
|
-
*/
|
|
126
|
-
constructor(p?: CircuitRelay.IPeer);
|
|
127
|
-
|
|
128
|
-
/** Peer id. */
|
|
129
|
-
public id: Uint8Array;
|
|
130
|
-
|
|
131
|
-
/** Peer addrs. */
|
|
132
|
-
public addrs: Uint8Array[];
|
|
133
|
-
|
|
134
|
-
/**
|
|
135
|
-
* Encodes the specified Peer message. Does not implicitly {@link CircuitRelay.Peer.verify|verify} messages.
|
|
136
|
-
* @param m Peer message or plain object to encode
|
|
137
|
-
* @param [w] Writer to encode to
|
|
138
|
-
* @returns Writer
|
|
139
|
-
*/
|
|
140
|
-
public static encode(m: CircuitRelay.IPeer, w?: $protobuf.Writer): $protobuf.Writer;
|
|
141
|
-
|
|
142
|
-
/**
|
|
143
|
-
* Decodes a Peer message from the specified reader or buffer.
|
|
144
|
-
* @param r Reader or buffer to decode from
|
|
145
|
-
* @param [l] Message length if known beforehand
|
|
146
|
-
* @returns Peer
|
|
147
|
-
* @throws {Error} If the payload is not a reader or valid buffer
|
|
148
|
-
* @throws {$protobuf.util.ProtocolError} If required fields are missing
|
|
149
|
-
*/
|
|
150
|
-
public static decode(r: ($protobuf.Reader|Uint8Array), l?: number): CircuitRelay.Peer;
|
|
151
|
-
|
|
152
|
-
/**
|
|
153
|
-
* Creates a Peer message from a plain object. Also converts values to their respective internal types.
|
|
154
|
-
* @param d Plain object
|
|
155
|
-
* @returns Peer
|
|
156
|
-
*/
|
|
157
|
-
public static fromObject(d: { [k: string]: any }): CircuitRelay.Peer;
|
|
158
|
-
|
|
159
|
-
/**
|
|
160
|
-
* Creates a plain object from a Peer message. Also converts values to other types if specified.
|
|
161
|
-
* @param m Peer
|
|
162
|
-
* @param [o] Conversion options
|
|
163
|
-
* @returns Plain object
|
|
164
|
-
*/
|
|
165
|
-
public static toObject(m: CircuitRelay.Peer, o?: $protobuf.IConversionOptions): { [k: string]: any };
|
|
166
|
-
|
|
167
|
-
/**
|
|
168
|
-
* Converts this Peer to JSON.
|
|
169
|
-
* @returns JSON object
|
|
170
|
-
*/
|
|
171
|
-
public toJSON(): { [k: string]: any };
|
|
172
|
-
}
|
|
173
|
-
}
|