Differential updates
This commit is contained in:
parent
c11e9350d5
commit
f58d1332c4
12 changed files with 873 additions and 153 deletions
50
ts/updater/got.ts
Normal file
50
ts/updater/got.ts
Normal file
|
@ -0,0 +1,50 @@
|
|||
// Copyright 2019-2022 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
import type { StrictOptions as GotOptions } from 'got';
|
||||
import config from 'config';
|
||||
import ProxyAgent from 'proxy-agent';
|
||||
|
||||
import * as packageJson from '../../package.json';
|
||||
import { getUserAgent } from '../util/getUserAgent';
|
||||
|
||||
export const GOT_CONNECT_TIMEOUT = 2 * 60 * 1000;
|
||||
export const GOT_LOOKUP_TIMEOUT = 2 * 60 * 1000;
|
||||
export const GOT_SOCKET_TIMEOUT = 2 * 60 * 1000;
|
||||
|
||||
export function getProxyUrl(): string | undefined {
|
||||
return process.env.HTTPS_PROXY || process.env.https_proxy;
|
||||
}
|
||||
|
||||
export function getCertificateAuthority(): string {
|
||||
return config.get('certificateAuthority');
|
||||
}
|
||||
|
||||
export function getGotOptions(): GotOptions {
|
||||
const certificateAuthority = getCertificateAuthority();
|
||||
const proxyUrl = getProxyUrl();
|
||||
const agent = proxyUrl
|
||||
? {
|
||||
http: new ProxyAgent(proxyUrl),
|
||||
https: new ProxyAgent(proxyUrl),
|
||||
}
|
||||
: undefined;
|
||||
|
||||
return {
|
||||
agent,
|
||||
https: {
|
||||
certificateAuthority,
|
||||
},
|
||||
headers: {
|
||||
'Cache-Control': 'no-cache',
|
||||
'User-Agent': getUserAgent(packageJson.version),
|
||||
},
|
||||
timeout: {
|
||||
connect: GOT_CONNECT_TIMEOUT,
|
||||
lookup: GOT_LOOKUP_TIMEOUT,
|
||||
|
||||
// This timeout is reset whenever we get new data on the socket
|
||||
socket: GOT_SOCKET_TIMEOUT,
|
||||
},
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue