Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
eaa5bcfe
V
vscode
项目概览
xxadev
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
eaa5bcfe
编写于
12月 01, 2015
作者:
J
Joao Moreno
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
bring proxy stuff together
add http.proxyStrictSSL option fixes #155
上级
9b6bff15
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
102 addition
and
54 deletion
+102
-54
src/typings/https-proxy-agent.d.ts
src/typings/https-proxy-agent.d.ts
+11
-0
src/vs/base/node/request.ts
src/vs/base/node/request.ts
+0
-34
src/vs/workbench/electron-main/win32/auto-updater.win32.ts
src/vs/workbench/electron-main/win32/auto-updater.win32.ts
+9
-7
src/vs/workbench/node/proxy.ts
src/vs/workbench/node/proxy.ts
+58
-0
src/vs/workbench/parts/extensions/node/extensionsService.ts
src/vs/workbench/parts/extensions/node/extensionsService.ts
+19
-13
src/vs/workbench/services/request/node/requestService.ts
src/vs/workbench/services/request/node/requestService.ts
+5
-0
未找到文件。
src/typings/https-proxy-agent.d.ts
浏览文件 @
eaa5bcfe
...
...
@@ -5,8 +5,19 @@
declare
module
'
https-proxy-agent
'
{
import
*
as
tls
from
'
tls
'
;
interface
IHttpsProxyAgentOptions
extends
tls
.
ConnectionOptions
{
host
:
string
;
port
:
number
;
secureProxy
?:
boolean
;
secureEndpoint
?:
boolean
;
}
class
HttpsProxyAgent
{
constructor
(
proxy
:
string
);
constructor
(
opts
:
IHttpsProxyAgentOptions
);
}
export
=
HttpsProxyAgent
;
}
\ No newline at end of file
src/vs/base/node/request.ts
浏览文件 @
eaa5bcfe
...
...
@@ -11,8 +11,6 @@ import http = require('http');
import
{
Url
,
parse
as
parseUrl
}
from
'
url
'
;
import
{
createWriteStream
}
from
'
fs
'
;
import
{
assign
}
from
'
vs/base/common/objects
'
;
import
HttpProxyAgent
=
require
(
'
http-proxy-agent
'
);
import
HttpsProxyAgent
=
require
(
'
https-proxy-agent
'
);
export
interface
IRequestOptions
{
type
?:
string
;
...
...
@@ -100,36 +98,4 @@ export function json<T>(opts: IRequestOptions): TPromise<T> {
pair
.
res
.
on
(
'
end
'
,
()
=>
c
(
JSON
.
parse
(
buffer
.
join
(
''
))));
pair
.
res
.
on
(
'
error
'
,
e
);
}));
}
function
getSystemProxyURI
(
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
(
rawRequestURL
:
string
,
proxyURL
:
string
):
any
{
let
requestURL
=
parseUrl
(
rawRequestURL
);
let
proxyEndpoint
=
parseUrl
(
proxyURL
);
if
(
!
/^https
?
:$/
.
test
(
proxyEndpoint
.
protocol
))
{
return
null
;
}
return
requestURL
.
protocol
===
'
http:
'
?
new
HttpProxyAgent
(
proxyURL
)
:
new
HttpsProxyAgent
(
proxyURL
);
}
export
function
getSystemProxyAgent
(
rawRequestURL
:
string
):
any
{
let
requestURL
=
parseUrl
(
rawRequestURL
);
let
proxyURL
=
getSystemProxyURI
(
requestURL
);
if
(
!
proxyURL
)
{
return
null
;
}
return
getProxyAgent
(
rawRequestURL
,
proxyURL
);
}
\ No newline at end of file
src/vs/workbench/electron-main/win32/auto-updater.win32.ts
浏览文件 @
eaa5bcfe
...
...
@@ -17,7 +17,8 @@ import {ClientRequest} from 'http';
import
{
mkdirp
}
from
'
vs/base/node/extfs
'
;
import
{
isString
}
from
'
vs/base/common/types
'
;
import
{
Promise
,
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
IRequestOptions
,
download
,
json
,
getProxyAgent
,
getSystemProxyAgent
}
from
'
vs/base/node/request
'
;
import
{
IRequestOptions
,
download
,
json
}
from
'
vs/base/node/request
'
;
import
{
getProxyAgent
}
from
'
vs/workbench/node/proxy
'
;
import
{
manager
as
Settings
}
from
'
vs/workbench/electron-main/settings
'
;
import
{
manager
as
Lifecycle
}
from
'
vs/workbench/electron-main/lifecycle
'
;
...
...
@@ -53,11 +54,11 @@ export class Win32AutoUpdaterImpl extends events.EventEmitter implements IAutoUp
this
.
emit
(
'
checking-for-update
'
);
const
httpProxySettings
=
Settings
.
getValue
(
'
http.proxy
'
);
const
getAgent
=
url
=>
httpProxySettings
?
getProxyAgent
(
url
,
httpProxySettings
)
:
getSystemProxyAgent
(
url
);
const
proxyUrl
=
Settings
.
getValue
(
'
http.proxy
'
);
const
strictSSL
=
Settings
.
getValue
(
'
http.proxy.strictSSL
'
,
true
);
const
agent
=
getProxyAgent
(
this
.
url
,
{
proxyUrl
,
strictSSL
});
this
.
currentRequest
=
json
<
IUpdate
>
({
url
:
this
.
url
,
agent
:
getAgent
(
this
.
url
)
})
this
.
currentRequest
=
json
<
IUpdate
>
({
url
:
this
.
url
,
agent
})
.
then
(
update
=>
{
if
(
!
update
||
!
update
.
url
||
!
update
.
version
)
{
this
.
emit
(
'
update-not-available
'
);
...
...
@@ -73,9 +74,10 @@ export class Win32AutoUpdaterImpl extends events.EventEmitter implements IAutoUp
return
TPromise
.
as
(
updatePackagePath
);
}
let
downloadPath
=
`
${
updatePackagePath
}
.tmp`
;
const
downloadPath
=
`
${
updatePackagePath
}
.tmp`
;
const
agent
=
getProxyAgent
(
update
.
url
,
{
proxyUrl
,
strictSSL
});
return
download
(
downloadPath
,
{
url
:
update
.
url
,
agent
:
getAgent
(
update
.
url
)
})
return
download
(
downloadPath
,
{
url
:
update
.
url
,
agent
})
.
then
(()
=>
pfs
.
rename
(
downloadPath
,
updatePackagePath
))
.
then
(()
=>
updatePackagePath
);
});
...
...
src/vs/workbench/node/proxy.ts
0 → 100644
浏览文件 @
eaa5bcfe
import
{
Url
,
parse
as
parseUrl
}
from
'
url
'
;
import
HttpProxyAgent
=
require
(
'
http-proxy-agent
'
);
import
HttpsProxyAgent
=
require
(
'
https-proxy-agent
'
);
function
getAgent
(
rawRequestURL
:
string
,
proxyURL
:
string
,
strictSSL
:
boolean
=
true
):
any
{
let
requestURL
=
parseUrl
(
rawRequestURL
);
let
proxyEndpoint
=
parseUrl
(
proxyURL
);
if
(
!
/^https
?
:$/
.
test
(
proxyEndpoint
.
protocol
))
{
return
null
;
}
if
(
requestURL
.
protocol
===
'
http:
'
)
{
return
new
HttpProxyAgent
(
proxyURL
);
}
return
new
HttpsProxyAgent
({
host
:
proxyEndpoint
.
host
,
port
:
Number
(
proxyEndpoint
.
port
),
rejectUnauthorized
:
strictSSL
});
}
function
getSystemProxyURI
(
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
;
}
function
getSystemProxyAgent
(
rawRequestURL
:
string
):
any
{
let
requestURL
=
parseUrl
(
rawRequestURL
);
let
proxyURL
=
getSystemProxyURI
(
requestURL
);
if
(
!
proxyURL
)
{
return
null
;
}
return
getAgent
(
rawRequestURL
,
proxyURL
);
}
export
interface
IOptions
{
proxyUrl
?:
string
;
strictSSL
?:
boolean
;
}
export
function
getProxyAgent
(
rawRequestURL
:
string
,
options
:
IOptions
=
{}):
any
{
console
.
log
(
rawRequestURL
,
options
);
if
(
!
options
.
proxyUrl
)
{
return
getSystemProxyAgent
(
rawRequestURL
);
}
return
getAgent
(
rawRequestURL
,
options
.
proxyUrl
,
options
.
strictSSL
);
}
\ No newline at end of file
src/vs/workbench/parts/extensions/node/extensionsService.ts
浏览文件 @
eaa5bcfe
...
...
@@ -16,7 +16,8 @@ import { assign } from 'vs/base/common/objects';
import
{
extract
,
buffer
}
from
'
vs/base/node/zip
'
;
import
{
Promise
,
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
IExtensionsService
,
IExtension
,
IExtensionManifest
,
IGalleryInformation
}
from
'
vs/workbench/parts/extensions/common/extensions
'
;
import
{
download
,
getProxyAgent
,
getSystemProxyAgent
}
from
'
vs/base/node/request
'
;
import
{
download
}
from
'
vs/base/node/request
'
;
import
{
getProxyAgent
}
from
'
vs/workbench/node/proxy
'
;
import
{
IWorkspaceContextService
}
from
'
vs/workbench/services/workspace/common/contextService
'
;
import
{
Limiter
}
from
'
vs/base/common/async
'
;
import
Event
,
{
Emitter
}
from
'
vs/base/common/event
'
;
...
...
@@ -121,18 +122,23 @@ export class ExtensionsService implements IExtensionsService {
const
extensionPath
=
path
.
join
(
this
.
extensionsPath
,
`
${
extension
.
publisher
}
.
${
extension
.
name
}
`
);
const
manifestPath
=
path
.
join
(
extensionPath
,
'
package.json
'
);
return
UserSettings
.
getValue
(
this
.
contextService
,
'
http.proxy
'
).
then
((
httpProxySettings
)
=>
{
const
getAgent
=
url
=>
httpProxySettings
?
getProxyAgent
(
url
,
httpProxySettings
)
:
getSystemProxyAgent
(
url
);
return
download
(
zipPath
,
{
url
:
url
,
agent
:
getAgent
(
url
)
})
.
then
(()
=>
validate
(
zipPath
,
extension
))
.
then
(
manifest
=>
{
this
.
_onInstallExtension
.
fire
(
manifest
);
return
manifest
;
})
.
then
(
manifest
=>
extract
(
zipPath
,
extensionPath
,
{
sourcePath
:
'
extension
'
,
overwrite
:
true
}).
then
(()
=>
manifest
))
.
then
(
manifest
=>
{
manifest
=
assign
({
__metadata
:
galleryInformation
},
manifest
);
return
pfs
.
writeFile
(
manifestPath
,
JSON
.
stringify
(
manifest
,
null
,
'
\t
'
));
})
.
then
(()
=>
{
this
.
_onDidInstallExtension
.
fire
(
extension
);
return
extension
;
});
});
const
settings
=
TPromise
.
join
([
UserSettings
.
getValue
(
this
.
contextService
,
'
http.proxy
'
),
UserSettings
.
getValue
(
this
.
contextService
,
'
http.proxy.strictSSL
'
)
]);
return
settings
.
then
(
settings
=>
({
proxyUrl
:
settings
[
0
],
strictSSL
:
settings
[
1
]
}))
.
then
(
options
=>
getProxyAgent
(
url
,
options
))
.
then
(
agent
=>
download
(
zipPath
,
{
url
,
agent
}))
.
then
(()
=>
validate
(
zipPath
,
extension
))
.
then
(
manifest
=>
{
this
.
_onInstallExtension
.
fire
(
manifest
);
return
manifest
;
})
.
then
(
manifest
=>
extract
(
zipPath
,
extensionPath
,
{
sourcePath
:
'
extension
'
,
overwrite
:
true
}).
then
(()
=>
manifest
))
.
then
(
manifest
=>
{
manifest
=
assign
({
__metadata
:
galleryInformation
},
manifest
);
return
pfs
.
writeFile
(
manifestPath
,
JSON
.
stringify
(
manifest
,
null
,
'
\t
'
));
})
.
then
(()
=>
{
this
.
_onDidInstallExtension
.
fire
(
extension
);
return
extension
;
});
}
private
installFromZip
(
zipPath
:
string
):
TPromise
<
IExtension
>
{
...
...
src/vs/workbench/services/request/node/requestService.ts
浏览文件 @
eaa5bcfe
...
...
@@ -125,6 +125,11 @@ confRegistry.registerConfiguration({
'
http.proxy
'
:
{
'
type
'
:
'
string
'
,
'
description
'
:
nls
.
localize
(
'
proxy
'
,
"
The proxy setting to use. If not set will be taken from the http_proxy and https_proxy environment variables
"
)
},
'
http.proxyStrictSSL
'
:
{
'
type
'
:
'
boolean
'
,
'
default
'
:
true
,
'
description
'
:
nls
.
localize
(
'
strictSSL
'
,
"
Whether the proxy server certificate should be verified against the list of supplied CAs.
"
)
}
}
});
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录