Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Fix package detail view when behind a proxy #1010

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions lib/atom-io-client.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ class AtomIoClient
@expiry = 1000 * 60 * 60 * 12
@createAvatarCache()
@expireAvatarCache()
@packageManager?.isStrictSsl()
.then (resolve) =>
@strictSsl = resolve
@packageManager?.getHttpsProxy()
.then (resolve) =>
@httpsProxy = resolve


# Public: Get an avatar image from the filesystem, fetching it first if necessary
avatar: (login, callback) ->
Expand Down Expand Up @@ -70,6 +77,10 @@ class AtomIoClient
url: "#{@baseURL}#{path}"
headers: {'User-Agent': navigator.userAgent}
}
if @httpsProxy?
options.proxy = @httpsProxy
if @strictSsl is false
options.rejectUnauthorized = false

request options, (err, res, body) =>
try
Expand Down
39 changes: 39 additions & 0 deletions lib/package-manager.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,45 @@ class PackageManager

handleProcessErrors(apmProcess, errorMessage, callback)

isStrictSsl: ->
new Promise (resolve, reject) =>
args = ['config' , 'get', 'strict-ssl']
errorMessage = 'Checking strict-ssl configuration failed'
apmProcess = @runCommand args, (code, stdout, stderr) ->
if code is 0
if stdout.trim() is 'false'
resolve(false)
else
resolve(true)
else
error = new Error(errorMessage)
error.stdout = stdout
error.stderr = stderr
reject(error)

handleProcessErrors apmProcess, errorMessage, (error) ->
reject(error)

getHttpsProxy: ->
new Promise (resolve, reject) =>
args = ['config' , 'get', 'https-proxy']
errorMessage = 'Checking https-proxy configuration failed'
apmProcess = @runCommand args, (code, stdout, stderr) ->
if code is 0
result = stdout.trim()
if result isnt 'null'
resolve(result)
else
resolve(null)
else
error = new Error(errorMessage)
error.stdout = stdout
error.stderr = stderr
reject(error)

handleProcessErrors apmProcess, errorMessage, (error) ->
reject(error)

getInstalled: ->
new Promise (resolve, reject) =>
@loadInstalled (error, result) ->
Expand Down