-
Notifications
You must be signed in to change notification settings - Fork 724
Fix respecting a system or user configured proxy. #350
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
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
b8f01e4
Fix respecting a system or user configured proxy.
37c9053
Revert unintended change to package.json.
s5no5t a6f0559
Comment out the omnisharp:fetch gulp task as it doesn't work when dow…
s5no5t f0b4441
Revert empty runtime setting change. Weird that this was changed at all.
s5no5t File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
|
||
'use strict'; | ||
|
||
import { Url, parse as parseUrl } from 'url'; | ||
import HttpProxyAgent = require('http-proxy-agent'); | ||
import HttpsProxyAgent = require('https-proxy-agent'); | ||
import {workspace} from 'vscode'; | ||
|
||
function getSystemProxyURL(requestURL: Url): string { | ||
if (requestURL.protocol === 'http:') { | ||
return process.env.HTTP_PROXY || process.env.http_proxy || null; | ||
} else if (requestURL.protocol === 'https:') { | ||
return process.env.HTTPS_PROXY || process.env.https_proxy || process.env.HTTP_PROXY || process.env.http_proxy || null; | ||
} | ||
|
||
return null; | ||
} | ||
|
||
export function getProxyAgent(requestURL: Url): any { | ||
const vsConfigProxyUrl = workspace.getConfiguration().get<string>('http.proxy'); | ||
const proxyURL = vsConfigProxyUrl || getSystemProxyURL(requestURL); | ||
|
||
if (!proxyURL) { | ||
return null; | ||
} | ||
|
||
const proxyEndpoint = parseUrl(proxyURL); | ||
|
||
if (!/^https?:$/.test(proxyEndpoint.protocol)) { | ||
return null; | ||
} | ||
|
||
const strictSSL = workspace.getConfiguration().get('http.proxyStrictSSL', true); | ||
const opts = { | ||
host: proxyEndpoint.hostname, | ||
port: Number(proxyEndpoint.port), | ||
auth: proxyEndpoint.auth, | ||
rejectUnauthorized: strictSSL | ||
}; | ||
|
||
return requestURL.protocol === 'http:' ? new HttpProxyAgent(opts) : new HttpsProxyAgent(opts); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
|
||
declare module 'http-proxy-agent' { | ||
|
||
interface IHttpProxyAgentOptions { | ||
host: string; | ||
port: number; | ||
auth?: string; | ||
} | ||
|
||
class HttpProxyAgent { | ||
constructor(proxy: string); | ||
constructor(opts: IHttpProxyAgentOptions); | ||
} | ||
|
||
export = HttpProxyAgent; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
|
||
declare module 'https-proxy-agent' { | ||
|
||
import * as tls from 'tls'; | ||
|
||
interface IHttpsProxyAgentOptions extends tls.ConnectionOptions { | ||
host: string; | ||
port: number; | ||
auth?: string; | ||
secureProxy?: boolean; | ||
secureEndpoint?: boolean; | ||
} | ||
|
||
class HttpsProxyAgent { | ||
constructor(proxy: string); | ||
constructor(opts: IHttpsProxyAgentOptions); | ||
} | ||
|
||
export = HttpsProxyAgent; | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sigh... I wish we didn't have to copy and paste this from VS Code and could just leverage their that's already running. But, 👍