proxy.js 918 B

123456789101112131415161718192021222324
  1. import * as debug from 'debug';
  2. import { getEnv, setEnv } from './utils';
  3. const d = debug('@electron/get:proxy');
  4. /**
  5. * Initializes a third-party proxy module for HTTP(S) requests.
  6. */
  7. export function initializeProxy() {
  8. try {
  9. // See: https://github.com/electron/get/pull/214#discussion_r798845713
  10. const env = getEnv('GLOBAL_AGENT_');
  11. setEnv('GLOBAL_AGENT_HTTP_PROXY', env('HTTP_PROXY'));
  12. setEnv('GLOBAL_AGENT_HTTPS_PROXY', env('HTTPS_PROXY'));
  13. setEnv('GLOBAL_AGENT_NO_PROXY', env('NO_PROXY'));
  14. /**
  15. * TODO: replace global-agent with a hpagent. @BlackHole1
  16. * https://github.com/sindresorhus/got/blob/HEAD/documentation/tips.md#proxying
  17. */
  18. require('global-agent').bootstrap();
  19. }
  20. catch (e) {
  21. d('Could not load either proxy modules, built-in proxy support not available:', e);
  22. }
  23. }
  24. //# sourceMappingURL=proxy.js.map