Include HTTP_PROXY and NO_PROXY (#93595)

This commit is contained in:
Christof Marti
2020-04-16 08:14:37 +02:00
parent a02cfef605
commit 273bb63e3c

View File

@@ -119,6 +119,7 @@ export class CodeWindow extends Disposable implements ICodeWindow {
private readonly touchBarGroups: TouchBarSegmentedControl[];
private currentHttpProxy?: string;
private currentNoProxy?: string;
constructor(
config: IWindowCreationOptions,
@@ -597,12 +598,17 @@ export class CodeWindow extends Disposable implements ICodeWindow {
this.setMenuBarVisibility(newMenuBarVisibility);
}
// Do not set to empty configuration at startup if setting is empty to not override configuration through CLI options:
const newHttpProxy = (this.configurationService.getValue<string>('http.proxy') || '').trim() || undefined;
if (newHttpProxy !== this.currentHttpProxy) {
const env = process.env;
const newHttpProxy = (this.configurationService.getValue<string>('http.proxy') || '').trim()
|| (env.https_proxy || process.env.HTTPS_PROXY || process.env.http_proxy || process.env.HTTP_PROXY || '').trim() // Not standardized.
|| undefined;
const newNoProxy = (env.no_proxy || env.NO_PROXY || '').trim() || undefined; // Not standardized.
if (newHttpProxy !== this.currentHttpProxy || newNoProxy !== this.currentNoProxy) {
this.currentHttpProxy = newHttpProxy;
this.currentNoProxy = newNoProxy;
this._win.webContents.session.setProxy({
proxyRules: newHttpProxy || '',
proxyBypassRules: '',
proxyBypassRules: newNoProxy ? `${newNoProxy},<local>` : '<local>',
pacScript: '',
});
}