@libp2p/upnp-nat 2.0.11 → 2.0.12-339b7df88
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/check-external-address.d.ts +4 -4
- package/dist/src/check-external-address.d.ts.map +1 -1
- package/dist/src/check-external-address.js +10 -26
- package/dist/src/check-external-address.js.map +1 -1
- package/dist/src/constants.d.ts +4 -0
- package/dist/src/constants.d.ts.map +1 -0
- package/dist/src/constants.js +4 -0
- package/dist/src/constants.js.map +1 -0
- package/dist/src/gateway-finder.d.ts +26 -0
- package/dist/src/gateway-finder.d.ts.map +1 -0
- package/dist/src/gateway-finder.js +48 -0
- package/dist/src/gateway-finder.js.map +1 -0
- package/dist/src/index.d.ts +12 -47
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/upnp-nat.d.ts +11 -24
- package/dist/src/upnp-nat.d.ts.map +1 -1
- package/dist/src/upnp-nat.js +56 -175
- package/dist/src/upnp-nat.js.map +1 -1
- package/dist/src/upnp-port-mapper.d.ts +38 -0
- package/dist/src/upnp-port-mapper.d.ts.map +1 -0
- package/dist/src/upnp-port-mapper.js +166 -0
- package/dist/src/upnp-port-mapper.js.map +1 -0
- package/package.json +11 -11
- package/src/check-external-address.ts +14 -34
- package/src/constants.ts +3 -0
- package/src/gateway-finder.ts +70 -0
- package/src/index.ts +13 -53
- package/src/upnp-nat.ts +60 -213
- package/src/upnp-port-mapper.ts +223 -0
- package/LICENSE +0 -4
- package/dist/typedoc-urls.json +0 -12
package/dist/src/upnp-nat.js
CHANGED
|
@@ -1,82 +1,49 @@
|
|
|
1
1
|
import { upnpNat } from '@achingbrain/nat-port-mapper';
|
|
2
|
-
import {
|
|
3
|
-
import { InvalidParametersError, serviceCapabilities, serviceDependencies, start, stop } from '@libp2p/interface';
|
|
2
|
+
import { serviceCapabilities, setMaxListeners, start, stop } from '@libp2p/interface';
|
|
4
3
|
import { debounce } from '@libp2p/utils/debounce';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { multiaddr } from '@multiformats/multiaddr';
|
|
9
|
-
import { QUICV1, TCP, WebSockets, WebSocketsSecure, WebTransport } from '@multiformats/multiaddr-matcher';
|
|
10
|
-
import { raceSignal } from 'race-signal';
|
|
11
|
-
import { dynamicExternalAddress, staticExternalAddress } from './check-external-address.js';
|
|
12
|
-
import { DoubleNATError, InvalidIPAddressError } from './errors.js';
|
|
13
|
-
const DEFAULT_TTL = 7200;
|
|
4
|
+
import { DEFAULT_PORT_MAPPING_TTL } from './constants.js';
|
|
5
|
+
import { GatewayFinder } from './gateway-finder.js';
|
|
6
|
+
import { UPnPPortMapper } from './upnp-port-mapper.js';
|
|
14
7
|
export class UPnPNAT {
|
|
15
|
-
client;
|
|
16
|
-
addressManager;
|
|
17
|
-
events;
|
|
18
|
-
externalAddress;
|
|
19
|
-
localAddress;
|
|
20
|
-
description;
|
|
21
|
-
ttl;
|
|
22
|
-
keepAlive;
|
|
23
|
-
gateway;
|
|
24
|
-
started;
|
|
25
8
|
log;
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
9
|
+
components;
|
|
10
|
+
init;
|
|
11
|
+
started;
|
|
12
|
+
portMappingClient;
|
|
13
|
+
shutdownController;
|
|
14
|
+
mapIpAddressesDebounced;
|
|
15
|
+
gatewayFinder;
|
|
16
|
+
portMappers;
|
|
30
17
|
constructor(components, init) {
|
|
31
18
|
this.log = components.logger.forComponent('libp2p:upnp-nat');
|
|
32
|
-
this.
|
|
33
|
-
this.
|
|
19
|
+
this.components = components;
|
|
20
|
+
this.init = init;
|
|
34
21
|
this.started = false;
|
|
35
|
-
this.
|
|
36
|
-
this.
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
this.gatewayDetectionTimeout = init.gatewayDetectionTimeout ?? 10000;
|
|
41
|
-
this.autoConfirmAddress = init.autoConfirmAddress ?? false;
|
|
42
|
-
this.mappedPorts = new Map();
|
|
43
|
-
if (this.ttl < DEFAULT_TTL) {
|
|
44
|
-
throw new InvalidParametersError(`NatManager ttl should be at least ${DEFAULT_TTL} seconds`);
|
|
45
|
-
}
|
|
46
|
-
this.client = init.client ?? upnpNat({
|
|
47
|
-
description: this.description,
|
|
48
|
-
ttl: this.ttl,
|
|
49
|
-
keepAlive: this.keepAlive,
|
|
50
|
-
gateway: this.gateway
|
|
22
|
+
this.portMappers = [];
|
|
23
|
+
this.portMappingClient = init.portMappingClient ?? upnpNat({
|
|
24
|
+
description: init.portMappingDescription ?? `${components.nodeInfo.name}@${components.nodeInfo.version} ${components.peerId.toString()}`,
|
|
25
|
+
ttl: init.portMappingTTL ?? DEFAULT_PORT_MAPPING_TTL,
|
|
26
|
+
autoRefresh: init.portMappingAutoRefresh ?? true
|
|
51
27
|
});
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
}
|
|
28
|
+
// trigger update when our addresses change
|
|
29
|
+
this.mapIpAddressesDebounced = debounce(async () => {
|
|
30
|
+
try {
|
|
31
|
+
await this.mapIpAddresses();
|
|
32
|
+
}
|
|
33
|
+
catch (err) {
|
|
34
|
+
this.log.error('error mapping IP addresses - %e', err);
|
|
35
|
+
}
|
|
36
|
+
}, 5_000);
|
|
37
|
+
// trigger update when we discovery gateways on the network
|
|
38
|
+
this.gatewayFinder = new GatewayFinder(components, {
|
|
39
|
+
portMappingClient: this.portMappingClient
|
|
40
|
+
});
|
|
41
|
+
this.onGatewayDiscovered = this.onGatewayDiscovered.bind(this);
|
|
67
42
|
}
|
|
68
43
|
[Symbol.toStringTag] = '@libp2p/upnp-nat';
|
|
69
44
|
[serviceCapabilities] = [
|
|
70
45
|
'@libp2p/nat-traversal'
|
|
71
46
|
];
|
|
72
|
-
get [serviceDependencies]() {
|
|
73
|
-
if (!this.autoConfirmAddress) {
|
|
74
|
-
return [
|
|
75
|
-
'@libp2p/autonat'
|
|
76
|
-
];
|
|
77
|
-
}
|
|
78
|
-
return [];
|
|
79
|
-
}
|
|
80
47
|
isStarted() {
|
|
81
48
|
return this.started;
|
|
82
49
|
}
|
|
@@ -85,126 +52,40 @@ export class UPnPNAT {
|
|
|
85
52
|
return;
|
|
86
53
|
}
|
|
87
54
|
this.started = true;
|
|
88
|
-
this.
|
|
89
|
-
|
|
55
|
+
this.shutdownController = new AbortController();
|
|
56
|
+
setMaxListeners(Infinity, this.shutdownController.signal);
|
|
57
|
+
this.components.events.addEventListener('self:peer:update', this.mapIpAddressesDebounced);
|
|
58
|
+
this.gatewayFinder.addEventListener('gateway', this.onGatewayDiscovered);
|
|
59
|
+
await start(this.mapIpAddressesDebounced, this.gatewayFinder, ...this.portMappers);
|
|
90
60
|
}
|
|
91
61
|
/**
|
|
92
62
|
* Stops the NAT manager
|
|
93
63
|
*/
|
|
94
64
|
async stop() {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
this.log.error(err);
|
|
100
|
-
}
|
|
101
|
-
this.events.removeEventListener('self:peer:update', this.onSelfPeerUpdate);
|
|
102
|
-
await stop(this.externalAddress, this.onSelfPeerUpdate);
|
|
65
|
+
this.shutdownController?.abort();
|
|
66
|
+
this.components.events.removeEventListener('self:peer:update', this.mapIpAddressesDebounced);
|
|
67
|
+
this.gatewayFinder.removeEventListener('gateway', this.onGatewayDiscovered);
|
|
68
|
+
await stop(this.mapIpAddressesDebounced, this.gatewayFinder, ...this.portMappers);
|
|
103
69
|
this.started = false;
|
|
104
70
|
}
|
|
105
|
-
|
|
106
|
-
this.
|
|
107
|
-
.
|
|
108
|
-
|
|
71
|
+
onGatewayDiscovered(event) {
|
|
72
|
+
const mapper = new UPnPPortMapper(this.components, {
|
|
73
|
+
...this.init,
|
|
74
|
+
gateway: event.detail
|
|
109
75
|
});
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
continue;
|
|
117
|
-
}
|
|
118
|
-
// ignore loopback
|
|
119
|
-
if (isLoopback(ma)) {
|
|
120
|
-
continue;
|
|
121
|
-
}
|
|
122
|
-
// only IP based addresses
|
|
123
|
-
if (!(TCP.exactMatch(ma) ||
|
|
124
|
-
WebSockets.exactMatch(ma) ||
|
|
125
|
-
WebSocketsSecure.exactMatch(ma) ||
|
|
126
|
-
QUICV1.exactMatch(ma) ||
|
|
127
|
-
WebTransport.exactMatch(ma))) {
|
|
128
|
-
continue;
|
|
129
|
-
}
|
|
130
|
-
const { port, family } = ma.toOptions();
|
|
131
|
-
if (family !== ipType) {
|
|
132
|
-
continue;
|
|
133
|
-
}
|
|
134
|
-
if (this.mappedPorts.has(port)) {
|
|
135
|
-
continue;
|
|
136
|
-
}
|
|
137
|
-
output.push(ma);
|
|
138
|
-
}
|
|
139
|
-
return output;
|
|
76
|
+
this.portMappers.push(mapper);
|
|
77
|
+
start(mapper)
|
|
78
|
+
.then(() => {
|
|
79
|
+
this.mapIpAddressesDebounced();
|
|
80
|
+
})
|
|
81
|
+
.catch(() => { });
|
|
140
82
|
}
|
|
141
83
|
async mapIpAddresses() {
|
|
142
|
-
|
|
143
|
-
this.
|
|
144
|
-
}
|
|
145
|
-
const publicIp = await this.externalAddress.getPublicIp({
|
|
146
|
-
signal: AbortSignal.timeout(this.gatewayDetectionTimeout)
|
|
147
|
-
});
|
|
148
|
-
this.externalAddress ?? await raceSignal(this.client.externalIp(), AbortSignal.timeout(this.gatewayDetectionTimeout), {
|
|
149
|
-
errorMessage: `Did not discover a "urn:schemas-upnp-org:device:InternetGatewayDevice:1" device on the local network after ${this.gatewayDetectionTimeout}ms - UPnP may not be configured on your router correctly`
|
|
150
|
-
});
|
|
151
|
-
let ipType = 4;
|
|
152
|
-
if (isIPv4(publicIp)) {
|
|
153
|
-
ipType = 4;
|
|
154
|
-
}
|
|
155
|
-
else if (isIPv6(publicIp)) {
|
|
156
|
-
ipType = 6;
|
|
157
|
-
}
|
|
158
|
-
else {
|
|
159
|
-
throw new InvalidIPAddressError(`Public address ${publicIp} was not an IPv4 address`);
|
|
160
|
-
}
|
|
161
|
-
// filter addresses to get private, non-relay, IP based addresses that we
|
|
162
|
-
// haven't mapped yet
|
|
163
|
-
const addresses = this.getUnmappedAddresses(this.addressManager.getAddresses(), ipType);
|
|
164
|
-
if (addresses.length === 0) {
|
|
165
|
-
this.log('no private, non-relay, unmapped, IP based addresses found');
|
|
166
|
-
return;
|
|
167
|
-
}
|
|
168
|
-
this.log('%s public IP %s', this.externalAddress != null ? 'using configured' : 'discovered', publicIp);
|
|
169
|
-
this.assertNotBehindDoubleNAT(publicIp);
|
|
170
|
-
for (const addr of addresses) {
|
|
171
|
-
// try to open uPnP ports for each thin waist address
|
|
172
|
-
const { family, host, port, transport } = addr.toOptions();
|
|
173
|
-
if (family === 6) {
|
|
174
|
-
// only support IPv4 addresses
|
|
175
|
-
continue;
|
|
176
|
-
}
|
|
177
|
-
if (this.mappedPorts.has(port)) {
|
|
178
|
-
// already mapped this port
|
|
179
|
-
continue;
|
|
180
|
-
}
|
|
181
|
-
const protocol = transport.toUpperCase();
|
|
182
|
-
this.log(`creating mapping of ${host}:${port}`);
|
|
183
|
-
const mappedPort = await this.client.map(port, {
|
|
184
|
-
localAddress: host,
|
|
185
|
-
protocol: protocol === 'TCP' ? 'TCP' : 'UDP'
|
|
186
|
-
});
|
|
187
|
-
this.mappedPorts.set(port, mappedPort);
|
|
188
|
-
const ma = multiaddr(addr.toString().replace(`/ip${family}/${host}/${transport}/${port}`, `/ip${family}/${publicIp}/${transport}/${mappedPort}`));
|
|
189
|
-
this.log(`created mapping of ${publicIp}:${mappedPort} to ${host}:${port} as %a`, ma);
|
|
190
|
-
if (this.autoConfirmAddress) {
|
|
191
|
-
this.addressManager.confirmObservedAddr(ma);
|
|
192
|
-
}
|
|
193
|
-
else {
|
|
194
|
-
this.addressManager.addObservedAddr(ma);
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
/**
|
|
199
|
-
* Some ISPs have double-NATs, there's not much we can do with them
|
|
200
|
-
*/
|
|
201
|
-
assertNotBehindDoubleNAT(publicIp) {
|
|
202
|
-
const isPrivate = isPrivateIp(publicIp);
|
|
203
|
-
if (isPrivate === true) {
|
|
204
|
-
throw new DoubleNATError(`${publicIp} is private - please set config.nat.externalIp to an externally routable IP or ensure you are not behind a double NAT`);
|
|
84
|
+
try {
|
|
85
|
+
await Promise.all(this.portMappers.map(async (mapper) => mapper.mapIpAddresses()));
|
|
205
86
|
}
|
|
206
|
-
|
|
207
|
-
|
|
87
|
+
catch (err) {
|
|
88
|
+
this.log.error('error mapping IP addresses - %e', err);
|
|
208
89
|
}
|
|
209
90
|
}
|
|
210
91
|
}
|
package/dist/src/upnp-nat.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"upnp-nat.js","sourceRoot":"","sources":["../../src/upnp-nat.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,8BAA8B,CAAA;AACtD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"upnp-nat.js","sourceRoot":"","sources":["../../src/upnp-nat.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,8BAA8B,CAAA;AACtD,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAA;AACrF,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAA;AACjD,OAAO,EAAE,wBAAwB,EAAE,MAAM,gBAAgB,CAAA;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAMtD,MAAM,OAAO,OAAO;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AC,aAAa,EAAE,GAAG,IAAI,CAAC,WAAW,CAAC,CAAA;QACjF,IAAI,CAAC,OAAO,GAAG,KAAK,CAAA;IACtB,CAAC;IAED,mBAAmB,CAAE,KAA2B;QAC9C,MAAM,MAAM,GAAG,IAAI,cAAc,CAAC,IAAI,CAAC,UAAU,EAAE;YACjD,GAAG,IAAI,CAAC,IAAI;YACZ,OAAO,EAAE,KAAK,CAAC,MAAM;SACtB,CAAC,CAAA;QAEF,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;QAE7B,KAAK,CAAC,MAAM,CAAC;aACV,IAAI,CAAC,GAAG,EAAE;YACT,IAAI,CAAC,uBAAuB,EAAE,CAAA;QAChC,CAAC,CAAC;aACD,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAA;IACpB,CAAC;IAED,KAAK,CAAC,cAAc;QAClB,IAAI,CAAC;YACH,MAAM,OAAO,CAAC,GAAG,CACf,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,KAAK,EAAC,MAAM,EAAC,EAAE,CAAC,MAAM,CAAC,cAAc,EAAE,CAAC,CAC9D,CAAA;QACH,CAAC;QAAC,OAAO,GAAQ,EAAE,CAAC;YAClB,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,iCAAiC,EAAE,GAAG,CAAC,CAAA;QACxD,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { Gateway } from '@achingbrain/nat-port-mapper';
|
|
2
|
+
import type { ComponentLogger } from '@libp2p/interface';
|
|
3
|
+
import type { AddressManager } from '@libp2p/interface-internal';
|
|
4
|
+
export interface UPnPPortMapperInit {
|
|
5
|
+
gateway: Gateway;
|
|
6
|
+
externalAddressCheckInterval?: number;
|
|
7
|
+
externalAddressCheckTimeout?: number;
|
|
8
|
+
}
|
|
9
|
+
export interface UPnPPortMapperComponents {
|
|
10
|
+
logger: ComponentLogger;
|
|
11
|
+
addressManager: AddressManager;
|
|
12
|
+
}
|
|
13
|
+
export declare class UPnPPortMapper {
|
|
14
|
+
private readonly gateway;
|
|
15
|
+
private readonly externalAddress;
|
|
16
|
+
private readonly addressManager;
|
|
17
|
+
private readonly log;
|
|
18
|
+
private readonly mappedPorts;
|
|
19
|
+
private started;
|
|
20
|
+
constructor(components: UPnPPortMapperComponents, init: UPnPPortMapperInit);
|
|
21
|
+
start(): Promise<void>;
|
|
22
|
+
stop(): Promise<void>;
|
|
23
|
+
/**
|
|
24
|
+
* Update the local address mappings when the gateway's external interface
|
|
25
|
+
* address changes
|
|
26
|
+
*/
|
|
27
|
+
private remapPorts;
|
|
28
|
+
/**
|
|
29
|
+
* Return any eligible multiaddrs that are not mapped on the detected gateway
|
|
30
|
+
*/
|
|
31
|
+
private getUnmappedAddresses;
|
|
32
|
+
mapIpAddresses(): Promise<void>;
|
|
33
|
+
/**
|
|
34
|
+
* Some ISPs have double-NATs, there's not much we can do with them
|
|
35
|
+
*/
|
|
36
|
+
private assertNotBehindDoubleNAT;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=upnp-port-mapper.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"upnp-port-mapper.d.ts","sourceRoot":"","sources":["../../src/upnp-port-mapper.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,8BAA8B,CAAA;AAC3D,OAAO,KAAK,EAAE,eAAe,EAAU,MAAM,mBAAmB,CAAA;AAChE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAA;AAGhE,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,OAAO,CAAA;IAChB,4BAA4B,CAAC,EAAE,MAAM,CAAA;IACrC,2BAA2B,CAAC,EAAE,MAAM,CAAA;CACrC;AAED,MAAM,WAAW,wBAAwB;IACvC,MAAM,EAAE,eAAe,CAAA;IACvB,cAAc,EAAE,cAAc,CAAA;CAC/B;AAOD,qBAAa,cAAc;IACzB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAiB;IACjD,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAgB;IAC/C,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAQ;IAC5B,OAAO,CAAC,QAAQ,CAAC,WAAW,CAA0B;IACtD,OAAO,CAAC,OAAO,CAAS;gBAEX,UAAU,EAAE,wBAAwB,EAAE,IAAI,EAAE,kBAAkB;IAkBrE,KAAK,IAAK,OAAO,CAAC,IAAI,CAAC;IASvB,IAAI,IAAK,OAAO,CAAC,IAAI,CAAC;IAe5B;;;OAGG;IACH,OAAO,CAAC,UAAU;IAalB;;OAEG;IACH,OAAO,CAAC,oBAAoB;IAyCtB,cAAc,IAAK,OAAO,CAAC,IAAI,CAAC;IAmEtC;;OAEG;IACH,OAAO,CAAC,wBAAwB;CAWjC"}
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import { isIPv4, isIPv6 } from '@chainsafe/is-ip';
|
|
2
|
+
import { InvalidParametersError, start, stop } from '@libp2p/interface';
|
|
3
|
+
import { isLoopback } from '@libp2p/utils/multiaddr/is-loopback';
|
|
4
|
+
import { isPrivate } from '@libp2p/utils/multiaddr/is-private';
|
|
5
|
+
import { isPrivateIp } from '@libp2p/utils/private-ip';
|
|
6
|
+
import { QUICV1, TCP, WebSockets, WebSocketsSecure, WebTransport } from '@multiformats/multiaddr-matcher';
|
|
7
|
+
import { dynamicExternalAddress } from './check-external-address.js';
|
|
8
|
+
import { DoubleNATError, InvalidIPAddressError } from './errors.js';
|
|
9
|
+
export class UPnPPortMapper {
|
|
10
|
+
gateway;
|
|
11
|
+
externalAddress;
|
|
12
|
+
addressManager;
|
|
13
|
+
log;
|
|
14
|
+
mappedPorts;
|
|
15
|
+
started;
|
|
16
|
+
constructor(components, init) {
|
|
17
|
+
this.log = components.logger.forComponent(`libp2p:upnp-nat:gateway:${init.gateway.id}`);
|
|
18
|
+
this.addressManager = components.addressManager;
|
|
19
|
+
this.gateway = init.gateway;
|
|
20
|
+
this.externalAddress = dynamicExternalAddress({
|
|
21
|
+
gateway: this.gateway,
|
|
22
|
+
addressManager: this.addressManager,
|
|
23
|
+
logger: components.logger
|
|
24
|
+
}, {
|
|
25
|
+
interval: init.externalAddressCheckInterval,
|
|
26
|
+
timeout: init.externalAddressCheckTimeout,
|
|
27
|
+
onExternalAddressChange: this.remapPorts.bind(this)
|
|
28
|
+
});
|
|
29
|
+
this.gateway = init.gateway;
|
|
30
|
+
this.mappedPorts = new Map();
|
|
31
|
+
this.started = false;
|
|
32
|
+
}
|
|
33
|
+
async start() {
|
|
34
|
+
if (this.started) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
await start(this.externalAddress);
|
|
38
|
+
this.started = true;
|
|
39
|
+
}
|
|
40
|
+
async stop() {
|
|
41
|
+
try {
|
|
42
|
+
const shutdownTimeout = AbortSignal.timeout(1000);
|
|
43
|
+
await this.gateway.stop({
|
|
44
|
+
signal: shutdownTimeout
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
catch (err) {
|
|
48
|
+
this.log.error('error closing gateway - %e', err);
|
|
49
|
+
}
|
|
50
|
+
await stop(this.externalAddress);
|
|
51
|
+
this.started = false;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Update the local address mappings when the gateway's external interface
|
|
55
|
+
* address changes
|
|
56
|
+
*/
|
|
57
|
+
remapPorts(newExternalHost) {
|
|
58
|
+
for (const [key, { externalHost, externalPort }] of this.mappedPorts.entries()) {
|
|
59
|
+
const [host, port, transport] = key.split('-');
|
|
60
|
+
this.addressManager.removePublicAddressMapping(host, parseInt(port), externalHost, externalPort, transport === 'tcp' ? 'tcp' : 'udp');
|
|
61
|
+
this.addressManager.addPublicAddressMapping(host, parseInt(port), newExternalHost, externalPort, transport === 'tcp' ? 'tcp' : 'udp');
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Return any eligible multiaddrs that are not mapped on the detected gateway
|
|
66
|
+
*/
|
|
67
|
+
getUnmappedAddresses(multiaddrs, ipType) {
|
|
68
|
+
const output = [];
|
|
69
|
+
for (const ma of multiaddrs) {
|
|
70
|
+
// ignore public addresses
|
|
71
|
+
if (!isPrivate(ma)) {
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
// ignore loopback
|
|
75
|
+
if (isLoopback(ma)) {
|
|
76
|
+
continue;
|
|
77
|
+
}
|
|
78
|
+
// only IP based addresses
|
|
79
|
+
if (!(TCP.exactMatch(ma) ||
|
|
80
|
+
WebSockets.exactMatch(ma) ||
|
|
81
|
+
WebSocketsSecure.exactMatch(ma) ||
|
|
82
|
+
QUICV1.exactMatch(ma) ||
|
|
83
|
+
WebTransport.exactMatch(ma))) {
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
const { port, host, family, transport } = ma.toOptions();
|
|
87
|
+
if (family !== ipType) {
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
90
|
+
if (this.mappedPorts.has(`${host}-${port}-${transport}`)) {
|
|
91
|
+
continue;
|
|
92
|
+
}
|
|
93
|
+
output.push(ma);
|
|
94
|
+
}
|
|
95
|
+
return output;
|
|
96
|
+
}
|
|
97
|
+
async mapIpAddresses() {
|
|
98
|
+
try {
|
|
99
|
+
const externalHost = await this.externalAddress.getPublicIp();
|
|
100
|
+
let ipType = 4;
|
|
101
|
+
if (isIPv4(externalHost)) {
|
|
102
|
+
ipType = 4;
|
|
103
|
+
}
|
|
104
|
+
else if (isIPv6(externalHost)) {
|
|
105
|
+
ipType = 6;
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
throw new InvalidIPAddressError(`Public address ${externalHost} was not an IPv4 address`);
|
|
109
|
+
}
|
|
110
|
+
// filter addresses to get private, non-relay, IP based addresses that we
|
|
111
|
+
// haven't mapped yet
|
|
112
|
+
const addresses = this.getUnmappedAddresses(this.addressManager.getAddresses(), ipType);
|
|
113
|
+
if (addresses.length === 0) {
|
|
114
|
+
this.log('no private, non-relay, unmapped, IP based addresses found');
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
this.log('%s public IP %s', this.externalAddress != null ? 'using configured' : 'discovered', externalHost);
|
|
118
|
+
this.assertNotBehindDoubleNAT(externalHost);
|
|
119
|
+
for (const addr of addresses) {
|
|
120
|
+
// try to open uPnP ports for each thin waist address
|
|
121
|
+
const { family, host, port, transport } = addr.toOptions();
|
|
122
|
+
if (family === 6) {
|
|
123
|
+
// only support IPv4 addresses
|
|
124
|
+
continue;
|
|
125
|
+
}
|
|
126
|
+
if (this.mappedPorts.has(`${host}-${port}-${transport}`)) {
|
|
127
|
+
// already mapped this port
|
|
128
|
+
continue;
|
|
129
|
+
}
|
|
130
|
+
try {
|
|
131
|
+
const key = `${host}-${port}-${transport}`;
|
|
132
|
+
this.log('creating mapping of key %s', key);
|
|
133
|
+
const externalPort = await this.gateway.map(port, {
|
|
134
|
+
localAddress: host,
|
|
135
|
+
protocol: transport === 'tcp' ? 'tcp' : 'udp'
|
|
136
|
+
});
|
|
137
|
+
this.mappedPorts.set(key, {
|
|
138
|
+
externalHost,
|
|
139
|
+
externalPort
|
|
140
|
+
});
|
|
141
|
+
this.log('created mapping of %s:%s to %s:%s', externalHost, externalPort, host, port);
|
|
142
|
+
this.addressManager.addPublicAddressMapping(host, port, externalHost, externalPort, transport === 'tcp' ? 'tcp' : 'udp');
|
|
143
|
+
}
|
|
144
|
+
catch (err) {
|
|
145
|
+
this.log.error('failed to create mapping of %s:%s - %e', host, port, err);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
catch (err) {
|
|
150
|
+
this.log.error('error finding gateways - %e', err);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Some ISPs have double-NATs, there's not much we can do with them
|
|
155
|
+
*/
|
|
156
|
+
assertNotBehindDoubleNAT(publicIp) {
|
|
157
|
+
const isPrivate = isPrivateIp(publicIp);
|
|
158
|
+
if (isPrivate === true) {
|
|
159
|
+
throw new DoubleNATError(`${publicIp} is private - please init uPnPNAT with 'externalAddress' set to an externally routable IP or ensure you are not behind a double NAT`);
|
|
160
|
+
}
|
|
161
|
+
if (isPrivate == null) {
|
|
162
|
+
throw new InvalidParametersError(`${publicIp} is not an IP address`);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
//# sourceMappingURL=upnp-port-mapper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"upnp-port-mapper.js","sourceRoot":"","sources":["../../src/upnp-port-mapper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AACjD,OAAO,EAAE,sBAAsB,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAA;AACvE,OAAO,EAAE,UAAU,EAAE,MAAM,qCAAqC,CAAA;AAChE,OAAO,EAAE,SAAS,EAAE,MAAM,oCAAoC,CAAA;AAC9D,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAA;AACtD,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,UAAU,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAA;AACzG,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAA;AACpE,OAAO,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAA;AAuBnE,MAAM,OAAO,cAAc;IACR,OAAO,CAAS;IAChB,eAAe,CAAiB;IAChC,cAAc,CAAgB;IAC9B,GAAG,CAAQ;IACX,WAAW,CAA0B;IAC9C,OAAO,CAAS;IAExB,YAAa,UAAoC,EAAE,IAAwB;QACzE,IAAI,CAAC,GAAG,GAAG,UAAU,CAAC,MAAM,CAAC,YAAY,CAAC,2BAA2B,IAAI,CAAC,OAAO,CAAC,EAAE,EAAE,CAAC,CAAA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CAAC,CAAC,KAAK,CAAC,CAAA;gBAC1H,CAAC;gBAAC,OAAO,GAAG,EAAE,CAAC;oBACb,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,wCAAwC,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,CAAC,CAAA;gBAC3E,CAAC;YACH,CAAC;QACH,CAAC;QAAC,OAAO,GAAQ,EAAE,CAAC;YAClB,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,6BAA6B,EAAE,GAAG,CAAC,CAAA;QACpD,CAAC;IACH,CAAC;IAED;;OAEG;IACK,wBAAwB,CAAE,QAAgB;QAChD,MAAM,SAAS,GAAG,WAAW,CAAC,QAAQ,CAAC,CAAA;QAEvC,IAAI,SAAS,KAAK,IAAI,EAAE,CAAC;YACvB,MAAM,IAAI,cAAc,CAAC,GAAG,QAAQ,qIAAqI,CAAC,CAAA;QAC5K,CAAC;QAED,IAAI,SAAS,IAAI,IAAI,EAAE,CAAC;YACtB,MAAM,IAAI,sBAAsB,CAAC,GAAG,QAAQ,uBAAuB,CAAC,CAAA;QACtE,CAAC;IACH,CAAC;CACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@libp2p/upnp-nat",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.12-339b7df88",
|
|
4
4
|
"description": "UPnP NAT hole punching",
|
|
5
5
|
"license": "Apache-2.0 OR MIT",
|
|
6
6
|
"homepage": "https://github.com/libp2p/js-libp2p/tree/main/packages/upnp-nat#readme",
|
|
@@ -50,21 +50,21 @@
|
|
|
50
50
|
"test:electron-main": "aegir test -t electron-main"
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
|
-
"@achingbrain/nat-port-mapper": "^
|
|
53
|
+
"@achingbrain/nat-port-mapper": "^3.0.2",
|
|
54
54
|
"@chainsafe/is-ip": "^2.0.2",
|
|
55
|
-
"@libp2p/interface": "
|
|
56
|
-
"@libp2p/interface-internal": "
|
|
57
|
-
"@libp2p/utils": "
|
|
58
|
-
"@multiformats/multiaddr": "^12.
|
|
59
|
-
"@multiformats/multiaddr-matcher": "^1.
|
|
55
|
+
"@libp2p/interface": "2.2.1-339b7df88",
|
|
56
|
+
"@libp2p/interface-internal": "2.1.1-339b7df88",
|
|
57
|
+
"@libp2p/utils": "6.2.1-339b7df88",
|
|
58
|
+
"@multiformats/multiaddr": "^12.3.3",
|
|
59
|
+
"@multiformats/multiaddr-matcher": "^1.6.0",
|
|
60
60
|
"p-defer": "^4.0.1",
|
|
61
61
|
"race-signal": "^1.1.0"
|
|
62
62
|
},
|
|
63
63
|
"devDependencies": {
|
|
64
|
-
"@libp2p/crypto": "
|
|
65
|
-
"@libp2p/logger": "
|
|
66
|
-
"@libp2p/peer-id": "
|
|
67
|
-
"aegir": "^
|
|
64
|
+
"@libp2p/crypto": "5.0.7-339b7df88",
|
|
65
|
+
"@libp2p/logger": "5.1.4-339b7df88",
|
|
66
|
+
"@libp2p/peer-id": "5.0.8-339b7df88",
|
|
67
|
+
"aegir": "^45.0.5",
|
|
68
68
|
"sinon-ts": "^2.0.0"
|
|
69
69
|
},
|
|
70
70
|
"sideEffects": false
|