Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
71570aa4
V
vscode
项目概览
掘金者说
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
71570aa4
编写于
1月 20, 2020
作者:
A
Alex Ross
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add candidate port filtering to proposed API
上级
872096e1
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
66 addition
and
26 deletion
+66
-26
src/vs/platform/remote/common/remoteAuthorityResolver.ts
src/vs/platform/remote/common/remoteAuthorityResolver.ts
+0
-1
src/vs/vscode.proposed.d.ts
src/vs/vscode.proposed.d.ts
+5
-1
src/vs/workbench/api/browser/mainThreadTunnelService.ts
src/vs/workbench/api/browser/mainThreadTunnelService.ts
+16
-0
src/vs/workbench/api/common/extHost.protocol.ts
src/vs/workbench/api/common/extHost.protocol.ts
+2
-0
src/vs/workbench/api/common/extHostExtensionService.ts
src/vs/workbench/api/common/extHostExtensionService.ts
+2
-2
src/vs/workbench/api/common/extHostTunnelService.ts
src/vs/workbench/api/common/extHostTunnelService.ts
+5
-2
src/vs/workbench/api/node/extHostTunnelService.ts
src/vs/workbench/api/node/extHostTunnelService.ts
+18
-7
src/vs/workbench/services/remote/common/remoteExplorerService.ts
...workbench/services/remote/common/remoteExplorerService.ts
+18
-13
未找到文件。
src/vs/platform/remote/common/remoteAuthorityResolver.ts
浏览文件 @
71570aa4
...
...
@@ -23,7 +23,6 @@ export interface TunnelDescription {
}
export
interface
TunnelInformation
{
environmentTunnels
?:
TunnelDescription
[];
hideCandidatePorts
?:
boolean
;
}
export
interface
ResolverResult
{
...
...
src/vs/vscode.proposed.d.ts
浏览文件 @
71570aa4
...
...
@@ -108,7 +108,6 @@ declare module 'vscode' {
*/
environmentTunnels
?:
TunnelDescription
[];
hideCandidatePorts
?:
boolean
;
}
export
type
ResolverResult
=
ResolvedAuthority
&
ResolvedOptions
&
TunnelInformation
;
...
...
@@ -128,6 +127,11 @@ declare module 'vscode' {
* When implemented, the core will use this to forward ports.
*/
tunnelFactory
?:
(
tunnelOptions
:
TunnelOptions
)
=>
Thenable
<
Tunnel
>
|
undefined
;
/**
* Provides filtering for candidate ports.
*/
showCandidatePort
?:
(
host
:
string
,
port
:
number
,
detail
:
string
)
=>
Thenable
<
boolean
>
;
}
export
namespace
workspace
{
...
...
src/vs/workbench/api/browser/mainThreadTunnelService.ts
浏览文件 @
71570aa4
...
...
@@ -59,6 +59,22 @@ export class MainThreadTunnelService implements MainThreadTunnelServiceShape {
this
.
tunnelService
.
setTunnelProvider
(
tunnelProvider
);
}
async
$setCandidateFilter
():
Promise
<
void
>
{
this
.
remoteExplorerService
.
setCandidateFilter
(
async
(
candidates
:
{
host
:
string
,
port
:
number
,
detail
:
string
}[]):
Promise
<
{
host
:
string
,
port
:
number
,
detail
:
string
}[]
>
=>
{
const
filters
:
boolean
[]
=
await
this
.
_proxy
.
$filterCandidates
(
candidates
);
const
filteredCandidates
:
{
host
:
string
,
port
:
number
,
detail
:
string
}[]
=
[];
if
(
filters
.
length
!==
candidates
.
length
)
{
return
candidates
;
}
for
(
let
i
=
0
;
i
<
candidates
.
length
;
i
++
)
{
if
(
filters
[
i
])
{
filteredCandidates
.
push
(
candidates
[
i
]);
}
}
return
filteredCandidates
;
});
}
dispose
():
void
{
//
}
...
...
src/vs/workbench/api/common/extHost.protocol.ts
浏览文件 @
71570aa4
...
...
@@ -787,6 +787,7 @@ export interface MainThreadTunnelServiceShape extends IDisposable {
$closeTunnel
(
remote
:
{
host
:
string
,
port
:
number
}):
Promise
<
void
>
;
$registerCandidateFinder
():
Promise
<
void
>
;
$setTunnelProvider
():
Promise
<
void
>
;
$setCandidateFilter
():
Promise
<
void
>
;
}
// -- extension host
...
...
@@ -1421,6 +1422,7 @@ export interface MainThreadThemingShape extends IDisposable {
export
interface
ExtHostTunnelServiceShape
{
$findCandidatePorts
():
Promise
<
{
host
:
string
,
port
:
number
,
detail
:
string
}[]
>
;
$filterCandidates
(
candidates
:
{
host
:
string
,
port
:
number
,
detail
:
string
}[]):
Promise
<
boolean
[]
>
;
$forwardPort
(
tunnelOptions
:
TunnelOptions
):
Promise
<
TunnelDto
>
|
undefined
;
$closeTunnel
(
remote
:
{
host
:
string
,
port
:
number
}):
Promise
<
void
>
;
}
...
...
src/vs/workbench/api/common/extHostExtensionService.ts
浏览文件 @
71570aa4
...
...
@@ -645,7 +645,7 @@ export abstract class AbstractExtHostExtensionService implements ExtHostExtensio
try
{
const
result
=
await
resolver
.
resolve
(
remoteAuthority
,
{
resolveAttempt
});
this
.
_disposables
.
add
(
await
this
.
_extHostTunnelService
.
set
ForwardPortProvider
(
resolver
));
this
.
_disposables
.
add
(
await
this
.
_extHostTunnelService
.
set
TunnelExtensionFunctions
(
resolver
));
// Split merged API result into separate authority/options
const
authority
:
ResolvedAuthority
=
{
...
...
@@ -662,7 +662,7 @@ export abstract class AbstractExtHostExtensionService implements ExtHostExtensio
value
:
{
authority
,
options
,
tunnelInformation
:
{
environmentTunnels
:
result
.
environmentTunnels
,
hideCandidatePorts
:
result
.
hideCandidatePorts
}
tunnelInformation
:
{
environmentTunnels
:
result
.
environmentTunnels
}
}
};
}
catch
(
err
)
{
...
...
src/vs/workbench/api/common/extHostTunnelService.ts
浏览文件 @
71570aa4
...
...
@@ -31,7 +31,7 @@ export interface Tunnel extends vscode.Disposable {
export
interface
IExtHostTunnelService
extends
ExtHostTunnelServiceShape
{
readonly
_serviceBrand
:
undefined
;
openTunnel
(
forward
:
TunnelOptions
):
Promise
<
vscode
.
Tunnel
|
undefined
>
;
set
ForwardPortProvider
(
provider
:
vscode
.
RemoteAuthorityResolver
|
undefined
):
Promise
<
IDisposable
>
;
set
TunnelExtensionFunctions
(
provider
:
vscode
.
RemoteAuthorityResolver
|
undefined
):
Promise
<
IDisposable
>
;
}
export
const
IExtHostTunnelService
=
createDecorator
<
IExtHostTunnelService
>
(
'
IExtHostTunnelService
'
);
...
...
@@ -44,7 +44,10 @@ export class ExtHostTunnelService implements IExtHostTunnelService {
async
$findCandidatePorts
():
Promise
<
{
host
:
string
,
port
:
number
;
detail
:
string
;
}[]
>
{
return
[];
}
async
setForwardPortProvider
(
provider
:
vscode
.
RemoteAuthorityResolver
|
undefined
):
Promise
<
IDisposable
>
{
return
{
dispose
:
()
=>
{
}
};
}
async
$filterCandidates
(
candidates
:
{
host
:
string
,
port
:
number
,
detail
:
string
}[]):
Promise
<
boolean
[]
>
{
return
candidates
.
map
(()
=>
true
);
}
async
setTunnelExtensionFunctions
(
provider
:
vscode
.
RemoteAuthorityResolver
|
undefined
):
Promise
<
IDisposable
>
{
return
{
dispose
:
()
=>
{
}
};
}
$forwardPort
(
tunnelOptions
:
TunnelOptions
):
Promise
<
TunnelDto
>
|
undefined
{
return
undefined
;
}
async
$closeTunnel
(
remote
:
{
host
:
string
,
port
:
number
}):
Promise
<
void
>
{
}
...
...
src/vs/workbench/api/node/extHostTunnelService.ts
浏览文件 @
71570aa4
...
...
@@ -37,6 +37,7 @@ export class ExtHostTunnelService extends Disposable implements IExtHostTunnelSe
readonly
_serviceBrand
:
undefined
;
private
readonly
_proxy
:
MainThreadTunnelServiceShape
;
private
_forwardPortProvider
:
((
tunnelOptions
:
TunnelOptions
)
=>
Thenable
<
vscode
.
Tunnel
>
|
undefined
)
|
undefined
;
private
_showCandidatePort
:
(
host
:
string
,
port
:
number
,
detail
:
string
)
=>
Thenable
<
boolean
>
=
()
=>
{
return
Promise
.
resolve
(
true
);
};
private
_extensionTunnels
:
Map
<
string
,
Map
<
number
,
vscode
.
Tunnel
>>
=
new
Map
();
constructor
(
...
...
@@ -65,10 +66,22 @@ export class ExtHostTunnelService extends Disposable implements IExtHostTunnelSe
return
this
.
_proxy
.
$registerCandidateFinder
();
}
async
setForwardPortProvider
(
provider
:
vscode
.
RemoteAuthorityResolver
|
undefined
):
Promise
<
IDisposable
>
{
if
(
provider
&&
provider
.
tunnelFactory
)
{
this
.
_forwardPortProvider
=
provider
.
tunnelFactory
;
await
this
.
_proxy
.
$setTunnelProvider
();
$filterCandidates
(
candidates
:
{
host
:
string
,
port
:
number
,
detail
:
string
}[]):
Promise
<
boolean
[]
>
{
return
Promise
.
all
(
candidates
.
map
(
candidate
=>
{
return
this
.
_showCandidatePort
(
candidate
.
host
,
candidate
.
port
,
candidate
.
detail
);
}));
}
async
setTunnelExtensionFunctions
(
provider
:
vscode
.
RemoteAuthorityResolver
|
undefined
):
Promise
<
IDisposable
>
{
if
(
provider
)
{
if
(
provider
.
showCandidatePort
)
{
this
.
_showCandidatePort
=
provider
.
showCandidatePort
;
await
this
.
_proxy
.
$setCandidateFilter
();
}
if
(
provider
.
tunnelFactory
)
{
this
.
_forwardPortProvider
=
provider
.
tunnelFactory
;
await
this
.
_proxy
.
$setTunnelProvider
();
}
}
else
{
this
.
_forwardPortProvider
=
undefined
;
}
...
...
@@ -128,9 +141,7 @@ export class ExtHostTunnelService extends Disposable implements IExtHostTunnelSe
const
childStat
=
fs
.
statSync
(
childUri
.
fsPath
);
if
(
childStat
.
isDirectory
()
&&
!
isNaN
(
pid
))
{
const
cwd
=
fs
.
readlinkSync
(
resources
.
joinPath
(
childUri
,
'
cwd
'
).
fsPath
);
const
rawCmd
=
fs
.
readFileSync
(
resources
.
joinPath
(
childUri
,
'
cmdline
'
).
fsPath
,
'
utf8
'
);
const
nullIndex
=
rawCmd
.
indexOf
(
'
\
0
'
);
const
cmd
=
rawCmd
.
substr
(
0
,
nullIndex
>
0
?
nullIndex
:
rawCmd
.
length
).
trim
();
const
cmd
=
fs
.
readFileSync
(
resources
.
joinPath
(
childUri
,
'
cmdline
'
).
fsPath
,
'
utf8
'
);
processes
.
push
({
pid
,
cwd
,
cmd
});
}
}
catch
(
e
)
{
...
...
src/vs/workbench/services/remote/common/remoteExplorerService.ts
浏览文件 @
71570aa4
...
...
@@ -59,7 +59,6 @@ export function MakeAddress(host: string, port: number): string {
export
class
TunnelModel
extends
Disposable
{
readonly
forwarded
:
Map
<
string
,
Tunnel
>
;
readonly
detected
:
Map
<
string
,
Tunnel
>
;
private
_candidatesEnabled
:
boolean
=
true
;
private
_onForwardPort
:
Emitter
<
Tunnel
>
=
new
Emitter
();
public
onForwardPort
:
Event
<
Tunnel
>
=
this
.
_onForwardPort
.
event
;
private
_onClosePort
:
Emitter
<
{
host
:
string
,
port
:
number
}
>
=
new
Emitter
();
...
...
@@ -70,6 +69,7 @@ export class TunnelModel extends Disposable {
private
_candidateFinder
:
(()
=>
Promise
<
{
host
:
string
,
port
:
number
,
detail
:
string
}[]
>
)
|
undefined
;
private
_onCandidatesChanged
:
Emitter
<
void
>
=
new
Emitter
();
public
onCandidatesChanged
:
Event
<
void
>
=
this
.
_onCandidatesChanged
.
event
;
private
_candidateFilter
:
((
candidates
:
{
host
:
string
,
port
:
number
,
detail
:
string
}[])
=>
Promise
<
{
host
:
string
,
port
:
number
,
detail
:
string
}[]
>
)
|
undefined
;
constructor
(
@
ITunnelService
private
readonly
tunnelService
:
ITunnelService
,
...
...
@@ -187,29 +187,31 @@ export class TunnelModel extends Disposable {
});
}
set
candidateEnabled
(
enabled
:
boolean
)
{
this
.
_candidatesEnabled
=
enabled
;
}
registerCandidateFinder
(
finder
:
()
=>
Promise
<
{
host
:
string
,
port
:
number
,
detail
:
string
}[]
>
):
void
{
this
.
_candidateFinder
=
finder
;
}
setCandidateFilter
(
filter
:
(
candidates
:
{
host
:
string
,
port
:
number
,
detail
:
string
}[])
=>
Promise
<
{
host
:
string
,
port
:
number
,
detail
:
string
}[]
>
):
void
{
this
.
_candidateFilter
=
filter
;
}
get
candidates
():
Promise
<
{
host
:
string
,
port
:
number
,
detail
:
string
}[]
>
{
return
this
.
updateCandidates
().
then
(()
=>
this
.
_candidates
);
}
private
async
updateCandidates
():
Promise
<
void
>
{
if
(
!
this
.
_candidatesEnabled
)
{
this
.
_candidates
=
[];
return
;
}
if
(
this
.
_candidateFinder
)
{
this
.
_candidates
=
(
await
this
.
_candidateFinder
()).
map
(
value
=>
{
let
candidates
=
await
this
.
_candidateFinder
();
if
(
this
.
_candidateFilter
&&
(
candidates
.
length
>
0
))
{
candidates
=
await
this
.
_candidateFilter
(
candidates
);
}
this
.
_candidates
=
candidates
.
map
(
value
=>
{
const
nullIndex
=
value
.
detail
.
indexOf
(
'
\
0
'
);
const
detail
=
value
.
detail
.
substr
(
0
,
nullIndex
>
0
?
nullIndex
:
value
.
detail
.
length
).
trim
();
return
{
host
:
ToLocalHost
(
value
.
host
),
port
:
value
.
port
,
detail
:
value
.
detail
detail
};
});
}
...
...
@@ -233,6 +235,7 @@ export interface IRemoteExplorerService {
close
(
remote
:
{
host
:
string
,
port
:
number
}):
Promise
<
void
>
;
setTunnelInformation
(
tunnelInformation
:
TunnelInformation
|
undefined
):
void
;
registerCandidateFinder
(
finder
:
()
=>
Promise
<
{
host
:
string
,
port
:
number
,
detail
:
string
}[]
>
):
void
;
setCandidateFilter
(
filter
:
(
candidates
:
{
host
:
string
,
port
:
number
,
detail
:
string
}[])
=>
Promise
<
{
host
:
string
,
port
:
number
,
detail
:
string
}[]
>
):
void
;
refresh
():
Promise
<
void
>
;
}
...
...
@@ -285,8 +288,6 @@ class RemoteExplorerService implements IRemoteExplorerService {
if
(
tunnelInformation
&&
tunnelInformation
.
environmentTunnels
)
{
this
.
tunnelModel
.
addEnvironmentTunnels
(
tunnelInformation
.
environmentTunnels
);
}
this
.
tunnelModel
.
candidateEnabled
=
tunnelInformation
?
(
tunnelInformation
.
hideCandidatePorts
!==
true
)
:
true
;
}
setEditable
(
tunnelItem
:
ITunnelItem
|
undefined
,
data
:
IEditableData
|
null
):
void
{
...
...
@@ -309,6 +310,10 @@ class RemoteExplorerService implements IRemoteExplorerService {
this
.
tunnelModel
.
registerCandidateFinder
(
finder
);
}
setCandidateFilter
(
filter
:
(
candidates
:
{
host
:
string
,
port
:
number
,
detail
:
string
}[])
=>
Promise
<
{
host
:
string
,
port
:
number
,
detail
:
string
}[]
>
):
void
{
this
.
tunnelModel
.
setCandidateFilter
(
filter
);
}
refresh
():
Promise
<
void
>
{
return
this
.
tunnelModel
.
refresh
();
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录