Use createHTTPSAgent for all requests

This commit is contained in:
Fedor Indutny 2023-12-12 23:57:09 +01:00 committed by GitHub
parent 15e1d6e441
commit f8c4e392fe
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 47 additions and 42 deletions

View file

@ -1,36 +1,18 @@
// Copyright 2023 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import type { LookupOneOptions, LookupAllOptions, LookupAddress } from 'dns';
import { lookup as nodeLookup } from 'dns';
import type {
LookupOneOptions,
LookupAllOptions,
LookupAddress,
lookup as nodeLookup,
} from 'dns';
import { ipcRenderer, net } from 'electron';
import type { ResolvedHost } from 'electron';
import { strictAssert } from './assert';
import { drop } from './drop';
const HOST_ALLOWLIST = new Set([
// Production
'chat.signal.org',
'storage.signal.org',
'cdsi.signal.org',
'cdn.signal.org',
'cdn2.signal.org',
'create.signal.art',
// Staging
'chat.staging.signal.org',
'storage-staging.signal.org',
'cdsi.staging.signal.org',
'cdn-staging.signal.org',
'cdn2-staging.signal.org',
'create.staging.signal.art',
// Common
'updates2.signal.org',
'sfu.voip.signal.org',
]);
function lookupAll(
hostname: string,
opts: LookupOneOptions | LookupAllOptions,
@ -40,11 +22,6 @@ function lookupAll(
family?: number
) => void
): void {
if (!HOST_ALLOWLIST.has(hostname)) {
nodeLookup(hostname, opts, callback);
return;
}
// Node.js support various signatures, but we only support one.
strictAssert(typeof opts === 'object', 'missing options');
strictAssert(typeof callback === 'function', 'missing callback');