Comparing version 2.6.1-7655833bb to 2.6.1-f9345a7a1
@@ -60,2 +60,4 @@ import { PeerMap } from '@libp2p/peer-collections'; | ||
* | ||
* Does not apply if an abort signal is passed to the `.dial` method. | ||
* | ||
* @default 3000 | ||
@@ -68,5 +70,20 @@ */ | ||
* @default 2000 | ||
* @deprecated use outboundStreamProtocolNegotiationTimeout or inboundStreamProtocolNegotiationTimeout instead | ||
*/ | ||
protocolNegotiationTimeout?: number; | ||
/** | ||
* Outbound protocol negotiation must complete within this number of ms. | ||
* | ||
* Does not apply if an abort signal is passed to the `.dial` method. | ||
* | ||
* @default 2000 | ||
*/ | ||
outboundStreamProtocolNegotiationTimeout?: number; | ||
/** | ||
* Inbound protocol negotiation must complete within this number of ms | ||
* | ||
* @default 2000 | ||
*/ | ||
inboundStreamProtocolNegotiationTimeout?: number; | ||
/** | ||
* Multiaddr resolvers to use when dialling | ||
@@ -73,0 +90,0 @@ */ |
@@ -35,2 +35,3 @@ import { publicKeyFromProtobuf } from '@libp2p/crypto/keys'; | ||
log; | ||
// eslint-disable-next-line complexity | ||
constructor(init) { | ||
@@ -99,3 +100,5 @@ super(); | ||
inboundUpgradeTimeout: init.connectionManager?.inboundUpgradeTimeout, | ||
outboundUpgradeTimeout: init.connectionManager?.outboundUpgradeTimeout | ||
outboundUpgradeTimeout: init.connectionManager?.outboundUpgradeTimeout, | ||
inboundStreamProtocolNegotiationTimeout: init.connectionManager?.inboundStreamProtocolNegotiationTimeout ?? init.connectionManager?.protocolNegotiationTimeout, | ||
outboundStreamProtocolNegotiationTimeout: init.connectionManager?.outboundStreamProtocolNegotiationTimeout ?? init.connectionManager?.protocolNegotiationTimeout | ||
}); | ||
@@ -102,0 +105,0 @@ // Setup the transport manager |
import { InvalidMultiaddrError, TooManyInboundProtocolStreamsError, TooManyOutboundProtocolStreamsError, LimitedConnectionError, setMaxListeners, InvalidPeerIdError } from '@libp2p/interface'; | ||
import * as mss from '@libp2p/multistream-select'; | ||
import { peerIdFromString } from '@libp2p/peer-id'; | ||
import { anySignal } from 'any-signal'; | ||
import { CustomProgressEvent } from 'progress-events'; | ||
@@ -148,6 +147,8 @@ import { createConnection } from './connection/index.js'; | ||
let cryptoProtocol; | ||
const upgradeTimeoutSignal = AbortSignal.timeout(direction === 'inbound' ? this.inboundUpgradeTimeout : this.outboundUpgradeTimeout); | ||
const signal = anySignal([upgradeTimeoutSignal, opts.signal]); | ||
setMaxListeners(Infinity, upgradeTimeoutSignal, signal); | ||
opts.signal = signal; | ||
if (opts.signal == null) { | ||
maConn.log('no abort signal was passed while trying to upgrade connection, falling back to default timeout'); | ||
const upgradeTimeoutSignal = AbortSignal.timeout(direction === 'inbound' ? this.inboundUpgradeTimeout : this.outboundUpgradeTimeout); | ||
setMaxListeners(Infinity, upgradeTimeoutSignal); | ||
opts.signal = upgradeTimeoutSignal; | ||
} | ||
this.components.metrics?.trackMultiaddrConnection(maConn); | ||
@@ -174,10 +175,4 @@ maConn.log.trace('starting the %s connection upgrade', direction); | ||
} = await (direction === 'inbound' | ||
? this._encryptInbound(protectedConn, { | ||
...opts, | ||
signal | ||
}) | ||
: this._encryptOutbound(protectedConn, { | ||
...opts, | ||
signal | ||
}))); | ||
? this._encryptInbound(protectedConn, opts) | ||
: this._encryptOutbound(protectedConn, opts))); | ||
const maConn = { | ||
@@ -229,5 +224,2 @@ ...protectedConn, | ||
} | ||
finally { | ||
signal.clear(); | ||
} | ||
await this.shouldBlockConnection(direction === 'inbound' ? 'denyInboundUpgradedConnection' : 'denyOutboundUpgradedConnection', remotePeer, maConn); | ||
@@ -234,0 +226,0 @@ maConn.log('successfully upgraded %s connection', direction); |
@@ -1,3 +0,3 @@ | ||
export declare const version = "2.6.1-7655833bb"; | ||
export declare const version = "2.6.1-f9345a7a1"; | ||
export declare const name = "js-libp2p"; | ||
//# sourceMappingURL=version.d.ts.map |
@@ -1,3 +0,3 @@ | ||
export const version = '2.6.1-7655833bb'; | ||
export const version = '2.6.1-f9345a7a1'; | ||
export const name = 'js-libp2p'; | ||
//# sourceMappingURL=version.js.map |
{ | ||
"name": "libp2p", | ||
"version": "2.6.1-7655833bb", | ||
"version": "2.6.1-f9345a7a1", | ||
"description": "JavaScript implementation of libp2p, a modular peer to peer network stack", | ||
@@ -95,11 +95,11 @@ "license": "Apache-2.0 OR MIT", | ||
"@chainsafe/netmask": "^2.0.0", | ||
"@libp2p/crypto": "5.0.11-7655833bb", | ||
"@libp2p/interface": "2.5.0-7655833bb", | ||
"@libp2p/interface-internal": "2.3.0-7655833bb", | ||
"@libp2p/logger": "5.1.8-7655833bb", | ||
"@libp2p/multistream-select": "6.0.13-7655833bb", | ||
"@libp2p/peer-collections": "6.0.17-7655833bb", | ||
"@libp2p/peer-id": "5.0.12-7655833bb", | ||
"@libp2p/peer-store": "11.0.17-7655833bb", | ||
"@libp2p/utils": "6.5.1-7655833bb", | ||
"@libp2p/crypto": "5.0.11-f9345a7a1", | ||
"@libp2p/interface": "2.5.0-f9345a7a1", | ||
"@libp2p/interface-internal": "2.3.0-f9345a7a1", | ||
"@libp2p/logger": "5.1.8-f9345a7a1", | ||
"@libp2p/multistream-select": "6.0.13-f9345a7a1", | ||
"@libp2p/peer-collections": "6.0.17-f9345a7a1", | ||
"@libp2p/peer-id": "5.0.12-f9345a7a1", | ||
"@libp2p/peer-store": "11.0.17-f9345a7a1", | ||
"@libp2p/utils": "6.5.1-f9345a7a1", | ||
"@multiformats/dns": "^1.0.6", | ||
@@ -106,0 +106,0 @@ "@multiformats/multiaddr": "^12.3.5", |
@@ -78,2 +78,4 @@ import { ConnectionClosedError, InvalidMultiaddrError, InvalidParametersError, InvalidPeerIdError, NotStartedError, start, stop } from '@libp2p/interface' | ||
* | ||
* Does not apply if an abort signal is passed to the `.dial` method. | ||
* | ||
* @default 3000 | ||
@@ -87,2 +89,3 @@ */ | ||
* @default 2000 | ||
* @deprecated use outboundStreamProtocolNegotiationTimeout or inboundStreamProtocolNegotiationTimeout instead | ||
*/ | ||
@@ -92,2 +95,18 @@ protocolNegotiationTimeout?: number | ||
/** | ||
* Outbound protocol negotiation must complete within this number of ms. | ||
* | ||
* Does not apply if an abort signal is passed to the `.dial` method. | ||
* | ||
* @default 2000 | ||
*/ | ||
outboundStreamProtocolNegotiationTimeout?: number | ||
/** | ||
* Inbound protocol negotiation must complete within this number of ms | ||
* | ||
* @default 2000 | ||
*/ | ||
inboundStreamProtocolNegotiationTimeout?: number | ||
/** | ||
* Multiaddr resolvers to use when dialling | ||
@@ -94,0 +113,0 @@ */ |
@@ -41,2 +41,3 @@ import { publicKeyFromProtobuf } from '@libp2p/crypto/keys' | ||
// eslint-disable-next-line complexity | ||
constructor (init: Libp2pInit<T> & { peerId: PeerId }) { | ||
@@ -120,3 +121,5 @@ super() | ||
inboundUpgradeTimeout: init.connectionManager?.inboundUpgradeTimeout, | ||
outboundUpgradeTimeout: init.connectionManager?.outboundUpgradeTimeout | ||
outboundUpgradeTimeout: init.connectionManager?.outboundUpgradeTimeout, | ||
inboundStreamProtocolNegotiationTimeout: init.connectionManager?.inboundStreamProtocolNegotiationTimeout ?? init.connectionManager?.protocolNegotiationTimeout, | ||
outboundStreamProtocolNegotiationTimeout: init.connectionManager?.outboundStreamProtocolNegotiationTimeout ?? init.connectionManager?.protocolNegotiationTimeout | ||
}) | ||
@@ -123,0 +126,0 @@ |
import { InvalidMultiaddrError, TooManyInboundProtocolStreamsError, TooManyOutboundProtocolStreamsError, LimitedConnectionError, setMaxListeners, InvalidPeerIdError } from '@libp2p/interface' | ||
import * as mss from '@libp2p/multistream-select' | ||
import { peerIdFromString } from '@libp2p/peer-id' | ||
import { anySignal } from 'any-signal' | ||
import { CustomProgressEvent } from 'progress-events' | ||
@@ -255,7 +254,10 @@ import { createConnection } from './connection/index.js' | ||
const upgradeTimeoutSignal = AbortSignal.timeout(direction === 'inbound' ? this.inboundUpgradeTimeout : this.outboundUpgradeTimeout) | ||
const signal = anySignal([upgradeTimeoutSignal, opts.signal]) | ||
setMaxListeners(Infinity, upgradeTimeoutSignal, signal) | ||
opts.signal = signal | ||
if (opts.signal == null) { | ||
maConn.log('no abort signal was passed while trying to upgrade connection, falling back to default timeout') | ||
const upgradeTimeoutSignal = AbortSignal.timeout(direction === 'inbound' ? this.inboundUpgradeTimeout : this.outboundUpgradeTimeout) | ||
setMaxListeners(Infinity, upgradeTimeoutSignal) | ||
opts.signal = upgradeTimeoutSignal | ||
} | ||
this.components.metrics?.trackMultiaddrConnection(maConn) | ||
@@ -288,10 +290,4 @@ | ||
} = await (direction === 'inbound' | ||
? this._encryptInbound(protectedConn, { | ||
...opts, | ||
signal | ||
}) | ||
: this._encryptOutbound(protectedConn, { | ||
...opts, | ||
signal | ||
}) | ||
? this._encryptInbound(protectedConn, opts) | ||
: this._encryptOutbound(protectedConn, opts) | ||
)) | ||
@@ -348,4 +344,2 @@ | ||
throw err | ||
} finally { | ||
signal.clear() | ||
} | ||
@@ -352,0 +346,0 @@ |
@@ -1,2 +0,2 @@ | ||
export const version = '2.6.1-7655833bb' | ||
export const version = '2.6.1-f9345a7a1' | ||
export const name = 'js-libp2p' |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
993586
12381
+ Added@libp2p/crypto@5.0.11-f9345a7a1(transitive)
+ Added@libp2p/interface@2.5.0-f9345a7a1(transitive)
+ Added@libp2p/interface-internal@2.3.0-f9345a7a1(transitive)
+ Added@libp2p/logger@5.1.8-f9345a7a1(transitive)
+ Added@libp2p/multistream-select@6.0.13-f9345a7a1(transitive)
+ Added@libp2p/peer-collections@6.0.17-f9345a7a1(transitive)
+ Added@libp2p/peer-id@5.0.12-f9345a7a1(transitive)
+ Added@libp2p/peer-record@8.0.17-f9345a7a1(transitive)
+ Added@libp2p/peer-store@11.0.17-f9345a7a1(transitive)
+ Added@libp2p/utils@6.5.1-f9345a7a1(transitive)
- Removed@libp2p/crypto@5.0.11-7655833bb(transitive)
- Removed@libp2p/interface@2.5.0-7655833bb(transitive)
- Removed@libp2p/interface-internal@2.3.0-7655833bb(transitive)
- Removed@libp2p/logger@5.1.8-7655833bb(transitive)
- Removed@libp2p/multistream-select@6.0.13-7655833bb(transitive)
- Removed@libp2p/peer-collections@6.0.17-7655833bb(transitive)
- Removed@libp2p/peer-id@5.0.12-7655833bb(transitive)
- Removed@libp2p/peer-record@8.0.17-7655833bb(transitive)
- Removed@libp2p/peer-store@11.0.17-7655833bb(transitive)
- Removed@libp2p/utils@6.5.1-7655833bb(transitive)