New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply Chromium proxies to env vars for apm #898

Merged
merged 1 commit into from Jan 19, 2017

Conversation

Projects
None yet
2 participants
@damieng
Contributor

damieng commented Jan 12, 2017

Description of the Change

Chromium does a good job at reading system proxy settings which means a lot of what Atom needs to do goes through the correct proxies.

The apm command line being a regular node app and not an Electron/Chromium app does not read or have access to these proxy settings and so fails when trying to connect if you are using a proxy.

This change determines what http and https proxy servers to use based on Chromium's session.resolveProxy call with atom.io and then sets the http_proxy and https_proxy environment variables that apm then uses.

Alternate Designs

Alternative designs include;

  1. Moving apm functionality entirely into Atom - too much work at this time and would mess up command-line scripting
  2. Editing the apm.rc file with the proxy settings - too destructive

Benefits

People behind proxy servers can use apm with no effort.

Possible Drawbacks

Users with manually set http_proxy and https_proxy environment variables will find we override their preferences. They can switch off the auto-detect proxy in settings.

Show outdated Hide outdated lib/package-manager.coffee
@@ -37,6 +37,22 @@ class PackageManager
schema = atom.config.getSchema(packageName)
schema? and (schema.type isnt 'any')
setProxyServers: (callback) =>
callback() if atom.config.get('core.useProxySettingsWhenCallingApm') isnt true

This comment has been minimized.

@50Wliu

50Wliu Jan 12, 2017

Member
callback() unless atom.config.get('core.useProxySettingsWhenCallingApm')

seems cleaner.

@50Wliu

50Wliu Jan 12, 2017

Member
callback() unless atom.config.get('core.useProxySettingsWhenCallingApm')

seems cleaner.

@50Wliu

This comment has been minimized.

Show comment
Hide comment
@50Wliu

50Wliu Jan 12, 2017

Member

Also, this looks like it only gets used with runCommand, so maybe setProxyServers can be moved to inside runCommand?

Member

50Wliu commented Jan 12, 2017

Also, this looks like it only gets used with runCommand, so maybe setProxyServers can be moved to inside runCommand?

@damieng

This comment has been minimized.

Show comment
Hide comment
@damieng

damieng Jan 12, 2017

Contributor

I originally had it in runCommand but the problem is that runCommand immediately passed back a BufferedProcess object that things attach to - this being async it couldn't do that immediately. Breaks everywhere.

Contributor

damieng commented Jan 12, 2017

I originally had it in runCommand but the problem is that runCommand immediately passed back a BufferedProcess object that things attach to - this being async it couldn't do that immediately. Breaks everywhere.

@damieng damieng merged commit 4fa5305 into master Jan 19, 2017

1 of 2 checks passed

continuous-integration/travis-ci/pr The Travis CI build is in progress
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details

@damieng damieng deleted the dg-apply-proxy-to-apm branch Jan 19, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment