Hot socket

This commit is contained in:
Fedor Indutny
2025-03-20 12:13:58 -07:00
committed by GitHub
parent 4a15c23bc6
commit 121b60c0b5
4 changed files with 562 additions and 561 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -118,7 +118,7 @@
"@react-aria/focus": "3.19.1",
"@react-aria/utils": "3.25.3",
"@react-spring/web": "9.7.5",
"@signalapp/libsignal-client": "0.67.3",
"@signalapp/libsignal-client": "0.67.4",
"@signalapp/quill-cjs": "2.1.2",
"@signalapp/ringrtc": "2.50.2",
"@signalapp/sqlcipher": "1.0.0",

10
pnpm-lock.yaml generated
View File

@@ -128,8 +128,8 @@ importers:
specifier: 9.7.5
version: 9.7.5(react-dom@17.0.2(react@17.0.2))(react@17.0.2)
'@signalapp/libsignal-client':
specifier: 0.67.3
version: 0.67.3
specifier: 0.67.4
version: 0.67.4
'@signalapp/quill-cjs':
specifier: 2.1.2
version: 2.1.2
@@ -2540,8 +2540,8 @@ packages:
'@signalapp/libsignal-client@0.60.2':
resolution: {integrity: sha512-tU4kNP/yCwkFntb2ahXOSQJtzdy+YifAB2yv5hw0qyKSidRHLn6bYiz4Zo2tjxLDRoBLAUxCRsQramStiqNZdA==}
'@signalapp/libsignal-client@0.67.3':
resolution: {integrity: sha512-GIiXJMqiIByPZbomytoYQcQLJ3pNgHBCjt5BvlE/3rkrmNwyXW1UVqszX6/WfZi91aqUapO4+7Op+8JCbDGRWA==}
'@signalapp/libsignal-client@0.67.4':
resolution: {integrity: sha512-nenGxomG2zH0uCoFSwBzofqSAHnJRdbIbLr8libGy9y3rCL2z62nHL79Kh1o46ZnzxgAA7Ay3/qMhwPcXq7Iig==}
'@signalapp/mock-server@11.1.0':
resolution: {integrity: sha512-SYYek3QCh57vZZGNVQW+fSXMr+xHjnO8sMAFfj8DovjqW4HIBWbt3itGyyjxSoIXnaCMK346O6I/R79w8xY/aw==}
@@ -12254,7 +12254,7 @@ snapshots:
type-fest: 4.26.1
uuid: 8.3.2
'@signalapp/libsignal-client@0.67.3':
'@signalapp/libsignal-client@0.67.4':
dependencies:
node-gyp-build: 4.8.4
type-fest: 4.26.1

View File

@@ -17,6 +17,7 @@ import type { Readable } from 'stream';
import { Net } from '@signalapp/libsignal-client';
import { assertDev, strictAssert } from '../util/assert';
import { drop } from '../util/drop';
import { isRecord } from '../util/isRecord';
import * as durations from '../util/durations';
import type { ExplodePromiseResultType } from '../util/explodePromise';
@@ -116,9 +117,6 @@ function resolveLibsignalNet(
TESTING_localServer_chatPort: parseInt(getMockServerPort(url), 10),
TESTING_localServer_cdsiPort: DISCARD_PORT,
TESTING_localServer_svr2Port: DISCARD_PORT,
TESTING_localServer_svr3SgxPort: DISCARD_PORT,
TESTING_localServer_svr3NitroPort: DISCARD_PORT,
TESTING_localServer_svr3Tpm2SnpPort: DISCARD_PORT,
TESTING_localServer_rootCertificateDer: pemToDer(certificateAuthority),
});
}
@@ -1692,6 +1690,46 @@ export type TopLevelType = {
type InflightCallback = (error: Error) => unknown;
// `libsignalNet` is an instance of a class from libsignal that is responsible
// for providing network layer API and related functionality.
// It's important to have a single instance of this class as it holds
// resources that are shared across all other use cases.
let libsignalNet: Net.Net;
// Not definied in tests
if (window.SignalContext.config?.serverUrl) {
const { config } = window.SignalContext;
libsignalNet = resolveLibsignalNet(
config.serverUrl,
config.version,
config.certificateAuthority
);
libsignalNet.setIpv6Enabled(!config.disableIPv6);
if (config.proxyUrl) {
log.info('WebAPI: Setting libsignal proxy');
try {
libsignalNet.setProxyFromUrl(config.proxyUrl);
} catch (error) {
log.error(`WebAPI: Failed to set proxy: ${error}`);
libsignalNet.clearProxy();
}
}
drop(
(async () => {
try {
log.info('WebAPI: preconnect start');
await libsignalNet.preconnectChat();
log.info('WebAPI: preconnect done');
} catch (error) {
log.error(`WebAPI: Failed to preconnect: ${toLogFormat(error)}`);
}
})()
);
}
// We first set up the data that won't change during this session of the app
export function initialize({
chatServiceUrl,
@@ -1704,7 +1742,6 @@ export function initialize({
contentProxyUrl,
proxyUrl,
version,
disableIPv6,
}: InitializeOptionsType): WebAPIConnectType {
if (!isString(chatServiceUrl)) {
throw new Error('WebAPI.initialize: Invalid chatServiceUrl');
@@ -1743,26 +1780,6 @@ export function initialize({
throw new Error('WebAPI.initialize: Invalid version');
}
// `libsignalNet` is an instance of a class from libsignal that is responsible
// for providing network layer API and related functionality.
// It's important to have a single instance of this class as it holds
// resources that are shared across all other use cases.
const libsignalNet = resolveLibsignalNet(
chatServiceUrl,
version,
certificateAuthority
);
libsignalNet.setIpv6Enabled(!disableIPv6);
if (proxyUrl) {
log.info('Setting libsignal proxy');
try {
libsignalNet.setProxyFromUrl(proxyUrl);
} catch (error) {
log.error(`Failed to set proxy: ${error}`);
libsignalNet.clearProxy();
}
}
// We store server alerts (returned on the WS upgrade response headers) so that the app
// can query them later, which is necessary if they arrive before app state is ready
let serverAlerts: Array<ServerAlert> = [];