diff --git a/package-lock.json b/package-lock.json index 25c941107..6dbf615d1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "polykey", - "version": "1.16.4", + "version": "1.17.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "polykey", - "version": "1.16.4", + "version": "1.17.0", "license": "GPL-3.0", "dependencies": { "@matrixai/async-cancellable": "^1.1.1", @@ -19,7 +19,7 @@ "@matrixai/id": "^3.3.6", "@matrixai/logger": "^3.1.2", "@matrixai/mdns": "^1.2.6", - "@matrixai/quic": "^1.3.1", + "@matrixai/quic": "^1.3.2", "@matrixai/resources": "^1.1.5", "@matrixai/rpc": "^0.6.2", "@matrixai/timer": "^1.1.3", @@ -1606,9 +1606,9 @@ "integrity": "sha512-ulDEYPv7asdKvqahuAY35c1selLdzDwHqugK92hfkzvlDCwXRRelDkR+Er33md/PtnpqHemgkuDPanZ4fiYZ8w==" }, "node_modules/@matrixai/quic": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/@matrixai/quic/-/quic-1.3.1.tgz", - "integrity": "sha512-uJCukeFQ17nqqv5lko/qKKLbQLO8An5YNMpOOrEzASCgsaaqpeJEutdhWmNOzFKwTatHYNkwWP4hXxU6TK9M6Q==", + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/@matrixai/quic/-/quic-1.3.2.tgz", + "integrity": "sha512-HpHqJJY0hVG0rvXN5VpWGh1hCbpz0Gg52olm8UneqLzRW+xFLlpV25JcIHZAh2AG4yILrFU/4JDAzx9Oxdzbww==", "dependencies": { "@matrixai/async-cancellable": "^1.1.1", "@matrixai/async-init": "^1.10.0", @@ -1622,17 +1622,17 @@ "ip-num": "^1.5.0" }, "optionalDependencies": { - "@matrixai/quic-darwin-arm64": "1.3.1", - "@matrixai/quic-darwin-universal": "1.3.1", - "@matrixai/quic-darwin-x64": "1.3.1", - "@matrixai/quic-linux-x64": "1.3.1", - "@matrixai/quic-win32-x64": "1.3.1" + "@matrixai/quic-darwin-arm64": "1.3.2", + "@matrixai/quic-darwin-universal": "1.3.2", + "@matrixai/quic-darwin-x64": "1.3.2", + "@matrixai/quic-linux-x64": "1.3.2", + "@matrixai/quic-win32-x64": "1.3.2" } }, "node_modules/@matrixai/quic-darwin-arm64": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/@matrixai/quic-darwin-arm64/-/quic-darwin-arm64-1.3.1.tgz", - "integrity": "sha512-pdEtTxhD293umFNTt/JxzqQCuRs2ImRemBBBnbo/CwHsDrJkCwJkI4cJaYnCVj4NOrL701GxBMTz+nbXm9JNhw==", + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/@matrixai/quic-darwin-arm64/-/quic-darwin-arm64-1.3.2.tgz", + "integrity": "sha512-RJeGfyayUHEPNKSfDNhU6QSqrjNWUeD9h/NaLIzueNPnxeSfFCcJEMDf6HhKuF/iMPuOiQABFb1lL0qjbCoEnQ==", "cpu": [ "arm64" ], @@ -1642,9 +1642,9 @@ ] }, "node_modules/@matrixai/quic-darwin-universal": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/@matrixai/quic-darwin-universal/-/quic-darwin-universal-1.3.1.tgz", - "integrity": "sha512-hOHYbMsYFbh0Mix10yEJuYVStS6DegCib16BqguK6fvnf2F3gj0npJKgk6yPtUy1vEsBjYKf6xuiv6qBdfpqNA==", + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/@matrixai/quic-darwin-universal/-/quic-darwin-universal-1.3.2.tgz", + "integrity": "sha512-d/FWERj8fNudFC1OaHfe0iPSzTsHCsbaLCMvFAGinsvcEB1YAHSt7DPRKJ+j8AJvoLqjM30QTxu+dHe9LsIUGA==", "cpu": [ "x64", "arm64" @@ -1655,9 +1655,9 @@ ] }, "node_modules/@matrixai/quic-darwin-x64": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/@matrixai/quic-darwin-x64/-/quic-darwin-x64-1.3.1.tgz", - "integrity": "sha512-2XFNn0yYiYO7MNQ44wuav4+gIi/VXa6hPyEVGUZgXfAAeBKzQQz89Wua9BYXGoiDz7j9C+ePE799q7zoGBSm9A==", + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/@matrixai/quic-darwin-x64/-/quic-darwin-x64-1.3.2.tgz", + "integrity": "sha512-higH93CI+qSwUc/mHeWF93UFo6ALnLwT0rPQxQQFEza03vx3uuZjvXUj1q8+skEHH/qOPz1ypWLrZSyvLMoADQ==", "cpu": [ "x64" ], @@ -1667,9 +1667,9 @@ ] }, "node_modules/@matrixai/quic-linux-x64": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/@matrixai/quic-linux-x64/-/quic-linux-x64-1.3.1.tgz", - "integrity": "sha512-jXjjO5soaJotfE3khsxKqNPTtL9AOnW9+NJfQalP+pBFbRT85vRu35dy+SSuFrsnuvtJc5YK0zUmfcD2Qlm55Q==", + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/@matrixai/quic-linux-x64/-/quic-linux-x64-1.3.2.tgz", + "integrity": "sha512-gWP+ioIa3QG0z40K0G7g33oVev1UxTtpju8FQg7A6nHH5gBfYNKM7zc/XdVmOfXiiTpv3zel49E/8/2A9gKeuw==", "cpu": [ "x64" ], @@ -1679,9 +1679,9 @@ ] }, "node_modules/@matrixai/quic-win32-x64": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/@matrixai/quic-win32-x64/-/quic-win32-x64-1.3.1.tgz", - "integrity": "sha512-VWvsS3zl3gkvHzj0WTpK2mgcoijuq5BEZ8MaZY30wZimr4PV8qw/Q8V36bZ1bqagQpcLjEv+TFIcfsr8nyQIYw==", + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/@matrixai/quic-win32-x64/-/quic-win32-x64-1.3.2.tgz", + "integrity": "sha512-hFYTtNEOOtttn5ytlXE4wsGSrj/mD9cz8gALgSMiEawaMQ2EeQ/G+hYZWreUuTyzhxITWe9mOPksIb1CvIBThQ==", "cpu": [ "x64" ], diff --git a/package.json b/package.json index a15a58df8..28c5152f8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "polykey", - "version": "1.16.4", + "version": "1.17.0", "homepage": "https://polykey.com", "author": "Matrix AI", "contributors": [ @@ -78,7 +78,7 @@ "@matrixai/id": "^3.3.6", "@matrixai/logger": "^3.1.2", "@matrixai/mdns": "^1.2.6", - "@matrixai/quic": "^1.3.1", + "@matrixai/quic": "^1.3.2", "@matrixai/resources": "^1.1.5", "@matrixai/rpc": "^0.6.2", "@matrixai/timer": "^1.1.3", diff --git a/src/PolykeyAgent.ts b/src/PolykeyAgent.ts index b64a30b5d..df55cc239 100644 --- a/src/PolykeyAgent.ts +++ b/src/PolykeyAgent.ts @@ -99,6 +99,8 @@ type PolykeyAgentOptions = { connectionKeepAliveTimeoutTime: number; connectionKeepAliveIntervalTime: number; connectionHolePunchIntervalTime: number; + connectionInitialMaxStreamsBidi: number; + connectionInitialMaxStreamsUni: number; rpcCallTimeoutTime: number; rpcParserBufferSize: number; dnsServers: Array | undefined; @@ -196,6 +198,10 @@ class PolykeyAgent { config.defaultsSystem.nodesConnectionKeepAliveIntervalTime, connectionHolePunchIntervalTime: config.defaultsSystem.nodesConnectionHolePunchIntervalTime, + connectionInitialMaxStreamsBidi: + config.defaultsSystem.nodesConnectionInitialMaxStreamsBidi, + connectionInitialMaxStreamsUni: + config.defaultsSystem.nodesConnectionInitialMaxStreamsUni, }, mdns: { groups: config.defaultsSystem.mdnsGroups, @@ -374,6 +380,10 @@ class PolykeyAgent { optionsDefaulted.nodes.connectionKeepAliveIntervalTime, connectionHolePunchIntervalTime: optionsDefaulted.nodes.connectionHolePunchIntervalTime, + connectionInitialMaxStreamsBidi: + optionsDefaulted.nodes.connectionInitialMaxStreamsBidi, + connectionInitialMaxStreamsUni: + optionsDefaulted.nodes.connectionInitialMaxStreamsBidi, rpcParserBufferSize: optionsDefaulted.nodes.rpcParserBufferSize, rpcCallTimeoutTime: optionsDefaulted.nodes.rpcCallTimeoutTime, logger: logger.getChild(NodeConnectionManager.name), diff --git a/src/config.ts b/src/config.ts index b5fbac37d..3f35bb5c2 100644 --- a/src/config.ts +++ b/src/config.ts @@ -251,6 +251,9 @@ const config = { * Interval for hole punching reverse node connections. */ nodesConnectionHolePunchIntervalTime: 1_000, // 1 second + nodesConnectionInitialMaxStreamsBidi: 1_000, + nodesConnectionInitialMaxStreamsUni: 0, // We don't use unidirectional streams so we disable them + /** * Interval for refreshing buckets. * diff --git a/src/nodes/NodeConnection.ts b/src/nodes/NodeConnection.ts index bb93ef1de..090eaa974 100644 --- a/src/nodes/NodeConnection.ts +++ b/src/nodes/NodeConnection.ts @@ -171,6 +171,10 @@ class NodeConnection { connectionKeepAliveIntervalTime, connectionKeepAliveTimeoutTime = config.defaultsSystem .nodesConnectionIdleTimeoutTimeMin, + connectionInitialMaxStreamsBidi = config.defaultsSystem + .nodesConnectionInitialMaxStreamsBidi, + connectionInitialMaxStreamsUni = config.defaultsSystem + .nodesConnectionInitialMaxStreamsUni, quicSocket, manifest, logger, @@ -182,6 +186,8 @@ class NodeConnection { tlsConfig: TLSConfig; connectionKeepAliveIntervalTime?: number; connectionKeepAliveTimeoutTime?: number; + connectionInitialMaxStreamsBidi?: number; + connectionInitialMaxStreamsUni?: number; quicSocket?: QUICSocket; manifest: AgentClientManifest; logger?: Logger; @@ -203,6 +209,10 @@ class NodeConnection { connectionKeepAliveIntervalTime, connectionKeepAliveTimeoutTime = config.defaultsSystem .nodesConnectionIdleTimeoutTimeMin, + connectionInitialMaxStreamsBidi = config.defaultsSystem + .nodesConnectionInitialMaxStreamsBidi, + connectionInitialMaxStreamsUni = config.defaultsSystem + .nodesConnectionInitialMaxStreamsUni, quicSocket, logger = new Logger(this.name), }: { @@ -214,6 +224,8 @@ class NodeConnection { manifest: AgentClientManifest; connectionKeepAliveIntervalTime?: number; connectionKeepAliveTimeoutTime?: number; + connectionInitialMaxStreamsBidi?: number; + connectionInitialMaxStreamsUni?: number; quicSocket: QUICSocket; logger?: Logger; }, @@ -255,6 +267,8 @@ class NodeConnection { ca: undefined, key: tlsConfig.keyPrivatePem, cert: tlsConfig.certChainPem, + initialMaxStreamsBidi: connectionInitialMaxStreamsBidi, + initialMaxStreamsUni: connectionInitialMaxStreamsUni, }, crypto: nodesUtils.quicClientCrypto, reasonToCode: nodesUtils.reasonToCode, diff --git a/src/nodes/NodeConnectionManager.ts b/src/nodes/NodeConnectionManager.ts index 17307cd03..f55e2978e 100644 --- a/src/nodes/NodeConnectionManager.ts +++ b/src/nodes/NodeConnectionManager.ts @@ -143,6 +143,16 @@ class NodeConnectionManager { */ public readonly connectionHolePunchIntervalTime: number; + /** + * Total number of active bidirectional streams that can be created + */ + public readonly connectionInitialMaxStreamsBidi: number; + + /** + * Total number of active unidirectional streams that can be created + */ + public readonly connectionInitialMaxStreamsUni: number; + /** * Max parse buffer size before RPC parser throws an parse error. */ @@ -370,9 +380,12 @@ class NodeConnectionManager { .nodesConnectionKeepAliveIntervalTime, connectionHolePunchIntervalTime = config.defaultsSystem .nodesConnectionHolePunchIntervalTime, + connectionInitialMaxStreamsBidi = config.defaultsSystem + .nodesConnectionInitialMaxStreamsBidi, + connectionInitialMaxStreamsUni = config.defaultsSystem + .nodesConnectionInitialMaxStreamsUni, rpcParserBufferSize = config.defaultsSystem.rpcParserBufferSize, rpcCallTimeoutTime = config.defaultsSystem.rpcCallTimeoutTime, - logger, }: { keyRing: KeyRing; @@ -386,6 +399,8 @@ class NodeConnectionManager { connectionKeepAliveTimeoutTime?: number; connectionKeepAliveIntervalTime?: number; connectionHolePunchIntervalTime?: number; + connectionInitialMaxStreamsBidi?: number; + connectionInitialMaxStreamsUni?: number; rpcParserBufferSize?: number; rpcCallTimeoutTime?: number; logger?: Logger; @@ -402,6 +417,8 @@ class NodeConnectionManager { this.connectionKeepAliveTimeoutTime = connectionKeepAliveTimeoutTime; this.connectionKeepAliveIntervalTime = connectionKeepAliveIntervalTime; this.connectionHolePunchIntervalTime = connectionHolePunchIntervalTime; + this.connectionInitialMaxStreamsBidi = connectionInitialMaxStreamsBidi; + this.connectionInitialMaxStreamsUni = connectionInitialMaxStreamsUni; this.rpcParserBufferSize = rpcParserBufferSize; this.rpcCallTimeoutTime = rpcCallTimeoutTime; @@ -422,6 +439,8 @@ class NodeConnectionManager { cert: tlsConfig.certChainPem, verifyPeer: true, verifyCallback: nodesUtils.verifyClientCertificateChain, + initialMaxStreamsBidi: 1000, + initialMaxStreamsUni: 0, }, socket: quicSocket, reasonToCode: nodesUtils.reasonToCode, @@ -736,6 +755,8 @@ class NodeConnectionManager { tlsConfig: this.tlsConfig, connectionKeepAliveIntervalTime: this.connectionKeepAliveIntervalTime, connectionKeepAliveTimeoutTime: this.connectionKeepAliveTimeoutTime, + connectionInitialMaxStreamsBidi: this.connectionInitialMaxStreamsBidi, + connectionInitialMaxStreamsUni: this.connectionInitialMaxStreamsUni, quicSocket: this.quicSocket, logger: this.logger.getChild( `${NodeConnection.name}Forward [${host}:${port}]`,