@libp2p/circuit-relay-v2 0.0.0-05b52d69c → 0.0.0-0b4a2ee79
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 +1 -1
- package/dist/index.min.js +9 -9
- package/dist/src/transport/index.d.ts.map +1 -1
- package/dist/src/transport/index.js +4 -273
- package/dist/src/transport/index.js.map +1 -1
- package/dist/src/transport/listener.d.ts.map +1 -1
- package/dist/src/transport/listener.js +1 -0
- package/dist/src/transport/listener.js.map +1 -1
- package/dist/src/transport/reservation-store.d.ts.map +1 -1
- package/dist/src/transport/reservation-store.js +16 -0
- package/dist/src/transport/reservation-store.js.map +1 -1
- package/dist/src/transport/transport.d.ts +63 -0
- package/dist/src/transport/transport.d.ts.map +1 -0
- package/dist/src/transport/transport.js +286 -0
- package/dist/src/transport/transport.js.map +1 -0
- package/dist/src/utils.d.ts.map +1 -1
- package/dist/src/utils.js +3 -9
- package/dist/src/utils.js.map +1 -1
- package/package.json +12 -11
- package/src/transport/index.ts +6 -336
- package/src/transport/listener.ts +1 -0
- package/src/transport/reservation-store.ts +19 -0
- package/src/transport/transport.ts +354 -0
- package/src/utils.ts +4 -10
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/transport/index.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/transport/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,QAAQ,EAAE,MAAM,6BAA6B,CAAA;AAC3E,OAAO,EAAE,KAAK,wBAAwB,EAAE,MAAM,gBAAgB,CAAA;AAC9D,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,wBAAwB,CAAA;AAE5D,OAAO,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AACtE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oCAAoC,CA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1
|
-
import {
|
2
|
-
import {
|
3
|
-
import {
|
4
|
-
import {
|
5
|
-
import * as mafmt from '@multiformats/mafmt';
|
6
|
-
import { multiaddr } from '@multiformats/multiaddr';
|
7
|
-
import { pbStream } from 'it-protobuf-stream';
|
8
|
-
import { CIRCUIT_PROTO_CODE, ERR_HOP_REQUEST_FAILED, ERR_RELAYED_DIAL, MAX_CONNECTIONS, RELAY_V2_HOP_CODEC, RELAY_V2_STOP_CODEC } from '../constants.js';
|
9
|
-
import { StopMessage, HopMessage, Status } from '../pb/index.js';
|
10
|
-
import { RelayDiscovery } from './discovery.js';
|
11
|
-
import { createListener } from './listener.js';
|
12
|
-
import { ReservationStore } from './reservation-store.js';
|
13
|
-
const isValidStop = (request) => {
|
14
|
-
if (request.peer == null) {
|
15
|
-
return false;
|
16
|
-
}
|
17
|
-
try {
|
18
|
-
request.peer.addrs.forEach(multiaddr);
|
19
|
-
}
|
20
|
-
catch {
|
21
|
-
return false;
|
22
|
-
}
|
23
|
-
return true;
|
24
|
-
};
|
25
|
-
const defaults = {
|
26
|
-
maxInboundStopStreams: MAX_CONNECTIONS,
|
27
|
-
maxOutboundStopStreams: MAX_CONNECTIONS,
|
28
|
-
stopTimeout: 30000
|
29
|
-
};
|
30
|
-
class CircuitRelayTransport {
|
31
|
-
discovery;
|
32
|
-
registrar;
|
33
|
-
peerStore;
|
34
|
-
connectionManager;
|
35
|
-
peerId;
|
36
|
-
upgrader;
|
37
|
-
addressManager;
|
38
|
-
connectionGater;
|
39
|
-
reservationStore;
|
40
|
-
logger;
|
41
|
-
maxInboundStopStreams;
|
42
|
-
maxOutboundStopStreams;
|
43
|
-
stopTimeout;
|
44
|
-
started;
|
45
|
-
log;
|
46
|
-
constructor(components, init) {
|
47
|
-
this.log = components.logger.forComponent('libp2p:circuit-relay:transport');
|
48
|
-
this.registrar = components.registrar;
|
49
|
-
this.peerStore = components.peerStore;
|
50
|
-
this.connectionManager = components.connectionManager;
|
51
|
-
this.logger = components.logger;
|
52
|
-
this.peerId = components.peerId;
|
53
|
-
this.upgrader = components.upgrader;
|
54
|
-
this.addressManager = components.addressManager;
|
55
|
-
this.connectionGater = components.connectionGater;
|
56
|
-
this.maxInboundStopStreams = init.maxInboundStopStreams ?? defaults.maxInboundStopStreams;
|
57
|
-
this.maxOutboundStopStreams = init.maxOutboundStopStreams ?? defaults.maxOutboundStopStreams;
|
58
|
-
this.stopTimeout = init.stopTimeout ?? defaults.stopTimeout;
|
59
|
-
if (init.discoverRelays != null && init.discoverRelays > 0) {
|
60
|
-
this.discovery = new RelayDiscovery(components);
|
61
|
-
this.discovery.addEventListener('relay:discover', (evt) => {
|
62
|
-
this.reservationStore.addRelay(evt.detail, 'discovered')
|
63
|
-
.catch(err => {
|
64
|
-
this.log.error('could not add discovered relay %p', evt.detail, err);
|
65
|
-
});
|
66
|
-
});
|
67
|
-
}
|
68
|
-
this.reservationStore = new ReservationStore(components, init);
|
69
|
-
this.reservationStore.addEventListener('relay:not-enough-relays', () => {
|
70
|
-
this.discovery?.discover()
|
71
|
-
.catch(err => {
|
72
|
-
this.log.error('could not discover relays', err);
|
73
|
-
});
|
74
|
-
});
|
75
|
-
this.started = false;
|
76
|
-
}
|
77
|
-
isStarted() {
|
78
|
-
return this.started;
|
79
|
-
}
|
80
|
-
async start() {
|
81
|
-
await this.reservationStore.start();
|
82
|
-
await this.discovery?.start();
|
83
|
-
await this.registrar.handle(RELAY_V2_STOP_CODEC, (data) => {
|
84
|
-
void this.onStop(data).catch(err => {
|
85
|
-
this.log.error('error while handling STOP protocol', err);
|
86
|
-
data.stream.abort(err);
|
87
|
-
});
|
88
|
-
}, {
|
89
|
-
maxInboundStreams: this.maxInboundStopStreams,
|
90
|
-
maxOutboundStreams: this.maxOutboundStopStreams,
|
91
|
-
runOnTransientConnection: true
|
92
|
-
});
|
93
|
-
this.started = true;
|
94
|
-
}
|
95
|
-
async stop() {
|
96
|
-
this.discovery?.stop();
|
97
|
-
await this.reservationStore.stop();
|
98
|
-
await this.registrar.unhandle(RELAY_V2_STOP_CODEC);
|
99
|
-
this.started = false;
|
100
|
-
}
|
101
|
-
[symbol] = true;
|
102
|
-
[Symbol.toStringTag] = 'libp2p/circuit-relay-v2';
|
103
|
-
/**
|
104
|
-
* Dial a peer over a relay
|
105
|
-
*/
|
106
|
-
async dial(ma, options = {}) {
|
107
|
-
if (ma.protoCodes().filter(code => code === CIRCUIT_PROTO_CODE).length !== 1) {
|
108
|
-
const errMsg = 'Invalid circuit relay address';
|
109
|
-
this.log.error(errMsg, ma);
|
110
|
-
throw new CodeError(errMsg, ERR_RELAYED_DIAL);
|
111
|
-
}
|
112
|
-
// Check the multiaddr to see if it contains a relay and a destination peer
|
113
|
-
const addrs = ma.toString().split('/p2p-circuit');
|
114
|
-
const relayAddr = multiaddr(addrs[0]);
|
115
|
-
const destinationAddr = multiaddr(addrs[addrs.length - 1]);
|
116
|
-
const relayId = relayAddr.getPeerId();
|
117
|
-
const destinationId = destinationAddr.getPeerId();
|
118
|
-
if (relayId == null || destinationId == null) {
|
119
|
-
const errMsg = `Circuit relay dial to ${ma.toString()} failed as address did not have peer ids`;
|
120
|
-
this.log.error(errMsg);
|
121
|
-
throw new CodeError(errMsg, ERR_RELAYED_DIAL);
|
122
|
-
}
|
123
|
-
const relayPeer = peerIdFromString(relayId);
|
124
|
-
const destinationPeer = peerIdFromString(destinationId);
|
125
|
-
let disconnectOnFailure = false;
|
126
|
-
const relayConnections = this.connectionManager.getConnections(relayPeer);
|
127
|
-
let relayConnection = relayConnections[0];
|
128
|
-
if (relayConnection == null) {
|
129
|
-
await this.peerStore.merge(relayPeer, {
|
130
|
-
multiaddrs: [relayAddr]
|
131
|
-
});
|
132
|
-
relayConnection = await this.connectionManager.openConnection(relayPeer, options);
|
133
|
-
disconnectOnFailure = true;
|
134
|
-
}
|
135
|
-
let stream;
|
136
|
-
try {
|
137
|
-
stream = await relayConnection.newStream([RELAY_V2_HOP_CODEC]);
|
138
|
-
return await this.connectV2({
|
139
|
-
stream,
|
140
|
-
connection: relayConnection,
|
141
|
-
destinationPeer,
|
142
|
-
destinationAddr,
|
143
|
-
relayAddr,
|
144
|
-
ma,
|
145
|
-
disconnectOnFailure
|
146
|
-
});
|
147
|
-
}
|
148
|
-
catch (err) {
|
149
|
-
this.log.error('circuit relay dial to destination %p via relay %p failed', destinationPeer, relayPeer, err);
|
150
|
-
if (stream != null) {
|
151
|
-
stream.abort(err);
|
152
|
-
}
|
153
|
-
disconnectOnFailure && await relayConnection.close();
|
154
|
-
throw err;
|
155
|
-
}
|
156
|
-
}
|
157
|
-
async connectV2({ stream, connection, destinationPeer, destinationAddr, relayAddr, ma, disconnectOnFailure }) {
|
158
|
-
try {
|
159
|
-
const pbstr = pbStream(stream);
|
160
|
-
const hopstr = pbstr.pb(HopMessage);
|
161
|
-
await hopstr.write({
|
162
|
-
type: HopMessage.Type.CONNECT,
|
163
|
-
peer: {
|
164
|
-
id: destinationPeer.toBytes(),
|
165
|
-
addrs: [multiaddr(destinationAddr).bytes]
|
166
|
-
}
|
167
|
-
});
|
168
|
-
const status = await hopstr.read();
|
169
|
-
if (status.status !== Status.OK) {
|
170
|
-
throw new CodeError(`failed to connect via relay with status ${status?.status?.toString() ?? 'undefined'}`, ERR_HOP_REQUEST_FAILED);
|
171
|
-
}
|
172
|
-
const maConn = streamToMaConnection({
|
173
|
-
stream: pbstr.unwrap(),
|
174
|
-
remoteAddr: ma,
|
175
|
-
localAddr: relayAddr.encapsulate(`/p2p-circuit/p2p/${this.peerId.toString()}`),
|
176
|
-
logger: this.logger
|
177
|
-
});
|
178
|
-
this.log('new outbound transient connection %a', maConn.remoteAddr);
|
179
|
-
return await this.upgrader.upgradeOutbound(maConn, {
|
180
|
-
transient: true
|
181
|
-
});
|
182
|
-
}
|
183
|
-
catch (err) {
|
184
|
-
this.log.error(`Circuit relay dial to destination ${destinationPeer.toString()} via relay ${connection.remotePeer.toString()} failed`, err);
|
185
|
-
disconnectOnFailure && await connection.close();
|
186
|
-
throw err;
|
187
|
-
}
|
188
|
-
}
|
189
|
-
/**
|
190
|
-
* Create a listener
|
191
|
-
*/
|
192
|
-
createListener(options) {
|
193
|
-
return createListener({
|
194
|
-
connectionManager: this.connectionManager,
|
195
|
-
relayStore: this.reservationStore,
|
196
|
-
logger: this.logger
|
197
|
-
});
|
198
|
-
}
|
199
|
-
/**
|
200
|
-
* Filter check for all Multiaddrs that this transport can dial on
|
201
|
-
*
|
202
|
-
* @param {Multiaddr[]} multiaddrs
|
203
|
-
* @returns {Multiaddr[]}
|
204
|
-
*/
|
205
|
-
filter(multiaddrs) {
|
206
|
-
multiaddrs = Array.isArray(multiaddrs) ? multiaddrs : [multiaddrs];
|
207
|
-
return multiaddrs.filter((ma) => {
|
208
|
-
return mafmt.Circuit.matches(ma);
|
209
|
-
});
|
210
|
-
}
|
211
|
-
/**
|
212
|
-
* An incoming STOP request means a remote peer wants to dial us via a relay
|
213
|
-
*/
|
214
|
-
async onStop({ connection, stream }) {
|
215
|
-
const signal = AbortSignal.timeout(this.stopTimeout);
|
216
|
-
const pbstr = pbStream(stream).pb(StopMessage);
|
217
|
-
const request = await pbstr.read({
|
218
|
-
signal
|
219
|
-
});
|
220
|
-
this.log('new circuit relay v2 stop stream from %p with type %s', connection.remotePeer, request.type);
|
221
|
-
if (request?.type === undefined) {
|
222
|
-
this.log.error('type was missing from circuit v2 stop protocol request from %s', connection.remotePeer);
|
223
|
-
await pbstr.write({ type: StopMessage.Type.STATUS, status: Status.MALFORMED_MESSAGE }, {
|
224
|
-
signal
|
225
|
-
});
|
226
|
-
await stream.close();
|
227
|
-
return;
|
228
|
-
}
|
229
|
-
// Validate the STOP request has the required input
|
230
|
-
if (request.type !== StopMessage.Type.CONNECT) {
|
231
|
-
this.log.error('invalid stop connect request via peer %p', connection.remotePeer);
|
232
|
-
await pbstr.write({ type: StopMessage.Type.STATUS, status: Status.UNEXPECTED_MESSAGE }, {
|
233
|
-
signal
|
234
|
-
});
|
235
|
-
await stream.close();
|
236
|
-
return;
|
237
|
-
}
|
238
|
-
if (!isValidStop(request)) {
|
239
|
-
this.log.error('invalid stop connect request via peer %p', connection.remotePeer);
|
240
|
-
await pbstr.write({ type: StopMessage.Type.STATUS, status: Status.MALFORMED_MESSAGE }, {
|
241
|
-
signal
|
242
|
-
});
|
243
|
-
await stream.close();
|
244
|
-
return;
|
245
|
-
}
|
246
|
-
const remotePeerId = peerIdFromBytes(request.peer.id);
|
247
|
-
if ((await this.connectionGater.denyInboundRelayedConnection?.(connection.remotePeer, remotePeerId)) === true) {
|
248
|
-
this.log.error('connection gater denied inbound relayed connection from %p', connection.remotePeer);
|
249
|
-
await pbstr.write({ type: StopMessage.Type.STATUS, status: Status.PERMISSION_DENIED }, {
|
250
|
-
signal
|
251
|
-
});
|
252
|
-
await stream.close();
|
253
|
-
return;
|
254
|
-
}
|
255
|
-
this.log.trace('sending success response to %p', connection.remotePeer);
|
256
|
-
await pbstr.write({ type: StopMessage.Type.STATUS, status: Status.OK }, {
|
257
|
-
signal
|
258
|
-
});
|
259
|
-
const remoteAddr = connection.remoteAddr.encapsulate(`/p2p-circuit/p2p/${remotePeerId.toString()}`);
|
260
|
-
const localAddr = this.addressManager.getAddresses()[0];
|
261
|
-
const maConn = streamToMaConnection({
|
262
|
-
stream: pbstr.unwrap().unwrap(),
|
263
|
-
remoteAddr,
|
264
|
-
localAddr,
|
265
|
-
logger: this.logger
|
266
|
-
});
|
267
|
-
this.log('new inbound transient connection %a', maConn.remoteAddr);
|
268
|
-
await this.upgrader.upgradeInbound(maConn, {
|
269
|
-
transient: true
|
270
|
-
});
|
271
|
-
this.log('%s connection %a upgraded', 'inbound', maConn.remoteAddr);
|
272
|
-
}
|
273
|
-
}
|
1
|
+
import {} from '@libp2p/interface/transport';
|
2
|
+
import {} from './discovery.js';
|
3
|
+
import {} from './reservation-store.js';
|
4
|
+
import { CircuitRelayTransport } from './transport.js';
|
274
5
|
export function circuitRelayTransport(init = {}) {
|
275
6
|
return (components) => {
|
276
7
|
return new CircuitRelayTransport(components, init);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/transport/index.ts"],"names":[],"mappings":"AAAA,OAAO,
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/transport/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiC,MAAM,6BAA6B,CAAA;AAC3E,OAAO,EAAiC,MAAM,gBAAgB,CAAA;AAC9D,OAAO,EAAuB,MAAM,wBAAwB,CAAA;AAC5D,OAAO,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAA;AA6DtD,MAAM,UAAU,qBAAqB,CAAE,OAAkC,EAAE;IACzE,OAAO,CAAC,UAAU,EAAE,EAAE;QACpB,OAAO,IAAI,qBAAqB,CAAC,UAAU,EAAE,IAAI,CAAC,CAAA;IACpD,CAAC,CAAA;AACH,CAAC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"listener.d.ts","sourceRoot":"","sources":["../../../src/transport/listener.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AAC9D,OAAO,KAAK,EAAE,eAAe,EAAU,MAAM,mBAAmB,CAAA;AAEhE,OAAO,KAAK,EAAE,QAAQ,EAAkB,MAAM,6BAA6B,CAAA;AAC3E,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,+CAA+C,CAAA;AAGtF,MAAM,WAAW,uCAAuC;IACtD,iBAAiB,EAAE,iBAAiB,CAAA;IACpC,UAAU,EAAE,gBAAgB,CAAA;IAC5B,MAAM,EAAE,eAAe,CAAA;CACxB;
|
1
|
+
{"version":3,"file":"listener.d.ts","sourceRoot":"","sources":["../../../src/transport/listener.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AAC9D,OAAO,KAAK,EAAE,eAAe,EAAU,MAAM,mBAAmB,CAAA;AAEhE,OAAO,KAAK,EAAE,QAAQ,EAAkB,MAAM,6BAA6B,CAAA;AAC3E,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,+CAA+C,CAAA;AAGtF,MAAM,WAAW,uCAAuC;IACtD,iBAAiB,EAAE,iBAAiB,CAAA;IACpC,UAAU,EAAE,gBAAgB,CAAA;IAC5B,MAAM,EAAE,eAAe,CAAA;CACxB;AAiFD,wBAAgB,cAAc,CAAE,OAAO,EAAE,uCAAuC,GAAG,QAAQ,CAE1F"}
|
@@ -25,6 +25,7 @@ class CircuitRelayTransportListener extends TypedEventEmitter {
|
|
25
25
|
const relayAddr = addr.decapsulate('/p2p-circuit');
|
26
26
|
const relayConn = await this.connectionManager.openConnection(relayAddr);
|
27
27
|
if (!this.relayStore.hasReservation(relayConn.remotePeer)) {
|
28
|
+
this.log('making reservation on peer %p', relayConn.remotePeer);
|
28
29
|
// addRelay calls transportManager.listen which calls this listen method
|
29
30
|
await this.relayStore.addRelay(relayConn.remotePeer, 'configured');
|
30
31
|
return;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"listener.js","sourceRoot":"","sources":["../../../src/transport/listener.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAA;AACpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAA;AAC5D,OAAO,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAA;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AAcnD,MAAM,6BAA8B,SAAQ,iBAAiC;IAC1D,iBAAiB,CAAmB;IACpC,UAAU,CAAkB;IAC5B,cAAc,CAAsB;IACpC,GAAG,CAAQ;IAE5B,YAAa,UAAmD;QAC9D,KAAK,EAAE,CAAA;QAEP,IAAI,CAAC,GAAG,GAAG,UAAU,CAAC,MAAM,CAAC,YAAY,CAAC,yCAAyC,CAAC,CAAA;QACpF,IAAI,CAAC,iBAAiB,GAAG,UAAU,CAAC,iBAAiB,CAAA;Q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AAC,CAAA;YACnE,IAAI,CAAC,UAAU,CAAC,mBAAmB,CAAC,eAAe,EAAE,IAAI,CAAC,kBAAkB,CAAC,CAAA;YAC7E,mCAAmC;YACnC,IAAI,CAAC,iBAAiB,CAAC,OAAO,EAAE,EAAE,CAAC,CAAA;SACpC;IACH,CAAC;CACF;AAED,MAAM,UAAU,cAAc,CAAE,OAAgD;IAC9E,OAAO,IAAI,6BAA6B,CAAC,OAAO,CAAC,CAAA;AACnD,CAAC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"reservation-store.d.ts","sourceRoot":"","sources":["../../../src/transport/reservation-store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,KAAK,gBAAgB,EAAE,MAAM,0BAA0B,CAAA;
|
1
|
+
{"version":3,"file":"reservation-store.d.ts","sourceRoot":"","sources":["../../../src/transport/reservation-store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,KAAK,gBAAgB,EAAE,MAAM,0BAA0B,CAAA;AASnF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AACjD,OAAO,KAAK,EAAE,YAAY,EAAgB,eAAe,EAAU,MAAM,mBAAmB,CAAA;AAE5F,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAA;AACvD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAA;AAC7D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAA;AAC5D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,+CAA+C,CAAA;AACtF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,8CAA8C,CAAA;AAWpF,MAAM,WAAW,oBAAoB;IACnC,MAAM,EAAE,MAAM,CAAA;IACd,iBAAiB,EAAE,iBAAiB,CAAA;IACpC,gBAAgB,EAAE,gBAAgB,CAAA;IAClC,SAAS,EAAE,SAAS,CAAA;IACpB,MAAM,EAAE,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AC,IAAI,CAAC;IAS5B;;;;;OAKG;IACG,QAAQ,CAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC;IA8G/D,cAAc,CAAE,MAAM,EAAE,MAAM,GAAG,OAAO;IAIxC,cAAc,CAAE,MAAM,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS;CA0EzD"}
|
@@ -3,6 +3,7 @@ import { PeerMap } from '@libp2p/peer-collections';
|
|
3
3
|
import { PeerJobQueue } from '@libp2p/utils/peer-job-queue';
|
4
4
|
import { multiaddr } from '@multiformats/multiaddr';
|
5
5
|
import { pbStream } from 'it-protobuf-stream';
|
6
|
+
import { equals as uint8ArrayEquals } from 'uint8arrays/equals';
|
6
7
|
import { DEFAULT_RESERVATION_CONCURRENCY, RELAY_TAG, RELAY_V2_HOP_CODEC } from '../constants.js';
|
7
8
|
import { HopMessage, Status } from '../pb/index.js';
|
8
9
|
import { getExpirationMilliseconds } from '../utils.js';
|
@@ -176,12 +177,27 @@ export class ReservationStore extends TypedEventEmitter {
|
|
176
177
|
}
|
177
178
|
catch (err) {
|
178
179
|
this.log.error('error parsing reserve message response from %p because', connection.remotePeer, err);
|
180
|
+
stream.abort(err);
|
179
181
|
throw err;
|
180
182
|
}
|
181
183
|
finally {
|
182
184
|
await stream.close();
|
183
185
|
}
|
184
186
|
if (response.status === Status.OK && (response.reservation != null)) {
|
187
|
+
// check that the returned relay has the relay address - this can be
|
188
|
+
// omitted when requesting a reservation from a go-libp2p relay we
|
189
|
+
// already have a reservation on
|
190
|
+
let hasRelayAddress = false;
|
191
|
+
const relayAddressBytes = connection.remoteAddr.bytes;
|
192
|
+
for (const buf of response.reservation.addrs) {
|
193
|
+
if (uint8ArrayEquals(relayAddressBytes, buf)) {
|
194
|
+
hasRelayAddress = true;
|
195
|
+
break;
|
196
|
+
}
|
197
|
+
}
|
198
|
+
if (!hasRelayAddress) {
|
199
|
+
response.reservation.addrs.push(relayAddressBytes);
|
200
|
+
}
|
185
201
|
return response.reservation;
|
186
202
|
}
|
187
203
|
const errMsg = `reservation failed with status ${response.status ?? 'undefined'}`;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"reservation-store.js","sourceRoot":"","sources":["../../../src/transport/reservation-store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAyB,MAAM,0BAA0B,CAAA;AACnF,OAAO,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAA;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAA;AAC3D,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AACnD,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAC7C,OAAO,EAAE,+BAA+B,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AAChG,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AACnD,OAAO,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAA;AAUvD,gFAAgF;AAChF,MAAM,cAAc,GAAG,CAAC,EAAE,GAAG,IAAI,CAAC,GAAG,EAAE,CAAA;AAEvC,4DAA4D;AAC5D,MAAM,eAAe,GAAG,CAAC,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC,CAAA;AAEvC,oEAAoE;AACpE,MAAM,mBAAmB,GAAG,EAAE,GAAG,IAAI,CAAA;AAoDrC,MAAM,OAAO,gBAAiB,SAAQ,iBAAyC;IAC5D,MAAM,CAAQ;IACd,iBAAiB,CAAmB;IACpC,gBAAgB,CAAkB;IAClC,SAAS,CAAW;IACpB,MAAM,CAAgC;IACtC,YAAY,CAAc;IAC1B,YAAY,CAAqB;IACjC,mBAAmB,CAAQ;IAC3B,yBAAyB,CAAQ;IACjC,4BAA4B,CAAQ;IAC7C,OAAO,CAAS;IACP,GAAG,CAAQ;IAE5B,YAAa,UAAgC,EAAE,IAAqB;QAClE,KAAK,EAAE,CAAA;Q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iB,CAAC,CAAA;aACnD;YAED,OAAO,QAAQ,CAAC,WAAW,CAAA;SAC5B;QAED,MAAM,MAAM,GAAG,kCAAkC,QAAQ,CAAC,MAAM,IAAI,WAAW,EAAE,CAAA;QACjF,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,CAAA;QAEtB,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC,CAAA;IACzB,CAAC;IAED;;OAEG;IACH,YAAY,CAAE,MAAc;QAC1B,MAAM,mBAAmB,GAAG,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;QAEzD,IAAI,mBAAmB,IAAI,IAAI,EAAE;YAC/B,OAAM;SACP;QAED,IAAI,CAAC,GAAG,CAAC,sEAAsE,EAAE,MAAM,CAAC,CAAA;QAExF,YAAY,CAAC,mBAAmB,CAAC,OAAO,CAAC,CAAA;QACzC,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;QAEhC,IAAI,CAAC,iBAAiB,CAAC,eAAe,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAA;QAE3D,IAAI,IAAI,CAAC,YAAY,CAAC,IAAI,GAAG,IAAI,CAAC,mBAAmB,EAAE;YACrD,IAAI,CAAC,GAAG,CAAC,yBAAyB,EAAE,IAAI,CAAC,YAAY,CAAC,IAAI,EAAE,IAAI,CAAC,mBAAmB,CAAC,CAAA;YACrF,IAAI,CAAC,iBAAiB,CAAC,yBAAyB,EAAE,EAAE,CAAC,CAAA;SACtD;IACH,CAAC;CACF"}
|
@@ -0,0 +1,63 @@
|
|
1
|
+
import { symbol, type Transport, type CreateListenerOptions, type Listener } from '@libp2p/interface/transport';
|
2
|
+
import { ReservationStore } from './reservation-store.js';
|
3
|
+
import type { CircuitRelayTransportComponents, CircuitRelayTransportInit } from './index.js';
|
4
|
+
import type { AbortOptions } from '@libp2p/interface';
|
5
|
+
import type { Connection, Stream } from '@libp2p/interface/connection';
|
6
|
+
import type { PeerId } from '@libp2p/interface/peer-id';
|
7
|
+
import type { IncomingStreamData } from '@libp2p/interface-internal/registrar';
|
8
|
+
import type { Multiaddr } from '@multiformats/multiaddr';
|
9
|
+
interface ConnectOptions {
|
10
|
+
stream: Stream;
|
11
|
+
connection: Connection;
|
12
|
+
destinationPeer: PeerId;
|
13
|
+
destinationAddr: Multiaddr;
|
14
|
+
relayAddr: Multiaddr;
|
15
|
+
ma: Multiaddr;
|
16
|
+
disconnectOnFailure: boolean;
|
17
|
+
}
|
18
|
+
export declare class CircuitRelayTransport implements Transport {
|
19
|
+
private readonly discovery?;
|
20
|
+
private readonly registrar;
|
21
|
+
private readonly peerStore;
|
22
|
+
private readonly connectionManager;
|
23
|
+
private readonly transportManager;
|
24
|
+
private readonly peerId;
|
25
|
+
private readonly upgrader;
|
26
|
+
private readonly addressManager;
|
27
|
+
private readonly connectionGater;
|
28
|
+
readonly reservationStore: ReservationStore;
|
29
|
+
private readonly logger;
|
30
|
+
private readonly maxInboundStopStreams;
|
31
|
+
private readonly maxOutboundStopStreams?;
|
32
|
+
private readonly stopTimeout;
|
33
|
+
private started;
|
34
|
+
private readonly log;
|
35
|
+
constructor(components: CircuitRelayTransportComponents, init: CircuitRelayTransportInit);
|
36
|
+
isStarted(): boolean;
|
37
|
+
start(): Promise<void>;
|
38
|
+
stop(): Promise<void>;
|
39
|
+
readonly [symbol] = true;
|
40
|
+
readonly [Symbol.toStringTag] = "libp2p/circuit-relay-v2";
|
41
|
+
/**
|
42
|
+
* Dial a peer over a relay
|
43
|
+
*/
|
44
|
+
dial(ma: Multiaddr, options?: AbortOptions): Promise<Connection>;
|
45
|
+
connectV2({ stream, connection, destinationPeer, destinationAddr, relayAddr, ma, disconnectOnFailure }: ConnectOptions): Promise<Connection>;
|
46
|
+
/**
|
47
|
+
* Create a listener
|
48
|
+
*/
|
49
|
+
createListener(options: CreateListenerOptions): Listener;
|
50
|
+
/**
|
51
|
+
* Filter check for all Multiaddrs that this transport can dial on
|
52
|
+
*
|
53
|
+
* @param {Multiaddr[]} multiaddrs
|
54
|
+
* @returns {Multiaddr[]}
|
55
|
+
*/
|
56
|
+
filter(multiaddrs: Multiaddr[]): Multiaddr[];
|
57
|
+
/**
|
58
|
+
* An incoming STOP request means a remote peer wants to dial us via a relay
|
59
|
+
*/
|
60
|
+
onStop({ connection, stream }: IncomingStreamData): Promise<void>;
|
61
|
+
}
|
62
|
+
export {};
|
63
|
+
//# sourceMappingURL=transport.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../../../src/transport/transport.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,KAAK,SAAS,EAAE,KAAK,qBAAqB,EAAE,KAAK,QAAQ,EAAiB,MAAM,6BAA6B,CAAA;AAU9H,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AACzD,OAAO,KAAK,EAAE,+BAA+B,EAAE,yBAAyB,EAAE,MAAM,YAAY,CAAA;AAC5F,OAAO,KAAK,EAAE,YAAY,EAA2B,MAAM,mBAAmB,CAAA;AAC9E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAA;AAEtE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAA;AAIvD,OAAO,KAAK,EAAE,kBAAkB,EAAa,MAAM,sCAAsC,CAAA;AAEzF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AAgBxD,UAAU,cAAc;IACtB,MAAM,EAAE,MAAM,CAAA;IACd,UAAU,EAAE,UAAU,CAAA;IACtB,eAAe,EAAE,MAAM,CAAA;IACvB,eAAe,EAAE,SAAS,CAAA;IAC1B,SAAS,EAAE,SAAS,CAAA;IACpB,EAAE,EAAE,SAAS,CAAA;IACb,mBAAmB,EAAE,OAAO,CAAA;CAC7B;AAQD,qBAAa,qBAAsB,YAAW,SAAS;IACrD,OAAO,CAAC,QAA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