Skip to content

Commit

Permalink
fix: remove global-tunnel-ng library (#227)
Browse files Browse the repository at this point in the history
  • Loading branch information
BlackHole1 authored Oct 18, 2022
1 parent 3dd868b commit 4fe5b00
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 53 deletions.
7 changes: 1 addition & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,4 @@ disable, set the `ELECTRON_GET_NO_PROGRESS` environment variable to any non-empt
### Proxies

Downstream packages should utilize the `initializeProxy` function to add HTTP(S) proxy support. If
the environment variable `ELECTRON_GET_USE_PROXY` is set, it is called automatically. A different
proxy module is used, depending on the version of Node in use, and as such, there are slightly
different ways to set the proxy environment variables. For Node 10 and above,
[`global-agent`](https://github.com/gajus/global-agent#environment-variables) is used. Otherwise,
[`global-tunnel-ng`](https://github.com/np-maintain/global-tunnel#auto-config) is used. Refer to the
appropriate linked module to determine how to configure proxy support.
the environment variable `ELECTRON_GET_USE_PROXY` is set, it is called automatically.
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,7 @@
"release"
],
"optionalDependencies": {
"global-agent": "^3.0.0",
"global-tunnel-ng": "^2.7.1"
"global-agent": "^3.0.0"
},
"resolutions": {
"eslint/inquirer": "< 7.3.0",
Expand Down
25 changes: 10 additions & 15 deletions src/proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,18 @@ const d = debug('@electron/get:proxy');
*/
export function initializeProxy(): void {
try {
// Code originally from https://github.com/yeoman/yo/blob/b2eea87e/lib/cli.js#L19-L28
const MAJOR_NODEJS_VERSION = parseInt(process.version.slice(1).split('.')[0], 10);
// See: https://github.com/electron/get/pull/214#discussion_r798845713
const env = getEnv('GLOBAL_AGENT_');

if (MAJOR_NODEJS_VERSION >= 10) {
// See: https://github.com/electron/get/pull/214#discussion_r798845713
const env = getEnv('GLOBAL_AGENT_');
setEnv('GLOBAL_AGENT_HTTP_PROXY', env('HTTP_PROXY'));
setEnv('GLOBAL_AGENT_HTTPS_PROXY', env('HTTPS_PROXY'));
setEnv('GLOBAL_AGENT_NO_PROXY', env('NO_PROXY'));

setEnv('GLOBAL_AGENT_HTTP_PROXY', env('HTTP_PROXY'));
setEnv('GLOBAL_AGENT_HTTPS_PROXY', env('HTTPS_PROXY'));
setEnv('GLOBAL_AGENT_NO_PROXY', env('NO_PROXY'));

// `global-agent` works with Node.js v10 and above.
require('global-agent').bootstrap();
} else {
// `global-tunnel-ng` works with Node.js v10 and below.
require('global-tunnel-ng').initialize();
}
/**
* TODO: replace global-agent with a hpagent. @BlackHole1
* https://github.com/sindresorhus/got/blob/HEAD/documentation/tips.md#proxying
*/
require('global-agent').bootstrap();
} catch (e) {
d('Could not load either proxy modules, built-in proxy support not available:', e);
}
Expand Down
32 changes: 2 additions & 30 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1439,7 +1439,7 @@ concat-stream@^1.5.0:
readable-stream "^2.2.2"
typedarray "^0.0.6"

config-chain@^1.1.11, config-chain@^1.1.12:
config-chain@^1.1.12:
version "1.1.12"
resolved "https://registry.yarnpkg.com/config-chain/-/config-chain-1.1.12.tgz#0fde8d091200eb5e808caf25fe618c02f48e4efa"
integrity sha512-a1eOIcu8+7lUInge4Rpf/n4Krkf3Dd9lqhljRzII1/Zno/kRtUWnznPO3jOKBmTEktkt3fkxisUcivoj0ebzoA==
Expand Down Expand Up @@ -1811,11 +1811,6 @@ emoji-regex@^8.0.0:
resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-8.0.0.tgz#e818fd69ce5ccfcb404594f842963bf53164cc37"
integrity sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==

encodeurl@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/encodeurl/-/encodeurl-1.0.2.tgz#ad3ff4c86ec2d029322f5a02c3a9a606c95b3f59"
integrity sha1-rT/0yG7C0CkyL1oCw6mmBslbP1k=

encoding@^0.1.11:
version "0.1.12"
resolved "https://registry.yarnpkg.com/encoding/-/encoding-0.1.12.tgz#538b66f3ee62cd1ab51ec323829d1f9480c74beb"
Expand Down Expand Up @@ -2618,16 +2613,6 @@ global-dirs@^0.1.0:
dependencies:
ini "^1.3.4"

global-tunnel-ng@^2.7.1:
version "2.7.1"
resolved "https://registry.yarnpkg.com/global-tunnel-ng/-/global-tunnel-ng-2.7.1.tgz#d03b5102dfde3a69914f5ee7d86761ca35d57d8f"
integrity sha512-4s+DyciWBV0eK148wqXxcmVAbFVPqtc3sEtUE/GTQfuU80rySLcMhUmHKSHI7/LDj8q0gDYI1lIhRRB7ieRAqg==
dependencies:
encodeurl "^1.0.2"
lodash "^4.17.10"
npm-conf "^1.1.3"
tunnel "^0.0.6"

globals@^11.1.0:
version "11.11.0"
resolved "https://registry.yarnpkg.com/globals/-/globals-11.11.0.tgz#dcf93757fa2de5486fbeed7118538adf789e9c2e"
Expand Down Expand Up @@ -4264,7 +4249,7 @@ lodash.without@~4.4.0:
resolved "https://registry.yarnpkg.com/lodash.without/-/lodash.without-4.4.0.tgz#3cd4574a00b67bae373a94b748772640507b7aac"
integrity sha1-PNRXSgC2e643OpS3SHcmQFB7eqw=

lodash@^4.17.10, lodash@^4.17.11, lodash@^4.17.14, lodash@^4.17.15, lodash@^4.17.4:
lodash@^4.17.11, lodash@^4.17.14, lodash@^4.17.15, lodash@^4.17.4:
version "4.17.21"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c"
integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==
Expand Down Expand Up @@ -4723,14 +4708,6 @@ npm-cache-filename@~1.0.2:
resolved "https://registry.yarnpkg.com/npm-cache-filename/-/npm-cache-filename-1.0.2.tgz#ded306c5b0bfc870a9e9faf823bc5f283e05ae11"
integrity sha1-3tMGxbC/yHCp6fr4I7xfKD4FrhE=

npm-conf@^1.1.3:
version "1.1.3"
resolved "https://registry.yarnpkg.com/npm-conf/-/npm-conf-1.1.3.tgz#256cc47bd0e218c259c4e9550bf413bc2192aff9"
integrity sha512-Yic4bZHJOt9RCFbRP3GgpqhScOY4HH3V2P8yBj6CeYq118Qr+BLXqT2JvpJ00mryLESpgOxf5XlFv4ZjXxLScw==
dependencies:
config-chain "^1.1.11"
pify "^3.0.0"

npm-install-checks@^3.0.2:
version "3.0.2"
resolved "https://registry.yarnpkg.com/npm-install-checks/-/npm-install-checks-3.0.2.tgz#ab2e32ad27baa46720706908e5b14c1852de44d9"
Expand Down Expand Up @@ -6842,11 +6819,6 @@ tunnel-agent@^0.6.0:
dependencies:
safe-buffer "^5.0.1"

tunnel@^0.0.6:
version "0.0.6"
resolved "https://registry.yarnpkg.com/tunnel/-/tunnel-0.0.6.tgz#72f1314b34a5b192db012324df2cc587ca47f92c"
integrity sha512-1h/Lnq9yajKY2PEbBadPXj3VxsDDu844OnaAo52UVmIzIvwwtBPIuNvkjuzBlTWpfJyUbG3ez0KSBibQkj4ojg==

tweetnacl@^0.14.3, tweetnacl@~0.14.0:
version "0.14.5"
resolved "https://registry.yarnpkg.com/tweetnacl/-/tweetnacl-0.14.5.tgz#5ae68177f192d4456269d108afa93ff8743f4f64"
Expand Down

0 comments on commit 4fe5b00

Please sign in to comment.