@libp2p/autonat-v2 0.0.0-2d6079bc1
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 +74 -0
- package/dist/index.min.js +19 -0
- package/dist/index.min.js.map +7 -0
- package/dist/src/autonat.d.ts +14 -0
- package/dist/src/autonat.d.ts.map +1 -0
- package/dist/src/autonat.js +38 -0
- package/dist/src/autonat.js.map +1 -0
- package/dist/src/client.d.ts +58 -0
- package/dist/src/client.d.ts.map +1 -0
- package/dist/src/client.js +476 -0
- package/dist/src/client.js.map +1 -0
- package/dist/src/constants.d.ts +22 -0
- package/dist/src/constants.d.ts.map +1 -0
- package/dist/src/constants.js +22 -0
- package/dist/src/constants.js.map +1 -0
- package/dist/src/index.d.ts +93 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +30 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/pb/index.d.ts +90 -0
- package/dist/src/pb/index.d.ts.map +1 -0
- package/dist/src/pb/index.js +488 -0
- package/dist/src/pb/index.js.map +1 -0
- package/dist/src/server.d.ts +27 -0
- package/dist/src/server.d.ts.map +1 -0
- package/dist/src/server.js +191 -0
- package/dist/src/server.js.map +1 -0
- package/dist/src/utils.d.ts +2 -0
- package/dist/src/utils.d.ts.map +1 -0
- package/dist/src/utils.js +4 -0
- package/dist/src/utils.js.map +1 -0
- package/package.json +75 -0
- package/src/autonat.ts +47 -0
- package/src/client.ts +628 -0
- package/src/constants.ts +24 -0
- package/src/index.ts +110 -0
- package/src/pb/index.proto +56 -0
- package/src/pb/index.ts +614 -0
- package/src/server.ts +237 -0
- package/src/utils.ts +3 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { serviceCapabilities, serviceDependencies } from '@libp2p/interface';
|
|
2
|
+
import type { AutoNATv2Components, AutoNATv2ServiceInit } from './index.ts';
|
|
3
|
+
import type { Startable } from '@libp2p/interface';
|
|
4
|
+
export declare class AutoNATv2Service implements Startable {
|
|
5
|
+
private readonly client;
|
|
6
|
+
private readonly server;
|
|
7
|
+
constructor(components: AutoNATv2Components, init: AutoNATv2ServiceInit);
|
|
8
|
+
readonly [Symbol.toStringTag] = "@libp2p/autonat-v2";
|
|
9
|
+
readonly [serviceCapabilities]: string[];
|
|
10
|
+
get [serviceDependencies](): string[];
|
|
11
|
+
start(): Promise<void>;
|
|
12
|
+
stop(): Promise<void>;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=autonat.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"autonat.d.ts","sourceRoot":"","sources":["../../src/autonat.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAe,MAAM,mBAAmB,CAAA;AAIzF,OAAO,KAAK,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAA;AAC3E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAElD,qBAAa,gBAAiB,YAAW,SAAS;IAChD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAiB;IACxC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAiB;gBAE3B,UAAU,EAAE,mBAAmB,EAAE,IAAI,EAAE,oBAAoB;IAgBxE,QAAQ,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,wBAAuB;IAEpD,QAAQ,CAAC,CAAC,mBAAmB,CAAC,EAAE,MAAM,EAAE,CAEvC;IAED,IAAI,CAAC,mBAAmB,CAAC,IAAK,MAAM,EAAE,CAIrC;IAEK,KAAK,IAAK,OAAO,CAAC,IAAI,CAAC;IAIvB,IAAI,IAAK,OAAO,CAAC,IAAI,CAAC;CAG7B"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { serviceCapabilities, serviceDependencies, start, stop } from '@libp2p/interface';
|
|
2
|
+
import { AutoNATv2Client } from "./client.js";
|
|
3
|
+
import { DIAL_BACK, DIAL_REQUEST, PROTOCOL_NAME, PROTOCOL_PREFIX, PROTOCOL_VERSION } from "./constants.js";
|
|
4
|
+
import { AutoNATv2Server } from "./server.js";
|
|
5
|
+
export class AutoNATv2Service {
|
|
6
|
+
client;
|
|
7
|
+
server;
|
|
8
|
+
constructor(components, init) {
|
|
9
|
+
const dialRequestProtocol = `/${init.protocolPrefix ?? PROTOCOL_PREFIX}/${PROTOCOL_NAME}/${PROTOCOL_VERSION}/${DIAL_REQUEST}`;
|
|
10
|
+
const dialBackProtocol = `/${init.protocolPrefix ?? PROTOCOL_PREFIX}/${PROTOCOL_NAME}/${PROTOCOL_VERSION}/${DIAL_BACK}`;
|
|
11
|
+
this.client = new AutoNATv2Client(components, {
|
|
12
|
+
...init,
|
|
13
|
+
dialRequestProtocol,
|
|
14
|
+
dialBackProtocol
|
|
15
|
+
});
|
|
16
|
+
this.server = new AutoNATv2Server(components, {
|
|
17
|
+
...init,
|
|
18
|
+
dialRequestProtocol,
|
|
19
|
+
dialBackProtocol
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
[Symbol.toStringTag] = '@libp2p/autonat-v2';
|
|
23
|
+
[serviceCapabilities] = [
|
|
24
|
+
'@libp2p/autonat'
|
|
25
|
+
];
|
|
26
|
+
get [serviceDependencies]() {
|
|
27
|
+
return [
|
|
28
|
+
'@libp2p/identify'
|
|
29
|
+
];
|
|
30
|
+
}
|
|
31
|
+
async start() {
|
|
32
|
+
await start(this.client, this.server);
|
|
33
|
+
}
|
|
34
|
+
async stop() {
|
|
35
|
+
await stop(this.client, this.server);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=autonat.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"autonat.js","sourceRoot":"","sources":["../../src/autonat.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAA;AACzF,OAAO,EAAE,eAAe,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serviceCapabilities, serviceDependencies } from '@libp2p/interface';
|
|
2
|
+
import type { AutoNATv2Components, AutoNATv2ServiceInit } from './index.ts';
|
|
3
|
+
import type { Connection, Startable, AbortOptions, IncomingStreamData } from '@libp2p/interface';
|
|
4
|
+
export interface AutoNATv2ClientInit extends AutoNATv2ServiceInit {
|
|
5
|
+
dialRequestProtocol: string;
|
|
6
|
+
dialBackProtocol: string;
|
|
7
|
+
maxDialDataBytes?: bigint;
|
|
8
|
+
dialDataChunkSize?: number;
|
|
9
|
+
}
|
|
10
|
+
export declare class AutoNATv2Client implements Startable {
|
|
11
|
+
private readonly components;
|
|
12
|
+
private readonly dialRequestProtocol;
|
|
13
|
+
private readonly dialBackProtocol;
|
|
14
|
+
private readonly timeout;
|
|
15
|
+
private readonly maxInboundStreams;
|
|
16
|
+
private readonly maxOutboundStreams;
|
|
17
|
+
private readonly maxMessageSize;
|
|
18
|
+
private readonly maxDialDataBytes;
|
|
19
|
+
private readonly dialDataChunkSize;
|
|
20
|
+
private started;
|
|
21
|
+
private readonly log;
|
|
22
|
+
private topologyId?;
|
|
23
|
+
private readonly dialResults;
|
|
24
|
+
private readonly findPeers;
|
|
25
|
+
private readonly addressFilter;
|
|
26
|
+
private readonly connectionThreshold;
|
|
27
|
+
private readonly queue;
|
|
28
|
+
private readonly nonces;
|
|
29
|
+
constructor(components: AutoNATv2Components, init: AutoNATv2ClientInit);
|
|
30
|
+
readonly [Symbol.toStringTag] = "@libp2p/autonat-v2";
|
|
31
|
+
readonly [serviceCapabilities]: string[];
|
|
32
|
+
get [serviceDependencies](): string[];
|
|
33
|
+
isStarted(): boolean;
|
|
34
|
+
start(): Promise<void>;
|
|
35
|
+
stop(): Promise<void>;
|
|
36
|
+
private allAddressesAreVerified;
|
|
37
|
+
findRandomPeers(options?: AbortOptions): Promise<void>;
|
|
38
|
+
/**
|
|
39
|
+
* Handle an incoming AutoNAT request
|
|
40
|
+
*/
|
|
41
|
+
handleDialBackStream(data: IncomingStreamData): Promise<void>;
|
|
42
|
+
private getUnverifiedMultiaddrs;
|
|
43
|
+
/**
|
|
44
|
+
* Removes any multiaddr result objects created for old multiaddrs that we are
|
|
45
|
+
* no longer waiting on
|
|
46
|
+
*/
|
|
47
|
+
private removeOutdatedMultiaddrResults;
|
|
48
|
+
/**
|
|
49
|
+
* Our multicodec topology noticed a new peer that supports autonat
|
|
50
|
+
*/
|
|
51
|
+
verifyExternalAddresses(connection: Connection): Promise<void>;
|
|
52
|
+
private askPeerToVerify;
|
|
53
|
+
private hasConnectionCapacity;
|
|
54
|
+
private confirmAddress;
|
|
55
|
+
private unconfirmAddress;
|
|
56
|
+
private getNetworkSegment;
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAA;AAc3F,OAAO,KAAK,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAA;AAC3E,OAAO,KAAK,EAAU,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AAyDxG,MAAM,WAAW,mBAAoB,SAAQ,oBAAoB;IAC/D,mBAAmB,EAAE,MAAM,CAAA;IAC3B,gBAAgB,EAAE,MAAM,CAAA;IACxB,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,iBAAiB,CAAC,EAAE,MAAM,CAAA;CAC3B;AAED,qBAAa,eAAgB,YAAW,SAAS;IAC/C,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAqB;IAChD,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CAAQ;IAC5C,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAQ;IACzC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAQ;IAChC,OAAO,CAAC,QAAQ,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UAAU,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC;YA2DvD,eAAe;IAmI7B,OAAO,CAAC,qBAAqB;IAQ7B,OAAO,CAAC,cAAc;IAUtB,OAAO,CAAC,gBAAgB;IAUxB,OAAO,CAAC,iBAAiB;CAY1B"}
|
|
@@ -0,0 +1,476 @@
|
|
|
1
|
+
import { ProtocolError, serviceCapabilities, serviceDependencies } from '@libp2p/interface';
|
|
2
|
+
import { peerSet } from '@libp2p/peer-collections';
|
|
3
|
+
import { createScalableCuckooFilter } from '@libp2p/utils/filters';
|
|
4
|
+
import { isGlobalUnicast } from '@libp2p/utils/multiaddr/is-global-unicast';
|
|
5
|
+
import { isPrivate } from '@libp2p/utils/multiaddr/is-private';
|
|
6
|
+
import { PeerQueue } from '@libp2p/utils/peer-queue';
|
|
7
|
+
import { repeatingTask } from '@libp2p/utils/repeating-task';
|
|
8
|
+
import { trackedMap } from '@libp2p/utils/tracked-map';
|
|
9
|
+
import { anySignal } from 'any-signal';
|
|
10
|
+
import { pbStream } from 'it-protobuf-stream';
|
|
11
|
+
import { setMaxListeners } from 'main-event';
|
|
12
|
+
import { DEFAULT_CONNECTION_THRESHOLD, DIAL_DATA_CHUNK_SIZE, MAX_DIAL_DATA_BYTES, MAX_INBOUND_STREAMS, MAX_MESSAGE_SIZE, MAX_OUTBOUND_STREAMS, TIMEOUT } from "./constants.js";
|
|
13
|
+
import { DialBack, DialBackResponse, DialResponse, DialStatus, Message } from "./pb/index.js";
|
|
14
|
+
import { randomNumber } from "./utils.js";
|
|
15
|
+
// if more than 3 peers manage to dial us on what we believe to be our external
|
|
16
|
+
// IP then we are convinced that it is, in fact, our external IP
|
|
17
|
+
// https://github.com/libp2p/specs/blob/master/autonat/autonat-v1.md#autonat-protocol
|
|
18
|
+
const REQUIRED_SUCCESSFUL_DIALS = 4;
|
|
19
|
+
const REQUIRED_FAILED_DIALS = 8;
|
|
20
|
+
export class AutoNATv2Client {
|
|
21
|
+
components;
|
|
22
|
+
dialRequestProtocol;
|
|
23
|
+
dialBackProtocol;
|
|
24
|
+
timeout;
|
|
25
|
+
maxInboundStreams;
|
|
26
|
+
maxOutboundStreams;
|
|
27
|
+
maxMessageSize;
|
|
28
|
+
maxDialDataBytes;
|
|
29
|
+
dialDataChunkSize;
|
|
30
|
+
started;
|
|
31
|
+
log;
|
|
32
|
+
topologyId;
|
|
33
|
+
dialResults;
|
|
34
|
+
findPeers;
|
|
35
|
+
addressFilter;
|
|
36
|
+
connectionThreshold;
|
|
37
|
+
queue;
|
|
38
|
+
nonces;
|
|
39
|
+
constructor(components, init) {
|
|
40
|
+
this.components = components;
|
|
41
|
+
this.log = components.logger.forComponent('libp2p:auto-nat-v2:client');
|
|
42
|
+
this.started = false;
|
|
43
|
+
this.dialRequestProtocol = init.dialRequestProtocol;
|
|
44
|
+
this.dialBackProtocol = init.dialBackProtocol;
|
|
45
|
+
this.timeout = init.timeout ?? TIMEOUT;
|
|
46
|
+
this.maxInboundStreams = init.maxInboundStreams ?? MAX_INBOUND_STREAMS;
|
|
47
|
+
this.maxOutboundStreams = init.maxOutboundStreams ?? MAX_OUTBOUND_STREAMS;
|
|
48
|
+
this.connectionThreshold = init.connectionThreshold ?? DEFAULT_CONNECTION_THRESHOLD;
|
|
49
|
+
this.maxMessageSize = init.maxMessageSize ?? MAX_MESSAGE_SIZE;
|
|
50
|
+
this.dialResults = trackedMap({
|
|
51
|
+
name: 'libp2p_autonat_v2_dial_results',
|
|
52
|
+
metrics: components.metrics
|
|
53
|
+
});
|
|
54
|
+
this.findPeers = repeatingTask(this.findRandomPeers.bind(this), 60_000);
|
|
55
|
+
this.addressFilter = createScalableCuckooFilter(1024);
|
|
56
|
+
this.queue = new PeerQueue({
|
|
57
|
+
concurrency: 3,
|
|
58
|
+
maxSize: 50
|
|
59
|
+
});
|
|
60
|
+
this.maxDialDataBytes = init.maxDialDataBytes ?? MAX_DIAL_DATA_BYTES;
|
|
61
|
+
this.dialDataChunkSize = init.dialDataChunkSize ?? DIAL_DATA_CHUNK_SIZE;
|
|
62
|
+
this.nonces = new Set();
|
|
63
|
+
}
|
|
64
|
+
[Symbol.toStringTag] = '@libp2p/autonat-v2';
|
|
65
|
+
[serviceCapabilities] = [
|
|
66
|
+
'@libp2p/autonat'
|
|
67
|
+
];
|
|
68
|
+
get [serviceDependencies]() {
|
|
69
|
+
return [
|
|
70
|
+
'@libp2p/identify'
|
|
71
|
+
];
|
|
72
|
+
}
|
|
73
|
+
isStarted() {
|
|
74
|
+
return this.started;
|
|
75
|
+
}
|
|
76
|
+
async start() {
|
|
77
|
+
if (this.started) {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
this.topologyId = await this.components.registrar.register(this.dialRequestProtocol, {
|
|
81
|
+
onConnect: (peerId, connection) => {
|
|
82
|
+
this.verifyExternalAddresses(connection)
|
|
83
|
+
.catch(err => {
|
|
84
|
+
this.log.error('could not verify addresses - %e', err);
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
await this.components.registrar.handle(this.dialBackProtocol, (data) => {
|
|
89
|
+
void this.handleDialBackStream(data)
|
|
90
|
+
.catch(err => {
|
|
91
|
+
this.log.error('error handling incoming autonat stream - %e', err);
|
|
92
|
+
});
|
|
93
|
+
}, {
|
|
94
|
+
maxInboundStreams: this.maxInboundStreams,
|
|
95
|
+
maxOutboundStreams: this.maxOutboundStreams
|
|
96
|
+
});
|
|
97
|
+
this.findPeers.start();
|
|
98
|
+
this.started = true;
|
|
99
|
+
}
|
|
100
|
+
async stop() {
|
|
101
|
+
await this.components.registrar.unhandle(this.dialRequestProtocol);
|
|
102
|
+
await this.components.registrar.unhandle(this.dialBackProtocol);
|
|
103
|
+
if (this.topologyId != null) {
|
|
104
|
+
await this.components.registrar.unhandle(this.topologyId);
|
|
105
|
+
}
|
|
106
|
+
this.dialResults.clear();
|
|
107
|
+
this.findPeers.stop();
|
|
108
|
+
this.started = false;
|
|
109
|
+
}
|
|
110
|
+
allAddressesAreVerified() {
|
|
111
|
+
return this.components.addressManager.getAddressesWithMetadata().every(addr => {
|
|
112
|
+
if (addr.expires > Date.now()) {
|
|
113
|
+
// ignore any unverified addresses within their TTL
|
|
114
|
+
return true;
|
|
115
|
+
}
|
|
116
|
+
return addr.verified;
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
async findRandomPeers(options) {
|
|
120
|
+
// skip if all addresses are verified
|
|
121
|
+
if (this.allAddressesAreVerified()) {
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
const signal = anySignal([
|
|
125
|
+
AbortSignal.timeout(10_000),
|
|
126
|
+
options?.signal
|
|
127
|
+
]);
|
|
128
|
+
// spend a few seconds finding random peers - dial them which will run
|
|
129
|
+
// identify to trigger the topology callbacks and run AutoNAT
|
|
130
|
+
try {
|
|
131
|
+
this.log('starting random walk to find peers to run AutoNAT');
|
|
132
|
+
for await (const peer of this.components.randomWalk.walk({ signal })) {
|
|
133
|
+
if (!(await this.components.connectionManager.isDialable(peer.multiaddrs))) {
|
|
134
|
+
this.log.trace('random peer %p was not dialable %s', peer.id, peer.multiaddrs.map(ma => ma.toString()).join(', '));
|
|
135
|
+
// skip peers we can't dial
|
|
136
|
+
continue;
|
|
137
|
+
}
|
|
138
|
+
try {
|
|
139
|
+
this.log.trace('dial random peer %p', peer.id);
|
|
140
|
+
await this.components.connectionManager.openConnection(peer.multiaddrs, {
|
|
141
|
+
signal
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
catch { }
|
|
145
|
+
if (this.allAddressesAreVerified()) {
|
|
146
|
+
this.log('stopping random walk, all addresses are verified');
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
if (!this.hasConnectionCapacity()) {
|
|
150
|
+
this.log('stopping random walk, too close to max connections');
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
catch { }
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Handle an incoming AutoNAT request
|
|
159
|
+
*/
|
|
160
|
+
async handleDialBackStream(data) {
|
|
161
|
+
const signal = AbortSignal.timeout(this.timeout);
|
|
162
|
+
setMaxListeners(Infinity, signal);
|
|
163
|
+
const messages = pbStream(data.stream, {
|
|
164
|
+
maxDataLength: this.maxMessageSize
|
|
165
|
+
});
|
|
166
|
+
try {
|
|
167
|
+
const message = await messages.read(DialBack, {
|
|
168
|
+
signal
|
|
169
|
+
});
|
|
170
|
+
// TODO: need to verify that the incoming address is the one we asked the
|
|
171
|
+
// peer to dial us on
|
|
172
|
+
if (!this.nonces.has(message.nonce)) {
|
|
173
|
+
throw new ProtocolError('No matching dial found for nonce value');
|
|
174
|
+
}
|
|
175
|
+
this.nonces.delete(message.nonce);
|
|
176
|
+
await messages.write({
|
|
177
|
+
status: DialBackResponse.DialBackStatus.OK
|
|
178
|
+
}, DialBackResponse);
|
|
179
|
+
await data.stream.close({
|
|
180
|
+
signal
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
catch (err) {
|
|
184
|
+
this.log.error('error handling incoming dial back stream - %e', err);
|
|
185
|
+
data.stream.abort(err);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
getUnverifiedMultiaddrs(segment, supportsIPv6) {
|
|
189
|
+
const addrs = this.components.addressManager.getAddressesWithMetadata()
|
|
190
|
+
.sort((a, b) => {
|
|
191
|
+
// sort addresses, de-prioritize observed addresses
|
|
192
|
+
if (a.type === 'observed' && b.type !== 'observed') {
|
|
193
|
+
return 1;
|
|
194
|
+
}
|
|
195
|
+
if (b.type === 'observed' && a.type !== 'observed') {
|
|
196
|
+
return -1;
|
|
197
|
+
}
|
|
198
|
+
return 0;
|
|
199
|
+
})
|
|
200
|
+
.filter(addr => {
|
|
201
|
+
const expired = addr.expires < Date.now();
|
|
202
|
+
if (!expired) {
|
|
203
|
+
// skip verified/non-verified addresses within their TTL
|
|
204
|
+
return false;
|
|
205
|
+
}
|
|
206
|
+
const options = addr.multiaddr.toOptions();
|
|
207
|
+
if (options.family === 6) {
|
|
208
|
+
// do not send IPv6 addresses to peers without IPv6 addresses
|
|
209
|
+
if (!supportsIPv6) {
|
|
210
|
+
return false;
|
|
211
|
+
}
|
|
212
|
+
if (!isGlobalUnicast(addr.multiaddr)) {
|
|
213
|
+
// skip non-globally routable addresses
|
|
214
|
+
return false;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
if (isPrivate(addr.multiaddr)) {
|
|
218
|
+
// skip private addresses
|
|
219
|
+
return false;
|
|
220
|
+
}
|
|
221
|
+
return true;
|
|
222
|
+
});
|
|
223
|
+
const output = [];
|
|
224
|
+
for (const addr of addrs) {
|
|
225
|
+
const addrString = addr.multiaddr.toString();
|
|
226
|
+
let results = this.dialResults.get(addrString);
|
|
227
|
+
if (results != null) {
|
|
228
|
+
if (results.networkSegments.includes(segment)) {
|
|
229
|
+
this.log.trace('%a already has a network segment result from %s', results.multiaddr, segment);
|
|
230
|
+
// skip this address if we already have a dial result from the
|
|
231
|
+
// network segment the peer is in
|
|
232
|
+
continue;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
// will include this multiaddr, ensure we have a results object
|
|
236
|
+
if (results == null) {
|
|
237
|
+
const needsRevalidating = addr.expires < Date.now();
|
|
238
|
+
// allow re-validating addresses that worked previously
|
|
239
|
+
if (needsRevalidating) {
|
|
240
|
+
this.addressFilter.remove?.(addrString);
|
|
241
|
+
}
|
|
242
|
+
if (this.addressFilter.has(addrString)) {
|
|
243
|
+
continue;
|
|
244
|
+
}
|
|
245
|
+
// only try to validate the address once
|
|
246
|
+
this.addressFilter.add(addrString);
|
|
247
|
+
this.log.trace('creating dial result %s %s', needsRevalidating ? 'to revalidate' : 'for', addrString);
|
|
248
|
+
results = {
|
|
249
|
+
multiaddr: addr.multiaddr,
|
|
250
|
+
success: 0,
|
|
251
|
+
failure: 0,
|
|
252
|
+
networkSegments: [],
|
|
253
|
+
verifyingPeers: peerSet(),
|
|
254
|
+
type: addr.type,
|
|
255
|
+
lastVerified: addr.lastVerified
|
|
256
|
+
};
|
|
257
|
+
this.dialResults.set(addrString, results);
|
|
258
|
+
}
|
|
259
|
+
output.push(results);
|
|
260
|
+
}
|
|
261
|
+
return output;
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* Removes any multiaddr result objects created for old multiaddrs that we are
|
|
265
|
+
* no longer waiting on
|
|
266
|
+
*/
|
|
267
|
+
removeOutdatedMultiaddrResults() {
|
|
268
|
+
const unverifiedMultiaddrs = new Set(this.components.addressManager.getAddressesWithMetadata()
|
|
269
|
+
.filter(({ expires }) => {
|
|
270
|
+
if (expires < Date.now()) {
|
|
271
|
+
return true;
|
|
272
|
+
}
|
|
273
|
+
return false;
|
|
274
|
+
})
|
|
275
|
+
.map(({ multiaddr }) => multiaddr.toString()));
|
|
276
|
+
for (const multiaddr of this.dialResults.keys()) {
|
|
277
|
+
if (!unverifiedMultiaddrs.has(multiaddr)) {
|
|
278
|
+
this.log.trace('remove results for %a', multiaddr);
|
|
279
|
+
this.dialResults.delete(multiaddr);
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* Our multicodec topology noticed a new peer that supports autonat
|
|
285
|
+
*/
|
|
286
|
+
async verifyExternalAddresses(connection) {
|
|
287
|
+
// do nothing if we are not running
|
|
288
|
+
if (!this.isStarted()) {
|
|
289
|
+
return;
|
|
290
|
+
}
|
|
291
|
+
// perform cleanup
|
|
292
|
+
this.removeOutdatedMultiaddrResults();
|
|
293
|
+
const peer = await this.components.peerStore.get(connection.remotePeer);
|
|
294
|
+
// if the remote peer has IPv6 addresses, we can probably send them an IPv6
|
|
295
|
+
// address to verify, otherwise only send them IPv4 addresses
|
|
296
|
+
const supportsIPv6 = peer.addresses.some(({ multiaddr }) => {
|
|
297
|
+
return multiaddr.toOptions().family === 6;
|
|
298
|
+
});
|
|
299
|
+
// get multiaddrs this peer is eligible to verify
|
|
300
|
+
const segment = this.getNetworkSegment(connection.remoteAddr);
|
|
301
|
+
const results = this.getUnverifiedMultiaddrs(segment, supportsIPv6);
|
|
302
|
+
if (results.length === 0) {
|
|
303
|
+
return;
|
|
304
|
+
}
|
|
305
|
+
if (!this.hasConnectionCapacity()) {
|
|
306
|
+
// we are near the max connection limit - any dial attempts from remote
|
|
307
|
+
// peers may be rejected which will get flagged as false dial errors and
|
|
308
|
+
// lead us to un-verify an otherwise reachable address
|
|
309
|
+
if (results[0]?.lastVerified != null) {
|
|
310
|
+
this.log('automatically re-verifying %a because we are too close to the connection limit', results[0].multiaddr);
|
|
311
|
+
this.confirmAddress(results[0]);
|
|
312
|
+
}
|
|
313
|
+
else {
|
|
314
|
+
this.log('skipping verifying %a because we are too close to the connection limit', results[0]?.multiaddr);
|
|
315
|
+
}
|
|
316
|
+
return;
|
|
317
|
+
}
|
|
318
|
+
this.queue.add(async (options) => {
|
|
319
|
+
const signal = anySignal([options.signal, AbortSignal.timeout(this.timeout)]);
|
|
320
|
+
const nonce = BigInt(randomNumber(0, Number.MAX_SAFE_INTEGER));
|
|
321
|
+
this.nonces.add(nonce);
|
|
322
|
+
try {
|
|
323
|
+
await this.askPeerToVerify(connection, segment, nonce, options);
|
|
324
|
+
}
|
|
325
|
+
finally {
|
|
326
|
+
signal.clear();
|
|
327
|
+
this.nonces.delete(nonce);
|
|
328
|
+
}
|
|
329
|
+
}, {
|
|
330
|
+
peerId: connection.remotePeer
|
|
331
|
+
})
|
|
332
|
+
.catch(err => {
|
|
333
|
+
this.log.error('error from %p verifying addresses - %e', connection.remotePeer, err);
|
|
334
|
+
});
|
|
335
|
+
}
|
|
336
|
+
async askPeerToVerify(connection, segment, nonce, options) {
|
|
337
|
+
const unverifiedAddresses = [...this.dialResults.values()]
|
|
338
|
+
.filter(entry => entry.result == null)
|
|
339
|
+
.map(entry => entry.multiaddr);
|
|
340
|
+
if (unverifiedAddresses.length === 0) {
|
|
341
|
+
// no unverified addresses
|
|
342
|
+
this.queue.clear();
|
|
343
|
+
return;
|
|
344
|
+
}
|
|
345
|
+
this.log.trace('asking %p to verify multiaddrs %s', connection.remotePeer, unverifiedAddresses);
|
|
346
|
+
const stream = await connection.newStream(this.dialRequestProtocol, options);
|
|
347
|
+
try {
|
|
348
|
+
const messages = pbStream(stream).pb(Message);
|
|
349
|
+
await messages.write({
|
|
350
|
+
dialRequest: {
|
|
351
|
+
addrs: unverifiedAddresses.map(ma => ma.bytes),
|
|
352
|
+
nonce
|
|
353
|
+
}
|
|
354
|
+
}, options);
|
|
355
|
+
while (true) {
|
|
356
|
+
let response = await messages.read(options);
|
|
357
|
+
if (response.dialDataRequest != null) {
|
|
358
|
+
if (response.dialDataRequest.numBytes > this.maxDialDataBytes) {
|
|
359
|
+
this.log('too many dial data byte requested by %p - %s/%s', connection.remotePeer, response.dialDataRequest.numBytes, this.maxDialDataBytes);
|
|
360
|
+
continue;
|
|
361
|
+
}
|
|
362
|
+
this.log('sending %d bytes to %p as anti-amplification attack protection', response.dialDataRequest.numBytes, connection.remotePeer);
|
|
363
|
+
const buf = new Uint8Array(this.dialDataChunkSize);
|
|
364
|
+
const bufSize = BigInt(this.dialDataChunkSize);
|
|
365
|
+
for (let i = 0n; i < response.dialDataRequest.numBytes; i += bufSize) {
|
|
366
|
+
await messages.write({
|
|
367
|
+
dialDataResponse: {
|
|
368
|
+
data: buf
|
|
369
|
+
}
|
|
370
|
+
}, options);
|
|
371
|
+
}
|
|
372
|
+
response = await messages.read(options);
|
|
373
|
+
}
|
|
374
|
+
if (response.dialResponse == null) {
|
|
375
|
+
this.log('invalid autonat response from %p - %j', connection.remotePeer, response);
|
|
376
|
+
return;
|
|
377
|
+
}
|
|
378
|
+
const status = response.dialResponse.status;
|
|
379
|
+
if (status !== DialResponse.ResponseStatus.OK) {
|
|
380
|
+
return;
|
|
381
|
+
}
|
|
382
|
+
const dialed = unverifiedAddresses[response.dialResponse.addrIdx];
|
|
383
|
+
if (dialed == null) {
|
|
384
|
+
this.log.trace('peer dialed unknown address');
|
|
385
|
+
continue;
|
|
386
|
+
}
|
|
387
|
+
const results = this.dialResults.get(dialed.toString());
|
|
388
|
+
if (results == null) {
|
|
389
|
+
this.log.trace('peer reported %a as %s but there is no result object', dialed, response.dialResponse.status);
|
|
390
|
+
continue;
|
|
391
|
+
}
|
|
392
|
+
if (results.networkSegments.includes(segment)) {
|
|
393
|
+
this.log.trace('%a results already included network segment %s', dialed, segment);
|
|
394
|
+
continue;
|
|
395
|
+
}
|
|
396
|
+
if (results.result != null) {
|
|
397
|
+
this.log.trace('already resolved result for %a, ignoring response from', dialed, connection.remotePeer);
|
|
398
|
+
continue;
|
|
399
|
+
}
|
|
400
|
+
if (results.verifyingPeers.has(connection.remotePeer)) {
|
|
401
|
+
this.log.trace('peer %p has already verified %a, ignoring response', connection.remotePeer, dialed);
|
|
402
|
+
continue;
|
|
403
|
+
}
|
|
404
|
+
results.verifyingPeers.add(connection.remotePeer);
|
|
405
|
+
results.networkSegments.push(segment);
|
|
406
|
+
if (response.dialResponse.dialStatus === DialStatus.OK) {
|
|
407
|
+
this.log.trace('%p dialed %a successfully', connection.remotePeer, results.multiaddr);
|
|
408
|
+
results.success++;
|
|
409
|
+
// observed addresses require more confirmations
|
|
410
|
+
if (results.type !== 'observed') {
|
|
411
|
+
this.confirmAddress(results);
|
|
412
|
+
continue;
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
else if (response.dialResponse.dialStatus === DialStatus.E_DIAL_ERROR) {
|
|
416
|
+
this.log.trace('%p could not dial %a', connection.remotePeer, results.multiaddr);
|
|
417
|
+
// the address was not dialable (e.g. not public)
|
|
418
|
+
results.failure++;
|
|
419
|
+
}
|
|
420
|
+
else if (response.dialResponse.dialStatus === DialStatus.E_DIAL_BACK_ERROR) {
|
|
421
|
+
this.log.trace('%p saw error while dialing %a', connection.remotePeer, results.multiaddr);
|
|
422
|
+
// the address was dialable but an error occurred during the dial back
|
|
423
|
+
continue;
|
|
424
|
+
}
|
|
425
|
+
this.log('%a success %d failure %d', results.multiaddr, results.success, results.failure);
|
|
426
|
+
if (results.success === REQUIRED_SUCCESSFUL_DIALS) {
|
|
427
|
+
this.confirmAddress(results);
|
|
428
|
+
}
|
|
429
|
+
if (results.failure === REQUIRED_FAILED_DIALS) {
|
|
430
|
+
this.unconfirmAddress(results);
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
finally {
|
|
435
|
+
try {
|
|
436
|
+
await stream.close(options);
|
|
437
|
+
}
|
|
438
|
+
catch (err) {
|
|
439
|
+
stream.abort(err);
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
hasConnectionCapacity() {
|
|
444
|
+
const connections = this.components.connectionManager.getConnections();
|
|
445
|
+
const currentConnectionCount = connections.length;
|
|
446
|
+
const maxConnections = this.components.connectionManager.getMaxConnections();
|
|
447
|
+
return ((currentConnectionCount / maxConnections) * 100) < this.connectionThreshold;
|
|
448
|
+
}
|
|
449
|
+
confirmAddress(results) {
|
|
450
|
+
// we are now convinced
|
|
451
|
+
this.log('%s address %a is externally dialable', results.type, results.multiaddr);
|
|
452
|
+
this.components.addressManager.confirmObservedAddr(results.multiaddr);
|
|
453
|
+
this.dialResults.delete(results.multiaddr.toString());
|
|
454
|
+
// abort & remove any outstanding verification jobs for this multiaddr
|
|
455
|
+
results.result = true;
|
|
456
|
+
}
|
|
457
|
+
unconfirmAddress(results) {
|
|
458
|
+
// we are now unconvinced
|
|
459
|
+
this.log('%s address %a is not externally dialable', results.type, results.multiaddr);
|
|
460
|
+
this.components.addressManager.removeObservedAddr(results.multiaddr);
|
|
461
|
+
this.dialResults.delete(results.multiaddr.toString());
|
|
462
|
+
// abort & remove any outstanding verification jobs for this multiaddr
|
|
463
|
+
results.result = false;
|
|
464
|
+
}
|
|
465
|
+
getNetworkSegment(ma) {
|
|
466
|
+
// make sure we use different network segments
|
|
467
|
+
const options = ma.toOptions();
|
|
468
|
+
if (options.family === 4) {
|
|
469
|
+
const octets = options.host.split('.');
|
|
470
|
+
return octets[0].padStart(3, '0');
|
|
471
|
+
}
|
|
472
|
+
const octets = options.host.split(':');
|
|
473
|
+
return octets[0].padStart(4, '0');
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAA;AAC3F,OAAO,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAA;AAClD,OAAO,EAAE,0BAA0B,EAAE,MAAM,uBAAuB,CAAA;AAClE,OAAO,EAAE,eAAe,EAAE,MAAM,2CAA2C,CAAA;AAC3E,OAAO,EAAE,SAAS,EAAE,MAAM,oCAAoC,CAAA;AAC9D,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAA;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAA;AAC5D,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAA;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AACtC,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAC5C,OAAO,EAAE,4BAA4B,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAA;AAC9K,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAE,YAAY,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAC7F,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AASzC,+EAA+E;AAC/E,gEAAgE;AAChE,qFAAqF;AACrF,MAAM,yBAAyB,GAAG,CAAC,CAAA;AACnC,M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AAC;CACF"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The prefix to use in the protocol
|
|
3
|
+
*/
|
|
4
|
+
export declare const PROTOCOL_PREFIX = "libp2p";
|
|
5
|
+
/**
|
|
6
|
+
* The name to use in the protocol
|
|
7
|
+
*/
|
|
8
|
+
export declare const PROTOCOL_NAME = "autonat";
|
|
9
|
+
/**
|
|
10
|
+
* The version to use in the protocol
|
|
11
|
+
*/
|
|
12
|
+
export declare const PROTOCOL_VERSION = "2";
|
|
13
|
+
export declare const TIMEOUT = 30000;
|
|
14
|
+
export declare const MAX_INBOUND_STREAMS = 2;
|
|
15
|
+
export declare const MAX_OUTBOUND_STREAMS = 20;
|
|
16
|
+
export declare const DEFAULT_CONNECTION_THRESHOLD = 80;
|
|
17
|
+
export declare const MAX_MESSAGE_SIZE = 8192;
|
|
18
|
+
export declare const DIAL_REQUEST = "dial-request";
|
|
19
|
+
export declare const DIAL_BACK = "dial-back";
|
|
20
|
+
export declare const MAX_DIAL_DATA_BYTES: bigint;
|
|
21
|
+
export declare const DIAL_DATA_CHUNK_SIZE = 4096;
|
|
22
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,eAAe,WAAW,CAAA;AAEvC;;GAEG;AACH,eAAO,MAAM,aAAa,YAAY,CAAA;AAEtC;;GAEG;AACH,eAAO,MAAM,gBAAgB,MAAM,CAAA;AACnC,eAAO,MAAM,OAAO,QAAS,CAAA;AAC7B,eAAO,MAAM,mBAAmB,IAAI,CAAA;AACpC,eAAO,MAAM,oBAAoB,KAAK,CAAA;AACtC,eAAO,MAAM,4BAA4B,KAAK,CAAA;AAC9C,eAAO,MAAM,gBAAgB,OAAO,CAAA;AAEpC,eAAO,MAAM,YAAY,iBAAiB,CAAA;AAC1C,eAAO,MAAM,SAAS,cAAc,CAAA;AACpC,eAAO,MAAM,mBAAmB,QAAe,CAAA;AAC/C,eAAO,MAAM,oBAAoB,OAAO,CAAA"}
|