Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
1737fde4
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,发现更多精彩内容 >>
提交
1737fde4
编写于
10月 28, 2018
作者:
C
Christof Marti
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Per extension (#60773)
上级
d9342838
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
70 addition
and
11 deletion
+70
-11
src/vs/workbench/node/extensionHostMain.ts
src/vs/workbench/node/extensionHostMain.ts
+1
-1
src/vs/workbench/node/proxyResolver.ts
src/vs/workbench/node/proxyResolver.ts
+69
-10
未找到文件。
src/vs/workbench/node/extensionHostMain.ts
浏览文件 @
1737fde4
...
...
@@ -91,8 +91,8 @@ export class ExtensionHostMain {
this
.
_extHostConfiguration
=
new
ExtHostConfiguration
(
rpcProtocol
.
getProxy
(
MainContext
.
MainThreadConfiguration
),
extHostWorkspace
,
initData
.
configuration
);
const
mainThreadTelemetry
=
rpcProtocol
.
getProxy
(
MainContext
.
MainThreadTelemetry
);
connectProxyResolver
(
extHostWorkspace
,
this
.
_extHostConfiguration
,
this
.
_extHostLogService
,
mainThreadTelemetry
);
this
.
_extensionService
=
new
ExtHostExtensionService
(
initData
,
rpcProtocol
,
extHostWorkspace
,
this
.
_extHostConfiguration
,
this
.
_extHostLogService
,
mainThreadTelemetry
);
connectProxyResolver
(
extHostWorkspace
,
this
.
_extHostConfiguration
,
this
.
_extensionService
,
this
.
_extHostLogService
,
mainThreadTelemetry
);
// error forwarding and stack trace scanning
Error
.
stackTraceLimit
=
100
;
// increase number of stack frames (from 10, https://github.com/v8/v8/wiki/Stack-Trace-API)
...
...
src/vs/workbench/node/proxyResolver.ts
浏览文件 @
1737fde4
...
...
@@ -3,17 +3,37 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import
{
ExtHostWorkspace
}
from
'
vs/workbench/api/node/extHostWorkspace
'
;
import
{
ExtHostConfiguration
}
from
'
vs/workbench/api/node/extHostConfiguration
'
;
import
*
as
http
from
'
http
'
;
import
*
as
https
from
'
https
'
;
import
*
as
nodeurl
from
'
url
'
;
import
{
assign
}
from
'
vs/base/common/objects
'
;
import
{
ExtHostWorkspace
}
from
'
vs/workbench/api/node/extHostWorkspace
'
;
import
{
ExtHostConfiguration
}
from
'
vs/workbench/api/node/extHostConfiguration
'
;
import
{
ProxyAgent
}
from
'
vscode-proxy-agent
'
;
import
{
MainThreadTelemetryShape
}
from
'
vs/workbench/api/node/extHost.protocol
'
;
import
{
ExtHostLogService
}
from
'
vs/workbench/api/node/extHostLogService
'
;
import
{
toErrorMessage
}
from
'
vs/base/common/errorMessage
'
;
import
{
ExtHostExtensionService
}
from
'
vs/workbench/api/node/extHostExtensionService
'
;
import
{
URI
}
from
'
vs/base/common/uri
'
;
export
function
connectProxyResolver
(
extHostWorkspace
:
ExtHostWorkspace
,
extHostConfiguration
:
ExtHostConfiguration
,
extensionService
:
ExtHostExtensionService
,
extHostLogService
:
ExtHostLogService
,
mainThreadTelemetry
:
MainThreadTelemetryShape
)
{
const
agent
=
createProxyAgent
(
extHostWorkspace
,
extHostLogService
,
mainThreadTelemetry
);
const
lookup
=
createPatchedModules
(
extHostConfiguration
,
agent
);
configureModuleLoading
(
extensionService
,
lookup
);
}
export
function
connectProxyResolver
(
extHostWorkspace
:
ExtHostWorkspace
,
extHostConfiguration
:
ExtHostConfiguration
,
extHostLogService
:
ExtHostLogService
,
mainThreadTelemetry
:
MainThreadTelemetryShape
)
{
function
createProxyAgent
(
extHostWorkspace
:
ExtHostWorkspace
,
extHostLogService
:
ExtHostLogService
,
mainThreadTelemetry
:
MainThreadTelemetryShape
)
{
let
timeout
:
NodeJS
.
Timer
|
undefined
;
let
count
=
0
;
let
duration
=
0
;
...
...
@@ -50,15 +70,45 @@ export function connectProxyResolver(extHostWorkspace: ExtHostWorkspace, extHost
});
}
const
agent
=
new
ProxyAgent
({
resolveProxy
});
return
new
ProxyAgent
({
resolveProxy
});
}
let
config
=
extHostConfiguration
.
getConfiguration
(
'
http
'
).
get
(
'
systemProxy
'
)
||
'
off
'
;
function
createPatchedModules
(
extHostConfiguration
:
ExtHostConfiguration
,
agent
:
http
.
Agent
)
{
const
setting
=
{
config
:
extHostConfiguration
.
getConfiguration
(
'
http
'
)
.
get
<
string
>
(
'
systemProxy
'
)
||
'
off
'
};
extHostConfiguration
.
onDidChangeConfiguration
(
e
=>
{
config
=
extHostConfiguration
.
getConfiguration
(
'
http
'
).
get
(
'
systemProxy
'
)
||
'
off
'
;
setting
.
config
=
extHostConfiguration
.
getConfiguration
(
'
http
'
)
.
get
<
string
>
(
'
systemProxy
'
)
||
'
off
'
;
});
return
{
http
:
{
off
:
assign
({},
http
),
on
:
assign
({},
http
,
patches
(
http
,
agent
,
{
config
:
'
on
'
})),
force
:
assign
({},
http
,
patches
(
http
,
agent
,
{
config
:
'
force
'
})),
default
:
assign
(
http
,
patches
(
http
,
agent
,
setting
))
// run last
},
https
:
{
off
:
assign
({},
https
),
on
:
assign
({},
https
,
patches
(
https
,
agent
,
{
config
:
'
on
'
})),
force
:
assign
({},
https
,
patches
(
https
,
agent
,
{
config
:
'
force
'
})),
default
:
assign
(
https
,
patches
(
https
,
agent
,
setting
))
// run last
}
};
}
function
patches
(
originals
:
typeof
http
|
typeof
https
,
agent
:
http
.
Agent
,
setting
:
{
config
:
string
;
})
{
return
{
get
:
patch
(
originals
.
get
),
request
:
patch
(
originals
.
request
)
};
function
patch
(
original
:
typeof
http
.
get
)
{
function
patched
(
url
:
string
|
URL
,
options
?:
http
.
RequestOptions
,
callback
?:
(
res
:
http
.
IncomingMessage
)
=>
void
):
http
.
ClientRequest
{
const
{
config
}
=
setting
;
if
(
config
===
'
off
'
)
{
return
original
.
apply
(
null
,
arguments
);
}
...
...
@@ -93,9 +143,18 @@ export function connectProxyResolver(extHostWorkspace: ExtHostWorkspace, extHost
}
return
patched
;
}
}
async
function
configureModuleLoading
(
extensionService
:
ExtHostExtensionService
,
lookup
:
ReturnType
<
typeof
createPatchedModules
>
):
Promise
<
void
>
{
const
extensionPaths
=
await
extensionService
.
getExtensionPathIndex
();
const
node_module
=
<
any
>
require
.
__$__nodeRequire
(
'
module
'
);
const
original
=
node_module
.
_load
;
node_module
.
_load
=
function
load
(
request
:
string
,
parent
:
any
,
isMain
:
any
)
{
if
(
request
!==
'
http
'
&&
request
!==
'
https
'
)
{
return
original
.
apply
(
this
,
arguments
);
}
(
<
any
>
http
).
get
=
patch
(
http
.
get
);
(
<
any
>
http
).
request
=
patch
(
http
.
request
);
(
<
any
>
https
).
get
=
patch
(
https
.
get
);
(
<
any
>
https
).
request
=
patch
(
https
.
request
);
const
ext
=
extensionPaths
.
findSubstr
(
URI
.
file
(
parent
.
filename
).
fsPath
);
return
ext
&&
ext
.
enableProposedApi
&&
lookup
[
request
][(
<
any
>
ext
).
systemProxy
]
||
lookup
[
request
].
default
;
};
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录