Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
c391faf3
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,体验更适合开发者的 AI 搜索 >>
提交
c391faf3
编写于
10月 29, 2018
作者:
C
Christof Marti
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
_vscodeSystemProxy option (#60773)
上级
1a1c4979
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
38 addition
and
28 deletion
+38
-28
src/vs/workbench/api/node/extHostExtensionService.ts
src/vs/workbench/api/node/extHostExtensionService.ts
+4
-0
src/vs/workbench/node/extensionHostMain.ts
src/vs/workbench/node/extensionHostMain.ts
+0
-2
src/vs/workbench/node/proxyResolver.ts
src/vs/workbench/node/proxyResolver.ts
+34
-26
未找到文件。
src/vs/workbench/api/node/extHostExtensionService.ts
浏览文件 @
c391faf3
...
...
@@ -20,6 +20,7 @@ import { ExtHostStorage } from 'vs/workbench/api/node/extHostStorage';
import
{
ExtHostWorkspace
}
from
'
vs/workbench/api/node/extHostWorkspace
'
;
import
{
IExtensionDescription
}
from
'
vs/workbench/services/extensions/common/extensions
'
;
import
{
ExtensionDescriptionRegistry
}
from
'
vs/workbench/services/extensions/node/extensionDescriptionRegistry
'
;
import
{
connectProxyResolver
}
from
'
vs/workbench/node/proxyResolver
'
;
class
ExtensionMemento
implements
IExtensionMemento
{
...
...
@@ -163,6 +164,9 @@ export class ExtHostExtensionService implements ExtHostExtensionServiceShape {
const
apiFactory
=
createApiFactory
(
initData
,
extHostContext
,
extHostWorkspace
,
extHostConfiguration
,
this
,
this
.
_extHostLogService
,
this
.
_storage
);
initializeExtensionApi
(
this
,
apiFactory
).
then
(()
=>
{
// Do this when extension service exists, but extensions are not being activated yet.
return
connectProxyResolver
(
extHostWorkspace
,
extHostConfiguration
,
this
,
this
.
_extHostLogService
,
this
.
_mainThreadTelemetry
);
}).
then
(()
=>
{
this
.
_activator
=
new
ExtensionsActivator
(
this
.
_registry
,
{
showMessage
:
(
severity
:
Severity
,
message
:
string
):
void
=>
{
...
...
src/vs/workbench/node/extensionHostMain.ts
浏览文件 @
c391faf3
...
...
@@ -20,7 +20,6 @@ import { ExtensionActivatedByEvent } from 'vs/workbench/api/node/extHostExtensio
import
{
ExtHostExtensionService
}
from
'
vs/workbench/api/node/extHostExtensionService
'
;
import
{
ExtHostLogService
}
from
'
vs/workbench/api/node/extHostLogService
'
;
import
{
ExtHostWorkspace
}
from
'
vs/workbench/api/node/extHostWorkspace
'
;
import
{
connectProxyResolver
}
from
'
vs/workbench/node/proxyResolver
'
;
import
{
IExtensionDescription
}
from
'
vs/workbench/services/extensions/common/extensions
'
;
import
{
RPCProtocol
}
from
'
vs/workbench/services/extensions/node/rpcProtocol
'
;
...
...
@@ -92,7 +91,6 @@ export class ExtensionHostMain {
this
.
_extHostConfiguration
=
new
ExtHostConfiguration
(
rpcProtocol
.
getProxy
(
MainContext
.
MainThreadConfiguration
),
extHostWorkspace
,
initData
.
configuration
);
const
mainThreadTelemetry
=
rpcProtocol
.
getProxy
(
MainContext
.
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
浏览文件 @
c391faf3
...
...
@@ -26,7 +26,7 @@ export function connectProxyResolver(
)
{
const
agent
=
createProxyAgent
(
extHostWorkspace
,
extHostLogService
,
mainThreadTelemetry
);
const
lookup
=
createPatchedModules
(
extHostConfiguration
,
agent
);
configureModuleLoading
(
extensionService
,
lookup
);
return
configureModuleLoading
(
extensionService
,
lookup
);
}
function
createProxyAgent
(
...
...
@@ -85,21 +85,23 @@ function createPatchedModules(extHostConfiguration: ExtHostConfiguration, agent:
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
off
:
assign
({},
http
,
patches
(
http
,
agent
,
{
config
:
'
off
'
},
true
)),
on
:
assign
({},
http
,
patches
(
http
,
agent
,
{
config
:
'
on
'
},
true
)),
force
:
assign
({},
http
,
patches
(
http
,
agent
,
{
config
:
'
force
'
},
true
)),
onRequest
:
assign
({},
http
,
patches
(
http
,
agent
,
setting
,
true
)),
default
:
assign
(
http
,
patches
(
http
,
agent
,
setting
,
false
))
// 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
off
:
assign
({},
https
,
patches
(
https
,
agent
,
{
config
:
'
off
'
},
true
)),
on
:
assign
({},
https
,
patches
(
https
,
agent
,
{
config
:
'
on
'
},
true
)),
force
:
assign
({},
https
,
patches
(
https
,
agent
,
{
config
:
'
force
'
},
true
)),
onRequest
:
assign
({},
https
,
patches
(
https
,
agent
,
setting
,
true
)),
default
:
assign
(
https
,
patches
(
https
,
agent
,
setting
,
false
))
// run last
}
};
}
function
patches
(
originals
:
typeof
http
|
typeof
https
,
agent
:
http
.
Agent
,
setting
:
{
config
:
string
;
})
{
function
patches
(
originals
:
typeof
http
|
typeof
https
,
agent
:
http
.
Agent
,
setting
:
{
config
:
string
;
}
,
onRequest
:
boolean
)
{
return
{
get
:
patch
(
originals
.
get
),
...
...
@@ -108,11 +110,6 @@ function patches(originals: typeof http | typeof https, agent: http.Agent, setti
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
);
}
if
(
typeof
url
!==
'
string
'
&&
!
(
url
&&
(
<
any
>
url
).
searchParams
))
{
callback
=
<
any
>
options
;
options
=
url
;
...
...
@@ -124,6 +121,11 @@ function patches(originals: typeof http | typeof https, agent: http.Agent, setti
}
options
=
options
||
{};
const
config
=
onRequest
&&
(
<
any
>
options
).
_vscodeSystemProxy
||
setting
.
config
;
if
(
config
===
'
off
'
)
{
return
original
.
apply
(
null
,
arguments
);
}
if
(
!
options
.
socketPath
&&
(
config
===
'
force
'
||
config
===
'
on
'
&&
!
options
.
agent
))
{
if
(
url
)
{
const
parsed
=
typeof
url
===
'
string
'
?
nodeurl
.
parse
(
url
)
:
url
;
...
...
@@ -145,16 +147,22 @@ function patches(originals: typeof http | typeof https, agent: http.Agent, setti
}
}
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
);
}
function
configureModuleLoading
(
extensionService
:
ExtHostExtensionService
,
lookup
:
ReturnType
<
typeof
createPatchedModules
>
):
Promise
<
void
>
{
return
extensionService
.
getExtensionPathIndex
()
.
then
(
extensionPaths
=>
{
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
);
}
const
ext
=
extensionPaths
.
findSubstr
(
URI
.
file
(
parent
.
filename
).
fsPath
);
return
ext
&&
ext
.
enableProposedApi
&&
lookup
[
request
][(
<
any
>
ext
).
systemProxy
]
||
lookup
[
request
].
default
;
};
const
modules
=
lookup
[
request
];
const
ext
=
extensionPaths
.
findSubstr
(
URI
.
file
(
parent
.
filename
).
fsPath
);
if
(
ext
&&
ext
.
enableProposedApi
)
{
return
modules
[(
<
any
>
ext
).
systemProxy
]
||
modules
.
onRequest
;
}
return
modules
.
default
;
};
});
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录