Infer libsignal environment from service url
This commit is contained in:
parent
b3196425af
commit
53b8f5f152
4 changed files with 5 additions and 17 deletions
|
@ -2498,9 +2498,6 @@ ipc.on('get-config', async event => {
|
||||||
preferredSystemLocales: getPreferredSystemLocales(),
|
preferredSystemLocales: getPreferredSystemLocales(),
|
||||||
localeOverride: getLocaleOverride(),
|
localeOverride: getLocaleOverride(),
|
||||||
version: app.getVersion(),
|
version: app.getVersion(),
|
||||||
libsignalNetEnvironment: config.has('libsignalNetEnvironment')
|
|
||||||
? config.get<string>('libsignalNetEnvironment')
|
|
||||||
: undefined,
|
|
||||||
buildCreation: config.get<number>('buildCreation'),
|
buildCreation: config.get<number>('buildCreation'),
|
||||||
buildExpiration: config.get<number>('buildExpiration'),
|
buildExpiration: config.get<number>('buildExpiration'),
|
||||||
challengeUrl: config.get<string>('challengeUrl'),
|
challengeUrl: config.get<string>('challengeUrl'),
|
||||||
|
|
|
@ -82,7 +82,7 @@ const DEFAULT_TIMEOUT = 30 * SECOND;
|
||||||
// (and other connectivity params) of the services.
|
// (and other connectivity params) of the services.
|
||||||
function resolveLibsignalNetEnvironment(
|
function resolveLibsignalNetEnvironment(
|
||||||
appEnv: Environment,
|
appEnv: Environment,
|
||||||
libsignalNetEnv: string | undefined
|
url: string
|
||||||
): Net.Environment {
|
): Net.Environment {
|
||||||
switch (appEnv) {
|
switch (appEnv) {
|
||||||
case Environment.Production:
|
case Environment.Production:
|
||||||
|
@ -91,12 +91,10 @@ function resolveLibsignalNetEnvironment(
|
||||||
// In the case of the `Development` Desktop env,
|
// In the case of the `Development` Desktop env,
|
||||||
// we should be checking the provided string value
|
// we should be checking the provided string value
|
||||||
// of `libsignalNetEnv`
|
// of `libsignalNetEnv`
|
||||||
switch (libsignalNetEnv) {
|
if (/staging/i.test(url)) {
|
||||||
case 'production':
|
return Net.Environment.Staging;
|
||||||
return Net.Environment.Production;
|
|
||||||
default:
|
|
||||||
return Net.Environment.Staging;
|
|
||||||
}
|
}
|
||||||
|
return Net.Environment.Production;
|
||||||
case Environment.Test:
|
case Environment.Test:
|
||||||
case Environment.Staging:
|
case Environment.Staging:
|
||||||
default:
|
default:
|
||||||
|
@ -654,7 +652,6 @@ type InitializeOptionsType = {
|
||||||
proxyUrl: string | undefined;
|
proxyUrl: string | undefined;
|
||||||
version: string;
|
version: string;
|
||||||
directoryConfig: DirectoryConfigType;
|
directoryConfig: DirectoryConfigType;
|
||||||
libsignalNetEnvironment: string | undefined;
|
|
||||||
disableIPv6: boolean;
|
disableIPv6: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1498,7 +1495,6 @@ export function initialize({
|
||||||
contentProxyUrl,
|
contentProxyUrl,
|
||||||
proxyUrl,
|
proxyUrl,
|
||||||
version,
|
version,
|
||||||
libsignalNetEnvironment,
|
|
||||||
disableIPv6,
|
disableIPv6,
|
||||||
}: InitializeOptionsType): WebAPIConnectType {
|
}: InitializeOptionsType): WebAPIConnectType {
|
||||||
if (!isString(url)) {
|
if (!isString(url)) {
|
||||||
|
@ -1542,10 +1538,7 @@ export function initialize({
|
||||||
// for providing network layer API and related functionality.
|
// for providing network layer API and related functionality.
|
||||||
// It's important to have a single instance of this class as it holds
|
// It's important to have a single instance of this class as it holds
|
||||||
// resources that are shared across all other use cases.
|
// resources that are shared across all other use cases.
|
||||||
const env = resolveLibsignalNetEnvironment(
|
const env = resolveLibsignalNetEnvironment(getEnvironment(), url);
|
||||||
getEnvironment(),
|
|
||||||
libsignalNetEnvironment
|
|
||||||
);
|
|
||||||
log.info(`libsignal net environment resolved to [${Net.Environment[env]}]`);
|
log.info(`libsignal net environment resolved to [${Net.Environment[env]}]`);
|
||||||
const libsignalNet = new Net.Net(env, getUserAgent(version));
|
const libsignalNet = new Net.Net(env, getUserAgent(version));
|
||||||
libsignalNet.setIpv6Enabled(!disableIPv6);
|
libsignalNet.setIpv6Enabled(!disableIPv6);
|
||||||
|
|
|
@ -73,7 +73,6 @@ export const rendererConfigSchema = z.object({
|
||||||
resourcesUrl: configRequiredStringSchema,
|
resourcesUrl: configRequiredStringSchema,
|
||||||
userDataPath: configRequiredStringSchema,
|
userDataPath: configRequiredStringSchema,
|
||||||
version: configRequiredStringSchema,
|
version: configRequiredStringSchema,
|
||||||
libsignalNetEnvironment: configOptionalStringSchema,
|
|
||||||
directoryConfig: directoryConfigSchema,
|
directoryConfig: directoryConfigSchema,
|
||||||
|
|
||||||
// Only used by main window
|
// Only used by main window
|
||||||
|
|
|
@ -37,7 +37,6 @@ window.WebAPI = window.textsecure.WebAPI.initialize({
|
||||||
contentProxyUrl: config.contentProxyUrl,
|
contentProxyUrl: config.contentProxyUrl,
|
||||||
proxyUrl: config.proxyUrl,
|
proxyUrl: config.proxyUrl,
|
||||||
version: config.version,
|
version: config.version,
|
||||||
libsignalNetEnvironment: config.libsignalNetEnvironment,
|
|
||||||
disableIPv6: config.disableIPv6,
|
disableIPv6: config.disableIPv6,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue