libp2p 0.46.21 → 1.0.0-551622a96
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +51 -47
- package/dist/index.min.js +40 -28
- package/dist/src/address-manager/index.d.ts +4 -5
- package/dist/src/address-manager/index.d.ts.map +1 -1
- package/dist/src/address-manager/index.js +3 -3
- package/dist/src/address-manager/index.js.map +1 -1
- package/dist/src/components.d.ts +4 -15
- package/dist/src/components.d.ts.map +1 -1
- package/dist/src/components.js +2 -2
- package/dist/src/components.js.map +1 -1
- package/dist/src/config/connection-gater.browser.d.ts +1 -1
- package/dist/src/config/connection-gater.browser.d.ts.map +1 -1
- package/dist/src/config/connection-gater.browser.js.map +1 -1
- package/dist/src/config/connection-gater.d.ts +1 -1
- package/dist/src/config/connection-gater.d.ts.map +1 -1
- package/dist/src/config.d.ts.map +1 -1
- package/dist/src/config.js +1 -2
- package/dist/src/config.js.map +1 -1
- package/dist/src/connection/index.d.ts +4 -6
- package/dist/src/connection/index.d.ts.map +1 -1
- package/dist/src/connection/index.js +11 -13
- package/dist/src/connection/index.js.map +1 -1
- package/dist/src/connection-manager/auto-dial.d.ts +3 -6
- package/dist/src/connection-manager/auto-dial.d.ts.map +1 -1
- package/dist/src/connection-manager/auto-dial.js +21 -21
- package/dist/src/connection-manager/auto-dial.js.map +1 -1
- package/dist/src/connection-manager/connection-pruner.d.ts +3 -5
- package/dist/src/connection-manager/connection-pruner.d.ts.map +1 -1
- package/dist/src/connection-manager/connection-pruner.js +8 -8
- package/dist/src/connection-manager/connection-pruner.js.map +1 -1
- package/dist/src/connection-manager/constants.defaults.d.ts +0 -4
- package/dist/src/connection-manager/constants.defaults.d.ts.map +1 -1
- package/dist/src/connection-manager/constants.defaults.js +0 -4
- package/dist/src/connection-manager/constants.defaults.js.map +1 -1
- package/dist/src/connection-manager/dial-queue.d.ts +3 -10
- package/dist/src/connection-manager/dial-queue.d.ts.map +1 -1
- package/dist/src/connection-manager/dial-queue.js +30 -38
- package/dist/src/connection-manager/dial-queue.js.map +1 -1
- package/dist/src/connection-manager/index.d.ts +3 -18
- package/dist/src/connection-manager/index.d.ts.map +1 -1
- package/dist/src/connection-manager/index.js +17 -18
- package/dist/src/connection-manager/index.js.map +1 -1
- package/dist/src/connection-manager/utils.js +1 -1
- package/dist/src/connection-manager/utils.js.map +1 -1
- package/dist/src/content-routing/index.d.ts +1 -5
- package/dist/src/content-routing/index.d.ts.map +1 -1
- package/dist/src/content-routing/index.js +2 -2
- package/dist/src/content-routing/index.js.map +1 -1
- package/dist/src/content-routing/utils.d.ts +1 -2
- package/dist/src/content-routing/utils.d.ts.map +1 -1
- package/dist/src/content-routing/utils.js +1 -1
- package/dist/src/content-routing/utils.js.map +1 -1
- package/dist/src/errors.d.ts +0 -2
- package/dist/src/errors.d.ts.map +1 -1
- package/dist/src/errors.js +0 -2
- package/dist/src/errors.js.map +1 -1
- package/dist/src/get-peer.d.ts +1 -1
- package/dist/src/get-peer.d.ts.map +1 -1
- package/dist/src/get-peer.js +1 -5
- package/dist/src/get-peer.js.map +1 -1
- package/dist/src/index.d.ts +5 -16
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/libp2p.d.ts +4 -12
- package/dist/src/libp2p.d.ts.map +1 -1
- package/dist/src/libp2p.js +31 -65
- package/dist/src/libp2p.js.map +1 -1
- package/dist/src/peer-routing.d.ts +6 -6
- package/dist/src/peer-routing.d.ts.map +1 -1
- package/dist/src/peer-routing.js +12 -9
- package/dist/src/peer-routing.js.map +1 -1
- package/dist/src/registrar.d.ts +5 -7
- package/dist/src/registrar.d.ts.map +1 -1
- package/dist/src/registrar.js +4 -4
- package/dist/src/registrar.js.map +1 -1
- package/dist/src/transport-manager.d.ts +5 -9
- package/dist/src/transport-manager.d.ts.map +1 -1
- package/dist/src/transport-manager.js +12 -13
- package/dist/src/transport-manager.js.map +1 -1
- package/dist/src/upgrader.d.ts +8 -19
- package/dist/src/upgrader.d.ts.map +1 -1
- package/dist/src/upgrader.js +75 -38
- package/dist/src/upgrader.js.map +1 -1
- package/dist/src/version.d.ts +1 -1
- package/dist/src/version.d.ts.map +1 -1
- package/dist/src/version.js +1 -1
- package/dist/src/version.js.map +1 -1
- package/package.json +37 -106
- package/src/address-manager/index.ts +6 -9
- package/src/components.ts +5 -16
- package/src/config/connection-gater.browser.ts +1 -1
- package/src/config/connection-gater.ts +1 -1
- package/src/config.ts +1 -2
- package/src/connection/index.ts +12 -17
- package/src/connection-manager/auto-dial.ts +23 -26
- package/src/connection-manager/connection-pruner.ts +10 -12
- package/src/connection-manager/constants.defaults.ts +0 -5
- package/src/connection-manager/dial-queue.ts +31 -46
- package/src/connection-manager/index.ts +19 -36
- package/src/connection-manager/utils.ts +1 -1
- package/src/content-routing/index.ts +3 -7
- package/src/content-routing/utils.ts +2 -3
- package/src/errors.ts +0 -2
- package/src/get-peer.ts +2 -7
- package/src/index.ts +6 -17
- package/src/libp2p.ts +32 -80
- package/src/peer-routing.ts +16 -15
- package/src/registrar.ts +8 -12
- package/src/transport-manager.ts +15 -22
- package/src/upgrader.ts +110 -64
- package/src/version.ts +1 -1
- package/dist/src/autonat/constants.d.ts +0 -18
- package/dist/src/autonat/constants.d.ts.map +0 -1
- package/dist/src/autonat/constants.js +0 -18
- package/dist/src/autonat/constants.js.map +0 -1
- package/dist/src/autonat/index.d.ts +0 -62
- package/dist/src/autonat/index.d.ts.map +0 -1
- package/dist/src/autonat/index.js +0 -447
- package/dist/src/autonat/index.js.map +0 -1
- package/dist/src/autonat/pb/index.d.ts +0 -57
- package/dist/src/autonat/pb/index.d.ts.map +0 -1
- package/dist/src/autonat/pb/index.js +0 -250
- package/dist/src/autonat/pb/index.js.map +0 -1
- package/dist/src/circuit-relay/constants.d.ts +0 -50
- package/dist/src/circuit-relay/constants.d.ts.map +0 -1
- package/dist/src/circuit-relay/constants.js +0 -56
- package/dist/src/circuit-relay/constants.js.map +0 -1
- package/dist/src/circuit-relay/index.d.ts +0 -55
- package/dist/src/circuit-relay/index.d.ts.map +0 -1
- package/dist/src/circuit-relay/index.js +0 -38
- package/dist/src/circuit-relay/index.js.map +0 -1
- package/dist/src/circuit-relay/pb/index.d.ts +0 -93
- package/dist/src/circuit-relay/pb/index.d.ts.map +0 -1
- package/dist/src/circuit-relay/pb/index.js +0 -425
- package/dist/src/circuit-relay/pb/index.js.map +0 -1
- package/dist/src/circuit-relay/server/advert-service.d.ts +0 -43
- package/dist/src/circuit-relay/server/advert-service.d.ts.map +0 -1
- package/dist/src/circuit-relay/server/advert-service.js +0 -73
- package/dist/src/circuit-relay/server/advert-service.js.map +0 -1
- package/dist/src/circuit-relay/server/index.d.ts +0 -65
- package/dist/src/circuit-relay/server/index.d.ts.map +0 -1
- package/dist/src/circuit-relay/server/index.js +0 -312
- package/dist/src/circuit-relay/server/index.js.map +0 -1
- package/dist/src/circuit-relay/server/reservation-store.d.ts +0 -49
- package/dist/src/circuit-relay/server/reservation-store.d.ts.map +0 -1
- package/dist/src/circuit-relay/server/reservation-store.js +0 -65
- package/dist/src/circuit-relay/server/reservation-store.js.map +0 -1
- package/dist/src/circuit-relay/server/reservation-voucher.d.ts +0 -18
- package/dist/src/circuit-relay/server/reservation-voucher.d.ts.map +0 -1
- package/dist/src/circuit-relay/server/reservation-voucher.js +0 -36
- package/dist/src/circuit-relay/server/reservation-voucher.js.map +0 -1
- package/dist/src/circuit-relay/transport/discovery.d.ts +0 -45
- package/dist/src/circuit-relay/transport/discovery.d.ts.map +0 -1
- package/dist/src/circuit-relay/transport/discovery.js +0 -97
- package/dist/src/circuit-relay/transport/discovery.js.map +0 -1
- package/dist/src/circuit-relay/transport/index.d.ts +0 -57
- package/dist/src/circuit-relay/transport/index.d.ts.map +0 -1
- package/dist/src/circuit-relay/transport/index.js +0 -276
- package/dist/src/circuit-relay/transport/index.js.map +0 -1
- package/dist/src/circuit-relay/transport/listener.d.ts +0 -9
- package/dist/src/circuit-relay/transport/listener.d.ts.map +0 -1
- package/dist/src/circuit-relay/transport/listener.js +0 -66
- package/dist/src/circuit-relay/transport/listener.js.map +0 -1
- package/dist/src/circuit-relay/transport/reservation-store.d.ts +0 -72
- package/dist/src/circuit-relay/transport/reservation-store.d.ts.map +0 -1
- package/dist/src/circuit-relay/transport/reservation-store.js +0 -209
- package/dist/src/circuit-relay/transport/reservation-store.js.map +0 -1
- package/dist/src/circuit-relay/utils.d.ts +0 -13
- package/dist/src/circuit-relay/utils.d.ts.map +0 -1
- package/dist/src/circuit-relay/utils.js +0 -108
- package/dist/src/circuit-relay/utils.js.map +0 -1
- package/dist/src/dcutr/dcutr.d.ts +0 -43
- package/dist/src/dcutr/dcutr.d.ts.map +0 -1
- package/dist/src/dcutr/dcutr.js +0 -313
- package/dist/src/dcutr/dcutr.js.map +0 -1
- package/dist/src/dcutr/index.d.ts +0 -92
- package/dist/src/dcutr/index.d.ts.map +0 -1
- package/dist/src/dcutr/index.js +0 -63
- package/dist/src/dcutr/index.js.map +0 -1
- package/dist/src/dcutr/pb/message.d.ts +0 -20
- package/dist/src/dcutr/pb/message.d.ts.map +0 -1
- package/dist/src/dcutr/pb/message.js +0 -77
- package/dist/src/dcutr/pb/message.js.map +0 -1
- package/dist/src/dcutr/utils.d.ts +0 -8
- package/dist/src/dcutr/utils.d.ts.map +0 -1
- package/dist/src/dcutr/utils.js +0 -27
- package/dist/src/dcutr/utils.js.map +0 -1
- package/dist/src/fetch/constants.d.ts +0 -3
- package/dist/src/fetch/constants.d.ts.map +0 -1
- package/dist/src/fetch/constants.js +0 -4
- package/dist/src/fetch/constants.js.map +0 -1
- package/dist/src/fetch/index.d.ts +0 -61
- package/dist/src/fetch/index.d.ts.map +0 -1
- package/dist/src/fetch/index.js +0 -205
- package/dist/src/fetch/index.js.map +0 -1
- package/dist/src/fetch/pb/proto.d.ts +0 -28
- package/dist/src/fetch/pb/proto.d.ts.map +0 -1
- package/dist/src/fetch/pb/proto.js +0 -120
- package/dist/src/fetch/pb/proto.js.map +0 -1
- package/dist/src/identify/consts.d.ts +0 -10
- package/dist/src/identify/consts.d.ts.map +0 -1
- package/dist/src/identify/consts.js +0 -11
- package/dist/src/identify/consts.js.map +0 -1
- package/dist/src/identify/identify.d.ts +0 -54
- package/dist/src/identify/identify.d.ts.map +0 -1
- package/dist/src/identify/identify.js +0 -447
- package/dist/src/identify/identify.js.map +0 -1
- package/dist/src/identify/index.d.ts +0 -72
- package/dist/src/identify/index.d.ts.map +0 -1
- package/dist/src/identify/index.js +0 -15
- package/dist/src/identify/index.js.map +0 -1
- package/dist/src/identify/pb/message.d.ts +0 -17
- package/dist/src/identify/pb/message.d.ts.map +0 -1
- package/dist/src/identify/pb/message.js +0 -98
- package/dist/src/identify/pb/message.js.map +0 -1
- package/dist/src/insecure/index.d.ts +0 -26
- package/dist/src/insecure/index.d.ts.map +0 -1
- package/dist/src/insecure/index.js +0 -110
- package/dist/src/insecure/index.js.map +0 -1
- package/dist/src/insecure/pb/proto.d.ts +0 -30
- package/dist/src/insecure/pb/proto.d.ts.map +0 -1
- package/dist/src/insecure/pb/proto.js +0 -127
- package/dist/src/insecure/pb/proto.js.map +0 -1
- package/dist/src/ping/constants.d.ts +0 -9
- package/dist/src/ping/constants.d.ts.map +0 -1
- package/dist/src/ping/constants.js +0 -15
- package/dist/src/ping/constants.js.map +0 -1
- package/dist/src/ping/index.d.ts +0 -24
- package/dist/src/ping/index.d.ts.map +0 -1
- package/dist/src/ping/index.js +0 -115
- package/dist/src/ping/index.js.map +0 -1
- package/dist/src/pnet/crypto.d.ts +0 -18
- package/dist/src/pnet/crypto.d.ts.map +0 -1
- package/dist/src/pnet/crypto.js +0 -60
- package/dist/src/pnet/crypto.js.map +0 -1
- package/dist/src/pnet/errors.d.ts +0 -6
- package/dist/src/pnet/errors.d.ts.map +0 -1
- package/dist/src/pnet/errors.js +0 -6
- package/dist/src/pnet/errors.js.map +0 -1
- package/dist/src/pnet/index.d.ts +0 -31
- package/dist/src/pnet/index.d.ts.map +0 -1
- package/dist/src/pnet/index.js +0 -97
- package/dist/src/pnet/index.js.map +0 -1
- package/dist/src/pnet/key-generator.d.ts +0 -11
- package/dist/src/pnet/key-generator.d.ts.map +0 -1
- package/dist/src/pnet/key-generator.js +0 -22
- package/dist/src/pnet/key-generator.js.map +0 -1
- package/dist/src/upnp-nat/index.d.ts +0 -71
- package/dist/src/upnp-nat/index.d.ts.map +0 -1
- package/dist/src/upnp-nat/index.js +0 -136
- package/dist/src/upnp-nat/index.js.map +0 -1
- package/dist/src/utils/peer-job-queue.d.ts +0 -33
- package/dist/src/utils/peer-job-queue.d.ts.map +0 -1
- package/dist/src/utils/peer-job-queue.js +0 -82
- package/dist/src/utils/peer-job-queue.js.map +0 -1
- package/dist/typedoc-urls.json +0 -71
- package/src/autonat/constants.ts +0 -19
- package/src/autonat/index.ts +0 -597
- package/src/autonat/pb/index.proto +0 -35
- package/src/autonat/pb/index.ts +0 -320
- package/src/circuit-relay/constants.ts +0 -72
- package/src/circuit-relay/index.ts +0 -59
- package/src/circuit-relay/pb/index.proto +0 -67
- package/src/circuit-relay/pb/index.ts +0 -539
- package/src/circuit-relay/server/advert-service.ts +0 -108
- package/src/circuit-relay/server/index.ts +0 -443
- package/src/circuit-relay/server/reservation-store.ts +0 -116
- package/src/circuit-relay/server/reservation-voucher.ts +0 -51
- package/src/circuit-relay/transport/discovery.ts +0 -136
- package/src/circuit-relay/transport/index.ts +0 -396
- package/src/circuit-relay/transport/listener.ts +0 -97
- package/src/circuit-relay/transport/reservation-store.ts +0 -312
- package/src/circuit-relay/utils.ts +0 -136
- package/src/dcutr/dcutr.ts +0 -378
- package/src/dcutr/index.ts +0 -102
- package/src/dcutr/pb/message.proto +0 -12
- package/src/dcutr/pb/message.ts +0 -96
- package/src/dcutr/utils.ts +0 -33
- package/src/fetch/README.md +0 -41
- package/src/fetch/constants.ts +0 -3
- package/src/fetch/index.ts +0 -315
- package/src/fetch/pb/proto.proto +0 -15
- package/src/fetch/pb/proto.ts +0 -153
- package/src/identify/README.md +0 -13
- package/src/identify/consts.ts +0 -12
- package/src/identify/identify.ts +0 -561
- package/src/identify/index.ts +0 -90
- package/src/identify/pb/message.proto +0 -30
- package/src/identify/pb/message.ts +0 -126
- package/src/insecure/index.ts +0 -138
- package/src/insecure/pb/proto.proto +0 -18
- package/src/insecure/pb/proto.ts +0 -161
- package/src/ping/constants.ts +0 -15
- package/src/ping/index.ts +0 -170
- package/src/pnet/README.md +0 -68
- package/src/pnet/crypto.ts +0 -67
- package/src/pnet/errors.ts +0 -5
- package/src/pnet/index.ts +0 -126
- package/src/pnet/key-generator.ts +0 -23
- package/src/upnp-nat/index.ts +0 -212
- package/src/utils/peer-job-queue.ts +0 -119
package/src/upgrader.ts
CHANGED
|
@@ -1,24 +1,12 @@
|
|
|
1
|
-
import { CodeError } from '@libp2p/interface
|
|
2
|
-
import { setMaxListeners } from '@libp2p/interface/events'
|
|
1
|
+
import { CodeError, ERR_TIMEOUT, setMaxListeners } from '@libp2p/interface'
|
|
3
2
|
import * as mss from '@libp2p/multistream-select'
|
|
4
3
|
import { peerIdFromString } from '@libp2p/peer-id'
|
|
5
4
|
import { createConnection } from './connection/index.js'
|
|
6
5
|
import { INBOUND_UPGRADE_TIMEOUT } from './connection-manager/constants.js'
|
|
7
6
|
import { codes } from './errors.js'
|
|
8
7
|
import { DEFAULT_MAX_INBOUND_STREAMS, DEFAULT_MAX_OUTBOUND_STREAMS } from './registrar.js'
|
|
9
|
-
import type { Libp2pEvents, AbortOptions, ComponentLogger, Logger } from '@libp2p/interface'
|
|
10
|
-
import type {
|
|
11
|
-
import type { ConnectionEncrypter, SecuredConnection } from '@libp2p/interface/connection-encrypter'
|
|
12
|
-
import type { ConnectionGater } from '@libp2p/interface/connection-gater'
|
|
13
|
-
import type { TypedEventTarget } from '@libp2p/interface/events'
|
|
14
|
-
import type { Metrics } from '@libp2p/interface/metrics'
|
|
15
|
-
import type { PeerId } from '@libp2p/interface/peer-id'
|
|
16
|
-
import type { PeerStore } from '@libp2p/interface/peer-store'
|
|
17
|
-
import type { StreamMuxer, StreamMuxerFactory } from '@libp2p/interface/stream-muxer'
|
|
18
|
-
import type { Upgrader, UpgraderOptions } from '@libp2p/interface/transport'
|
|
19
|
-
import type { ConnectionManager } from '@libp2p/interface-internal/connection-manager'
|
|
20
|
-
import type { Registrar } from '@libp2p/interface-internal/registrar'
|
|
21
|
-
import type { Duplex, Source } from 'it-stream-types'
|
|
8
|
+
import type { Libp2pEvents, AbortOptions, ComponentLogger, Logger, MultiaddrConnection, Connection, Stream, ConnectionProtector, NewStreamOptions, ConnectionEncrypter, SecuredConnection, ConnectionGater, TypedEventTarget, Metrics, PeerId, PeerStore, StreamMuxer, StreamMuxerFactory, Upgrader, UpgraderOptions } from '@libp2p/interface'
|
|
9
|
+
import type { ConnectionManager, Registrar } from '@libp2p/interface-internal'
|
|
22
10
|
|
|
23
11
|
const DEFAULT_PROTOCOL_SELECT_TIMEOUT = 30000
|
|
24
12
|
|
|
@@ -26,7 +14,7 @@ interface CreateConnectionOptions {
|
|
|
26
14
|
cryptoProtocol: string
|
|
27
15
|
direction: 'inbound' | 'outbound'
|
|
28
16
|
maConn: MultiaddrConnection
|
|
29
|
-
upgradedConn:
|
|
17
|
+
upgradedConn: MultiaddrConnection
|
|
30
18
|
remotePeer: PeerId
|
|
31
19
|
muxerFactory?: StreamMuxerFactory
|
|
32
20
|
transient?: boolean
|
|
@@ -38,7 +26,7 @@ interface OnStreamOptions {
|
|
|
38
26
|
protocol: string
|
|
39
27
|
}
|
|
40
28
|
|
|
41
|
-
export interface CryptoResult extends SecuredConnection {
|
|
29
|
+
export interface CryptoResult extends SecuredConnection<MultiaddrConnection> {
|
|
42
30
|
protocol: string
|
|
43
31
|
}
|
|
44
32
|
|
|
@@ -107,8 +95,6 @@ export interface DefaultUpgraderComponents {
|
|
|
107
95
|
logger: ComponentLogger
|
|
108
96
|
}
|
|
109
97
|
|
|
110
|
-
type EncryptedConn = Duplex<AsyncGenerator<Uint8Array, any, unknown>, Source<Uint8Array>, Promise<void>>
|
|
111
|
-
|
|
112
98
|
type ConnectionDeniedType = keyof Pick<ConnectionGater, 'denyOutboundConnection' | 'denyInboundEncryptedConnection' | 'denyOutboundEncryptedConnection' | 'denyInboundUpgradedConnection' | 'denyOutboundUpgradedConnection'>
|
|
113
99
|
|
|
114
100
|
export class DefaultUpgrader implements Upgrader {
|
|
@@ -117,12 +103,12 @@ export class DefaultUpgrader implements Upgrader {
|
|
|
117
103
|
private readonly muxers: Map<string, StreamMuxerFactory>
|
|
118
104
|
private readonly inboundUpgradeTimeout: number
|
|
119
105
|
private readonly events: TypedEventTarget<Libp2pEvents>
|
|
120
|
-
readonly
|
|
106
|
+
private readonly log: Logger
|
|
121
107
|
|
|
122
108
|
constructor (components: DefaultUpgraderComponents, init: UpgraderInit) {
|
|
123
109
|
this.components = components
|
|
124
110
|
this.connectionEncryption = new Map()
|
|
125
|
-
this
|
|
111
|
+
this.log = components.logger.forComponent('libp2p:upgrader')
|
|
126
112
|
|
|
127
113
|
init.connectionEncryption.forEach(encrypter => {
|
|
128
114
|
this.connectionEncryption.set(encrypter.protocol, encrypter)
|
|
@@ -158,16 +144,16 @@ export class DefaultUpgrader implements Upgrader {
|
|
|
158
144
|
throw new CodeError('connection denied', codes.ERR_CONNECTION_DENIED)
|
|
159
145
|
}
|
|
160
146
|
|
|
161
|
-
let encryptedConn:
|
|
147
|
+
let encryptedConn: MultiaddrConnection
|
|
162
148
|
let remotePeer
|
|
163
|
-
let upgradedConn:
|
|
149
|
+
let upgradedConn: MultiaddrConnection
|
|
164
150
|
let muxerFactory: StreamMuxerFactory | undefined
|
|
165
151
|
let cryptoProtocol
|
|
166
152
|
|
|
167
153
|
const signal = AbortSignal.timeout(this.inboundUpgradeTimeout)
|
|
168
154
|
|
|
169
155
|
const onAbort = (): void => {
|
|
170
|
-
maConn.abort(new CodeError('inbound upgrade timeout',
|
|
156
|
+
maConn.abort(new CodeError('inbound upgrade timeout', ERR_TIMEOUT))
|
|
171
157
|
}
|
|
172
158
|
|
|
173
159
|
signal.addEventListener('abort', onAbort, { once: true })
|
|
@@ -181,7 +167,7 @@ export class DefaultUpgrader implements Upgrader {
|
|
|
181
167
|
|
|
182
168
|
this.components.metrics?.trackMultiaddrConnection(maConn)
|
|
183
169
|
|
|
184
|
-
this
|
|
170
|
+
this.log('starting the inbound connection upgrade')
|
|
185
171
|
|
|
186
172
|
// Protect
|
|
187
173
|
let protectedConn = maConn
|
|
@@ -190,7 +176,7 @@ export class DefaultUpgrader implements Upgrader {
|
|
|
190
176
|
const protector = this.components.connectionProtector
|
|
191
177
|
|
|
192
178
|
if (protector != null) {
|
|
193
|
-
this
|
|
179
|
+
this.log('protecting the inbound connection')
|
|
194
180
|
protectedConn = await protector.protect(maConn)
|
|
195
181
|
}
|
|
196
182
|
}
|
|
@@ -237,13 +223,13 @@ export class DefaultUpgrader implements Upgrader {
|
|
|
237
223
|
upgradedConn = multiplexed.stream
|
|
238
224
|
}
|
|
239
225
|
} catch (err: any) {
|
|
240
|
-
this
|
|
226
|
+
this.log.error('Failed to upgrade inbound connection', err)
|
|
241
227
|
throw err
|
|
242
228
|
}
|
|
243
229
|
|
|
244
230
|
await this.shouldBlockConnection(remotePeer, maConn, 'denyInboundUpgradedConnection')
|
|
245
231
|
|
|
246
|
-
this
|
|
232
|
+
this.log('successfully upgraded inbound connection')
|
|
247
233
|
|
|
248
234
|
return this._createConnection({
|
|
249
235
|
cryptoProtocol,
|
|
@@ -274,15 +260,15 @@ export class DefaultUpgrader implements Upgrader {
|
|
|
274
260
|
await this.shouldBlockConnection(remotePeerId, maConn, 'denyOutboundConnection')
|
|
275
261
|
}
|
|
276
262
|
|
|
277
|
-
let encryptedConn
|
|
263
|
+
let encryptedConn: MultiaddrConnection
|
|
278
264
|
let remotePeer: PeerId
|
|
279
|
-
let upgradedConn:
|
|
265
|
+
let upgradedConn: MultiaddrConnection
|
|
280
266
|
let cryptoProtocol
|
|
281
267
|
let muxerFactory
|
|
282
268
|
|
|
283
269
|
this.components.metrics?.trackMultiaddrConnection(maConn)
|
|
284
270
|
|
|
285
|
-
this
|
|
271
|
+
this.log('Starting the outbound connection upgrade')
|
|
286
272
|
|
|
287
273
|
// If the transport natively supports encryption, skip connection
|
|
288
274
|
// protector and encryption
|
|
@@ -335,14 +321,14 @@ export class DefaultUpgrader implements Upgrader {
|
|
|
335
321
|
upgradedConn = multiplexed.stream
|
|
336
322
|
}
|
|
337
323
|
} catch (err: any) {
|
|
338
|
-
this
|
|
324
|
+
this.log.error('Failed to upgrade outbound connection', err)
|
|
339
325
|
await maConn.close(err)
|
|
340
326
|
throw err
|
|
341
327
|
}
|
|
342
328
|
|
|
343
329
|
await this.shouldBlockConnection(remotePeer, maConn, 'denyOutboundUpgradedConnection')
|
|
344
330
|
|
|
345
|
-
this
|
|
331
|
+
this.log('Successfully upgraded outbound connection')
|
|
346
332
|
|
|
347
333
|
return this._createConnection({
|
|
348
334
|
cryptoProtocol,
|
|
@@ -386,13 +372,17 @@ export class DefaultUpgrader implements Upgrader {
|
|
|
386
372
|
void Promise.resolve()
|
|
387
373
|
.then(async () => {
|
|
388
374
|
const protocols = this.components.registrar.getProtocols()
|
|
389
|
-
const { stream, protocol } = await mss.handle(muxedStream, protocols
|
|
390
|
-
|
|
375
|
+
const { stream, protocol } = await mss.handle(muxedStream, protocols, {
|
|
376
|
+
log: muxedStream.log,
|
|
377
|
+
yieldBytes: false
|
|
378
|
+
})
|
|
391
379
|
|
|
392
380
|
if (connection == null) {
|
|
393
381
|
return
|
|
394
382
|
}
|
|
395
383
|
|
|
384
|
+
connection.log('incoming stream opened on %s', protocol)
|
|
385
|
+
|
|
396
386
|
const incomingLimit = findIncomingStreamLimit(protocol, this.components.registrar)
|
|
397
387
|
const streamCount = countStreams(protocol, 'inbound', connection)
|
|
398
388
|
|
|
@@ -409,6 +399,21 @@ export class DefaultUpgrader implements Upgrader {
|
|
|
409
399
|
muxedStream.sink = stream.sink
|
|
410
400
|
muxedStream.protocol = protocol
|
|
411
401
|
|
|
402
|
+
// allow closing the write end of a not-yet-negotiated stream
|
|
403
|
+
if (stream.closeWrite != null) {
|
|
404
|
+
muxedStream.closeWrite = stream.closeWrite
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
// allow closing the read end of a not-yet-negotiated stream
|
|
408
|
+
if (stream.closeRead != null) {
|
|
409
|
+
muxedStream.closeRead = stream.closeRead
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
// make sure we don't try to negotiate a stream we are closing
|
|
413
|
+
if (stream.close != null) {
|
|
414
|
+
muxedStream.close = stream.close
|
|
415
|
+
}
|
|
416
|
+
|
|
412
417
|
// If a protocol stream has been successfully negotiated and is to be passed to the application,
|
|
413
418
|
// the peerstore should ensure that the peer is registered with that protocol
|
|
414
419
|
await this.components.peerStore.merge(remotePeer, {
|
|
@@ -420,7 +425,7 @@ export class DefaultUpgrader implements Upgrader {
|
|
|
420
425
|
this._onStream({ connection, stream: muxedStream, protocol })
|
|
421
426
|
})
|
|
422
427
|
.catch(async err => {
|
|
423
|
-
this
|
|
428
|
+
this.log.error('error handling incoming stream id %s', muxedStream.id, err.message, err.code, err.stack)
|
|
424
429
|
|
|
425
430
|
if (muxedStream.timeline.close == null) {
|
|
426
431
|
await muxedStream.close()
|
|
@@ -434,12 +439,13 @@ export class DefaultUpgrader implements Upgrader {
|
|
|
434
439
|
throw new CodeError('Stream is not multiplexed', codes.ERR_MUXER_UNAVAILABLE)
|
|
435
440
|
}
|
|
436
441
|
|
|
437
|
-
|
|
442
|
+
connection.log('starting new stream for protocols %s', protocols)
|
|
438
443
|
const muxedStream = await muxer.newStream()
|
|
444
|
+
connection.log.trace('started new stream %s for protocols %s', muxedStream.id, protocols)
|
|
439
445
|
|
|
440
446
|
try {
|
|
441
447
|
if (options.signal == null) {
|
|
442
|
-
this
|
|
448
|
+
this.log('No abort signal was passed while trying to negotiate protocols %s falling back to default timeout', protocols)
|
|
443
449
|
|
|
444
450
|
const signal = AbortSignal.timeout(DEFAULT_PROTOCOL_SELECT_TIMEOUT)
|
|
445
451
|
setMaxListeners(Infinity, signal)
|
|
@@ -450,7 +456,18 @@ export class DefaultUpgrader implements Upgrader {
|
|
|
450
456
|
}
|
|
451
457
|
}
|
|
452
458
|
|
|
453
|
-
|
|
459
|
+
muxedStream.log.trace('selecting protocol from protocols %s', protocols)
|
|
460
|
+
|
|
461
|
+
const {
|
|
462
|
+
stream,
|
|
463
|
+
protocol
|
|
464
|
+
} = await mss.select(muxedStream, protocols, {
|
|
465
|
+
...options,
|
|
466
|
+
log: muxedStream.log,
|
|
467
|
+
yieldBytes: true
|
|
468
|
+
})
|
|
469
|
+
|
|
470
|
+
muxedStream.log('selected protocol %s', protocol)
|
|
454
471
|
|
|
455
472
|
const outgoingLimit = findOutgoingStreamLimit(protocol, this.components.registrar, options)
|
|
456
473
|
const streamCount = countStreams(protocol, 'outbound', connection)
|
|
@@ -474,11 +491,26 @@ export class DefaultUpgrader implements Upgrader {
|
|
|
474
491
|
muxedStream.sink = stream.sink
|
|
475
492
|
muxedStream.protocol = protocol
|
|
476
493
|
|
|
494
|
+
// allow closing the write end of a not-yet-negotiated stream
|
|
495
|
+
if (stream.closeWrite != null) {
|
|
496
|
+
muxedStream.closeWrite = stream.closeWrite
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
// allow closing the read end of a not-yet-negotiated stream
|
|
500
|
+
if (stream.closeRead != null) {
|
|
501
|
+
muxedStream.closeRead = stream.closeRead
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
// make sure we don't try to negotiate a stream we are closing
|
|
505
|
+
if (stream.close != null) {
|
|
506
|
+
muxedStream.close = stream.close
|
|
507
|
+
}
|
|
508
|
+
|
|
477
509
|
this.components.metrics?.trackProtocolStream(muxedStream, connection)
|
|
478
510
|
|
|
479
511
|
return muxedStream
|
|
480
512
|
} catch (err: any) {
|
|
481
|
-
|
|
513
|
+
connection.log.error('could not create new stream for protocols %s', protocols, err)
|
|
482
514
|
|
|
483
515
|
if (muxedStream.timeline.close == null) {
|
|
484
516
|
muxedStream.abort(err)
|
|
@@ -497,7 +529,7 @@ export class DefaultUpgrader implements Upgrader {
|
|
|
497
529
|
muxer.sink(upgradedConn.source),
|
|
498
530
|
upgradedConn.sink(muxer.source)
|
|
499
531
|
]).catch(err => {
|
|
500
|
-
this
|
|
532
|
+
this.log.error(err)
|
|
501
533
|
})
|
|
502
534
|
}
|
|
503
535
|
|
|
@@ -512,14 +544,14 @@ export class DefaultUpgrader implements Upgrader {
|
|
|
512
544
|
await connection.close()
|
|
513
545
|
}
|
|
514
546
|
} catch (err: any) {
|
|
515
|
-
this
|
|
547
|
+
this.log.error(err)
|
|
516
548
|
} finally {
|
|
517
549
|
this.events.safeDispatchEvent('connection:close', {
|
|
518
550
|
detail: connection
|
|
519
551
|
})
|
|
520
552
|
}
|
|
521
553
|
})().catch(err => {
|
|
522
|
-
this
|
|
554
|
+
this.log.error(err)
|
|
523
555
|
})
|
|
524
556
|
}
|
|
525
557
|
|
|
@@ -548,14 +580,14 @@ export class DefaultUpgrader implements Upgrader {
|
|
|
548
580
|
close: async (options?: AbortOptions) => {
|
|
549
581
|
// Ensure remaining streams are closed gracefully
|
|
550
582
|
if (muxer != null) {
|
|
551
|
-
this
|
|
583
|
+
this.log.trace('close muxer')
|
|
552
584
|
await muxer.close(options)
|
|
553
585
|
}
|
|
554
586
|
|
|
555
|
-
this
|
|
587
|
+
this.log.trace('close maconn')
|
|
556
588
|
// close the underlying transport
|
|
557
589
|
await maConn.close(options)
|
|
558
|
-
this
|
|
590
|
+
this.log.trace('closed maconn')
|
|
559
591
|
},
|
|
560
592
|
abort: (err) => {
|
|
561
593
|
maConn.abort(err)
|
|
@@ -590,13 +622,13 @@ export class DefaultUpgrader implements Upgrader {
|
|
|
590
622
|
/**
|
|
591
623
|
* Attempts to encrypt the incoming `connection` with the provided `cryptos`
|
|
592
624
|
*/
|
|
593
|
-
async _encryptInbound (connection:
|
|
625
|
+
async _encryptInbound (connection: MultiaddrConnection): Promise<CryptoResult> {
|
|
594
626
|
const protocols = Array.from(this.connectionEncryption.keys())
|
|
595
|
-
this
|
|
627
|
+
this.log('handling inbound crypto protocol selection', protocols)
|
|
596
628
|
|
|
597
629
|
try {
|
|
598
630
|
const { stream, protocol } = await mss.handle(connection, protocols, {
|
|
599
|
-
|
|
631
|
+
log: connection.log
|
|
600
632
|
})
|
|
601
633
|
const encrypter = this.connectionEncryption.get(protocol)
|
|
602
634
|
|
|
@@ -604,7 +636,7 @@ export class DefaultUpgrader implements Upgrader {
|
|
|
604
636
|
throw new Error(`no crypto module found for ${protocol}`)
|
|
605
637
|
}
|
|
606
638
|
|
|
607
|
-
this
|
|
639
|
+
this.log('encrypting inbound connection using', protocol)
|
|
608
640
|
|
|
609
641
|
return {
|
|
610
642
|
...await encrypter.secureInbound(this.components.peerId, stream),
|
|
@@ -621,19 +653,26 @@ export class DefaultUpgrader implements Upgrader {
|
|
|
621
653
|
*/
|
|
622
654
|
async _encryptOutbound (connection: MultiaddrConnection, remotePeerId?: PeerId): Promise<CryptoResult> {
|
|
623
655
|
const protocols = Array.from(this.connectionEncryption.keys())
|
|
624
|
-
this
|
|
656
|
+
this.log('selecting outbound crypto protocol', protocols)
|
|
625
657
|
|
|
626
658
|
try {
|
|
627
|
-
|
|
628
|
-
|
|
659
|
+
connection.log.trace('selecting encrypter from %s', protocols)
|
|
660
|
+
|
|
661
|
+
const {
|
|
662
|
+
stream,
|
|
663
|
+
protocol
|
|
664
|
+
} = await mss.select(connection, protocols, {
|
|
665
|
+
log: connection.log,
|
|
666
|
+
yieldBytes: true
|
|
629
667
|
})
|
|
668
|
+
|
|
630
669
|
const encrypter = this.connectionEncryption.get(protocol)
|
|
631
670
|
|
|
632
671
|
if (encrypter == null) {
|
|
633
672
|
throw new Error(`no crypto module found for ${protocol}`)
|
|
634
673
|
}
|
|
635
674
|
|
|
636
|
-
|
|
675
|
+
connection.log('encrypting outbound connection to %p using %p', remotePeerId)
|
|
637
676
|
|
|
638
677
|
return {
|
|
639
678
|
...await encrypter.secureOutbound(this.components.peerId, stream, remotePeerId),
|
|
@@ -648,19 +687,26 @@ export class DefaultUpgrader implements Upgrader {
|
|
|
648
687
|
* Selects one of the given muxers via multistream-select. That
|
|
649
688
|
* muxer will be used for all future streams on the connection.
|
|
650
689
|
*/
|
|
651
|
-
async _multiplexOutbound (connection: MultiaddrConnection, muxers: Map<string, StreamMuxerFactory>): Promise<{ stream:
|
|
690
|
+
async _multiplexOutbound (connection: MultiaddrConnection, muxers: Map<string, StreamMuxerFactory>): Promise<{ stream: MultiaddrConnection, muxerFactory?: StreamMuxerFactory }> {
|
|
652
691
|
const protocols = Array.from(muxers.keys())
|
|
653
|
-
this
|
|
692
|
+
this.log('outbound selecting muxer %s', protocols)
|
|
654
693
|
try {
|
|
655
|
-
|
|
656
|
-
|
|
694
|
+
connection.log.trace('selecting stream muxer from %s', protocols)
|
|
695
|
+
|
|
696
|
+
const {
|
|
697
|
+
stream,
|
|
698
|
+
protocol
|
|
699
|
+
} = await mss.select(connection, protocols, {
|
|
700
|
+
log: connection.log,
|
|
701
|
+
yieldBytes: true
|
|
657
702
|
})
|
|
658
|
-
|
|
703
|
+
|
|
704
|
+
connection.log('selected %s as muxer protocol', protocol)
|
|
659
705
|
const muxerFactory = muxers.get(protocol)
|
|
660
706
|
|
|
661
707
|
return { stream, muxerFactory }
|
|
662
708
|
} catch (err: any) {
|
|
663
|
-
|
|
709
|
+
connection.log.error('error multiplexing outbound stream', err)
|
|
664
710
|
throw new CodeError(String(err), codes.ERR_MUXER_UNAVAILABLE)
|
|
665
711
|
}
|
|
666
712
|
}
|
|
@@ -669,18 +715,18 @@ export class DefaultUpgrader implements Upgrader {
|
|
|
669
715
|
* Registers support for one of the given muxers via multistream-select. The
|
|
670
716
|
* selected muxer will be used for all future streams on the connection.
|
|
671
717
|
*/
|
|
672
|
-
async _multiplexInbound (connection: MultiaddrConnection, muxers: Map<string, StreamMuxerFactory>): Promise<{ stream:
|
|
718
|
+
async _multiplexInbound (connection: MultiaddrConnection, muxers: Map<string, StreamMuxerFactory>): Promise<{ stream: MultiaddrConnection, muxerFactory?: StreamMuxerFactory }> {
|
|
673
719
|
const protocols = Array.from(muxers.keys())
|
|
674
|
-
this
|
|
720
|
+
this.log('inbound handling muxers %s', protocols)
|
|
675
721
|
try {
|
|
676
722
|
const { stream, protocol } = await mss.handle(connection, protocols, {
|
|
677
|
-
|
|
723
|
+
log: connection.log
|
|
678
724
|
})
|
|
679
725
|
const muxerFactory = muxers.get(protocol)
|
|
680
726
|
|
|
681
727
|
return { stream, muxerFactory }
|
|
682
728
|
} catch (err: any) {
|
|
683
|
-
this
|
|
729
|
+
this.log.error('error multiplexing inbound stream', err)
|
|
684
730
|
throw new CodeError(String(err), codes.ERR_MUXER_UNAVAILABLE)
|
|
685
731
|
}
|
|
686
732
|
}
|
package/src/version.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const version = '0.
|
|
1
|
+
export const version = '1.0.0-551622a96'
|
|
2
2
|
export const name = 'libp2p'
|
|
@@ -1,18 +0,0 @@
|
|
|
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 = "1.0.0";
|
|
13
|
-
export declare const TIMEOUT = 30000;
|
|
14
|
-
export declare const STARTUP_DELAY = 5000;
|
|
15
|
-
export declare const REFRESH_INTERVAL = 60000;
|
|
16
|
-
export declare const MAX_INBOUND_STREAMS = 1;
|
|
17
|
-
export declare const MAX_OUTBOUND_STREAMS = 1;
|
|
18
|
-
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/autonat/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,UAAU,CAAA;AACvC,eAAO,MAAM,OAAO,QAAQ,CAAA;AAC5B,eAAO,MAAM,aAAa,OAAO,CAAA;AACjC,eAAO,MAAM,gBAAgB,QAAQ,CAAA;AACrC,eAAO,MAAM,mBAAmB,IAAI,CAAA;AACpC,eAAO,MAAM,oBAAoB,IAAI,CAAA"}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The prefix to use in the protocol
|
|
3
|
-
*/
|
|
4
|
-
export const PROTOCOL_PREFIX = 'libp2p';
|
|
5
|
-
/**
|
|
6
|
-
* The name to use in the protocol
|
|
7
|
-
*/
|
|
8
|
-
export const PROTOCOL_NAME = 'autonat';
|
|
9
|
-
/**
|
|
10
|
-
* The version to use in the protocol
|
|
11
|
-
*/
|
|
12
|
-
export const PROTOCOL_VERSION = '1.0.0';
|
|
13
|
-
export const TIMEOUT = 30000;
|
|
14
|
-
export const STARTUP_DELAY = 5000;
|
|
15
|
-
export const REFRESH_INTERVAL = 60000;
|
|
16
|
-
export const MAX_INBOUND_STREAMS = 1;
|
|
17
|
-
export const MAX_OUTBOUND_STREAMS = 1;
|
|
18
|
-
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/autonat/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,QAAQ,CAAA;AAEvC;;GAEG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,SAAS,CAAA;AAEtC;;GAEG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,OAAO,CAAA;AACvC,MAAM,CAAC,MAAM,OAAO,GAAG,KAAK,CAAA;AAC5B,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,CAAA;AACjC,MAAM,CAAC,MAAM,gBAAgB,GAAG,KAAK,CAAA;AACrC,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,CAAA;AACpC,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,CAAA"}
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @packageDocumentation
|
|
3
|
-
*
|
|
4
|
-
* Use the `autoNATService` function to add support for the [AutoNAT protocol](https://docs.libp2p.io/concepts/nat/autonat/)
|
|
5
|
-
* to libp2p.
|
|
6
|
-
*
|
|
7
|
-
* @example
|
|
8
|
-
*
|
|
9
|
-
* ```typescript
|
|
10
|
-
* import { createLibp2p } from 'libp2p'
|
|
11
|
-
* import { autoNATService } from 'libp2p/autonat'
|
|
12
|
-
*
|
|
13
|
-
* const node = await createLibp2p({
|
|
14
|
-
* // ...other options
|
|
15
|
-
* services: {
|
|
16
|
-
* autoNAT: autoNATService()
|
|
17
|
-
* }
|
|
18
|
-
* })
|
|
19
|
-
* ```
|
|
20
|
-
*/
|
|
21
|
-
import type { PeerId } from '@libp2p/interface/peer-id';
|
|
22
|
-
import type { PeerRouting } from '@libp2p/interface/peer-routing';
|
|
23
|
-
import type { AddressManager } from '@libp2p/interface-internal/address-manager';
|
|
24
|
-
import type { ConnectionManager } from '@libp2p/interface-internal/connection-manager';
|
|
25
|
-
import type { Registrar } from '@libp2p/interface-internal/registrar';
|
|
26
|
-
import type { TransportManager } from '@libp2p/interface-internal/transport-manager';
|
|
27
|
-
export interface AutoNATServiceInit {
|
|
28
|
-
/**
|
|
29
|
-
* Allows overriding the protocol prefix used
|
|
30
|
-
*/
|
|
31
|
-
protocolPrefix?: string;
|
|
32
|
-
/**
|
|
33
|
-
* How long we should wait for a remote peer to verify our external address
|
|
34
|
-
*/
|
|
35
|
-
timeout?: number;
|
|
36
|
-
/**
|
|
37
|
-
* How long to wait after startup before trying to verify our external address
|
|
38
|
-
*/
|
|
39
|
-
startupDelay?: number;
|
|
40
|
-
/**
|
|
41
|
-
* Verify our external addresses this often
|
|
42
|
-
*/
|
|
43
|
-
refreshInterval?: number;
|
|
44
|
-
/**
|
|
45
|
-
* How many parallel inbound autoNAT streams we allow per-connection
|
|
46
|
-
*/
|
|
47
|
-
maxInboundStreams?: number;
|
|
48
|
-
/**
|
|
49
|
-
* How many parallel outbound autoNAT streams we allow per-connection
|
|
50
|
-
*/
|
|
51
|
-
maxOutboundStreams?: number;
|
|
52
|
-
}
|
|
53
|
-
export interface AutoNATComponents {
|
|
54
|
-
registrar: Registrar;
|
|
55
|
-
addressManager: AddressManager;
|
|
56
|
-
transportManager: TransportManager;
|
|
57
|
-
peerId: PeerId;
|
|
58
|
-
connectionManager: ConnectionManager;
|
|
59
|
-
peerRouting: PeerRouting;
|
|
60
|
-
}
|
|
61
|
-
export declare function autoNATService(init?: AutoNATServiceInit): (components: AutoNATComponents) => unknown;
|
|
62
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/autonat/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAsBH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAA;AAEvD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAA;AAEjE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4CAA4C,CAAA;AAChF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,+CAA+C,CAAA;AACtF,OAAO,KAAK,EAAsB,SAAS,EAAE,MAAM,sCAAsC,CAAA;AACzF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,8CAA8C,CAAA;AASpF,MAAM,WAAW,kBAAkB;IACjC;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,CAAA;IAEvB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;IAEhB;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAA;IAErB;;OAEG;IACH,eAAe,CAAC,EAAE,MAAM,CAAA;IAExB;;OAEG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAE1B;;OAEG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAA;CAC5B;AAED,MAAM,WAAW,iBAAiB;IAChC,SAAS,EAAE,SAAS,CAAA;IACpB,cAAc,EAAE,cAAc,CAAA;IAC9B,gBAAgB,EAAE,gBAAgB,CAAA;IAClC,MAAM,EAAE,MAAM,CAAA;IACd,iBAAiB,EAAE,iBAAiB,CAAA;IACpC,WAAW,EAAE,WAAW,CAAA;CACzB;AAgfD,wBAAgB,cAAc,CAAE,IAAI,GAAE,kBAAuB,GAAG,CAAC,UAAU,EAAE,iBAAiB,KAAK,OAAO,CAIzG"}
|