Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
8374d6a4
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,发现更多精彩内容 >>
提交
8374d6a4
编写于
11月 19, 2020
作者:
A
Alex Ross
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Detect ports to forward more often
Part of microsoft/vscode-remote-release#4021
上级
71fce013
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
36 addition
and
109 deletion
+36
-109
src/vs/workbench/api/browser/mainThreadTunnelService.ts
src/vs/workbench/api/browser/mainThreadTunnelService.ts
+2
-18
src/vs/workbench/api/common/extHost.protocol.ts
src/vs/workbench/api/common/extHost.protocol.ts
+1
-4
src/vs/workbench/api/common/extHostTunnelService.ts
src/vs/workbench/api/common/extHostTunnelService.ts
+0
-6
src/vs/workbench/api/node/extHostTunnelService.ts
src/vs/workbench/api/node/extHostTunnelService.ts
+14
-14
src/vs/workbench/contrib/remote/browser/tunnelView.ts
src/vs/workbench/contrib/remote/browser/tunnelView.ts
+0
-31
src/vs/workbench/services/remote/common/remoteExplorerService.ts
...workbench/services/remote/common/remoteExplorerService.ts
+19
-36
未找到文件。
src/vs/workbench/api/browser/mainThreadTunnelService.ts
浏览文件 @
8374d6a4
...
...
@@ -47,8 +47,8 @@ export class MainThreadTunnelService extends Disposable implements MainThreadTun
});
}
async
$
registerCandidateFinder
(
):
Promise
<
void
>
{
this
.
remoteExplorerService
.
registerCandidateFinder
(()
=>
this
.
_proxy
.
$findCandidatePorts
()
);
async
$
onFoundNewCandidates
(
candidates
:
{
host
:
string
,
port
:
number
,
detail
:
string
}[]
):
Promise
<
void
>
{
this
.
remoteExplorerService
.
onFoundNewCandidates
(
candidates
);
}
async
$tunnelServiceReady
():
Promise
<
void
>
{
...
...
@@ -78,22 +78,6 @@ export class MainThreadTunnelService extends Disposable implements MainThreadTun
this
.
tunnelService
.
setTunnelProvider
(
tunnelProvider
);
}
async
$setCandidateFilter
():
Promise
<
void
>
{
this
.
_register
(
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
浏览文件 @
8374d6a4
...
...
@@ -949,10 +949,9 @@ export interface MainThreadTunnelServiceShape extends IDisposable {
$openTunnel
(
tunnelOptions
:
TunnelOptions
):
Promise
<
TunnelDto
|
undefined
>
;
$closeTunnel
(
remote
:
{
host
:
string
,
port
:
number
}):
Promise
<
void
>
;
$getTunnels
():
Promise
<
TunnelDescription
[]
>
;
$registerCandidateFinder
():
Promise
<
void
>
;
$setTunnelProvider
():
Promise
<
void
>
;
$setCandidateFilter
():
Promise
<
void
>
;
$tunnelServiceReady
():
Promise
<
void
>
;
$onFoundNewCandidates
(
candidates
:
{
host
:
string
,
port
:
number
,
detail
:
string
}[]):
Promise
<
void
>
;
}
export
interface
MainThreadTimelineShape
extends
IDisposable
{
...
...
@@ -1742,8 +1741,6 @@ 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
},
silent
?:
boolean
):
Promise
<
void
>
;
$onDidTunnelsChange
():
Promise
<
void
>
;
...
...
src/vs/workbench/api/common/extHostTunnelService.ts
浏览文件 @
8374d6a4
...
...
@@ -57,12 +57,6 @@ export class ExtHostTunnelService implements IExtHostTunnelService {
async
getTunnels
():
Promise
<
vscode
.
TunnelDescription
[]
>
{
return
[];
}
async
$findCandidatePorts
():
Promise
<
{
host
:
string
,
port
:
number
;
detail
:
string
;
}[]
>
{
return
[];
}
async
$filterCandidates
(
candidates
:
{
host
:
string
,
port
:
number
,
detail
:
string
}[]):
Promise
<
boolean
[]
>
{
return
candidates
.
map
(()
=>
true
);
}
async
setTunnelExtensionFunctions
(
provider
:
vscode
.
RemoteAuthorityResolver
|
undefined
):
Promise
<
IDisposable
>
{
await
this
.
_proxy
.
$tunnelServiceReady
();
return
{
dispose
:
()
=>
{
}
};
...
...
src/vs/workbench/api/node/extHostTunnelService.ts
浏览文件 @
8374d6a4
...
...
@@ -69,21 +69,25 @@ export class ExtHostTunnelService extends Disposable implements IExtHostTunnelSe
return
this
.
_proxy
.
$getTunnels
();
}
registerCandidateFinder
():
Promise
<
void
>
{
return
this
.
_proxy
.
$registerCandidateFinder
();
}
$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
);
}));
registerCandidateFinder
():
void
{
// Every two seconds, scan to see if the candidate ports have changed;
if
(
isLinux
)
{
let
oldPorts
:
{
host
:
string
,
port
:
number
,
detail
:
string
}[]
|
undefined
=
undefined
;
setInterval
(
async
()
=>
{
const
newPorts
=
await
this
.
findCandidatePorts
();
if
(
!
oldPorts
||
(
JSON
.
stringify
(
oldPorts
)
!==
JSON
.
stringify
(
newPorts
)))
{
oldPorts
=
newPorts
;
this
.
_proxy
.
$onFoundNewCandidates
(
oldPorts
.
filter
(
async
(
candidate
)
=>
await
this
.
_showCandidatePort
(
candidate
.
host
,
candidate
.
port
,
candidate
.
detail
)));
return
;
}
},
2000
);
}
}
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
;
...
...
@@ -133,11 +137,7 @@ export class ExtHostTunnelService extends Disposable implements IExtHostTunnelSe
}
async
$findCandidatePorts
():
Promise
<
{
host
:
string
,
port
:
number
,
detail
:
string
}[]
>
{
if
(
!
isLinux
)
{
return
[];
}
async
findCandidatePorts
():
Promise
<
{
host
:
string
,
port
:
number
,
detail
:
string
}[]
>
{
const
ports
:
{
host
:
string
,
port
:
number
,
detail
:
string
}[]
=
[];
let
tcp
:
string
=
''
;
let
tcp6
:
string
=
''
;
...
...
src/vs/workbench/contrib/remote/browser/tunnelView.ts
浏览文件 @
8374d6a4
...
...
@@ -936,18 +936,6 @@ namespace CopyAddressAction {
}
}
namespace
RefreshTunnelViewAction
{
export
const
ID
=
'
remote.tunnel.refresh
'
;
export
const
LABEL
=
nls
.
localize
(
'
remote.tunnel.refreshView
'
,
"
Refresh
"
);
export
function
handler
():
ICommandHandler
{
return
(
accessor
,
arg
)
=>
{
const
remoteExplorerService
=
accessor
.
get
(
IRemoteExplorerService
);
return
remoteExplorerService
.
refresh
();
};
}
}
namespace
ChangeLocalPortAction
{
export
const
ID
=
'
remote.tunnel.changeLocalPort
'
;
export
const
LABEL
=
nls
.
localize
(
'
remote.tunnel.changeLocalPort
'
,
"
Change Local Port
"
);
...
...
@@ -1022,7 +1010,6 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({
handler
:
CopyAddressAction
.
inlineHandler
()
});
CommandsRegistry
.
registerCommand
(
CopyAddressAction
.
COMMANDPALETTE_ID
,
CopyAddressAction
.
commandPaletteHandler
());
CommandsRegistry
.
registerCommand
(
RefreshTunnelViewAction
.
ID
,
RefreshTunnelViewAction
.
handler
());
CommandsRegistry
.
registerCommand
(
ChangeLocalPortAction
.
ID
,
ChangeLocalPortAction
.
handler
());
MenuRegistry
.
appendMenuItem
(
MenuId
.
CommandPalette
,
({
...
...
@@ -1055,15 +1042,6 @@ MenuRegistry.appendMenuItem(MenuId.TunnelTitle, ({
icon
:
{
id
:
'
codicon/plus
'
}
}
}));
MenuRegistry
.
appendMenuItem
(
MenuId
.
TunnelTitle
,
({
group
:
'
navigation
'
,
order
:
1
,
command
:
{
id
:
RefreshTunnelViewAction
.
ID
,
title
:
RefreshTunnelViewAction
.
LABEL
,
icon
:
{
id
:
'
codicon/refresh
'
}
}
}));
MenuRegistry
.
appendMenuItem
(
MenuId
.
TunnelContext
,
({
group
:
'
0_manage
'
,
order
:
0
,
...
...
@@ -1109,15 +1087,6 @@ MenuRegistry.appendMenuItem(MenuId.TunnelContext, ({
},
when
:
ContextKeyExpr
.
or
(
TunnelTypeContextKey
.
isEqualTo
(
TunnelType
.
Candidate
),
TunnelTypeContextKey
.
isEqualTo
(
TunnelType
.
Add
))
}));
MenuRegistry
.
appendMenuItem
(
MenuId
.
TunnelContext
,
({
group
:
'
0_manage
'
,
order
:
2
,
command
:
{
id
:
RefreshTunnelViewAction
.
ID
,
title
:
RefreshTunnelViewAction
.
LABEL
,
},
when
:
TunnelTypeContextKey
.
isEqualTo
(
TunnelType
.
Candidate
)
}));
MenuRegistry
.
appendMenuItem
(
MenuId
.
TunnelContext
,
({
group
:
'
1_manage
'
,
order
:
1
,
...
...
src/vs/workbench/services/remote/common/remoteExplorerService.ts
浏览文件 @
8374d6a4
...
...
@@ -90,7 +90,6 @@ export class TunnelModel extends Disposable {
private
_onPortName
:
Emitter
<
{
host
:
string
,
port
:
number
}
>
=
new
Emitter
();
public
onPortName
:
Event
<
{
host
:
string
,
port
:
number
}
>
=
this
.
_onPortName
.
event
;
private
_candidates
:
{
host
:
string
,
port
:
number
,
detail
:
string
}[]
=
[];
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
;
...
...
@@ -217,40 +216,29 @@ export class TunnelModel extends Disposable {
this
.
_onForwardPort
.
fire
();
}
registerCandidateFinder
(
finder
:
()
=>
Promise
<
{
host
:
string
,
port
:
number
,
detail
:
string
}[]
>
):
void
{
this
.
_candidateFinder
=
finder
;
this
.
_onCandidatesChanged
.
fire
();
}
setCandidateFilter
(
filter
:
((
candidates
:
{
host
:
string
,
port
:
number
,
detail
:
string
}[])
=>
Promise
<
{
host
:
string
,
port
:
number
,
detail
:
string
}[]
>
)
|
undefined
):
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
.
_candidateFinder
)
{
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
:
value
.
host
,
port
:
value
.
port
,
detail
};
});
async
setCandidates
(
candidates
:
{
host
:
string
,
port
:
number
,
detail
:
string
}[])
{
let
processedCandidates
=
candidates
;
if
(
this
.
_candidateFilter
)
{
processedCandidates
=
await
this
.
_candidateFilter
(
candidates
);
}
this
.
_candidates
=
processedCandidates
.
map
(
value
=>
{
const
nullIndex
=
value
.
detail
.
indexOf
(
'
\
0
'
);
const
detail
=
value
.
detail
.
substr
(
0
,
nullIndex
>
0
?
nullIndex
:
value
.
detail
.
length
).
trim
();
return
{
host
:
value
.
host
,
port
:
value
.
port
,
detail
};
});
this
.
_onCandidatesChanged
.
fire
();
}
async
refresh
():
Promise
<
void
>
{
await
this
.
updateCandidates
();
this
.
_onCandidatesChanged
.
fire
();
get
candidates
():
{
host
:
string
,
port
:
number
,
detail
:
string
}[]
{
return
this
.
_candidates
;
}
}
...
...
@@ -265,9 +253,8 @@ export interface IRemoteExplorerService {
forward
(
remote
:
{
host
:
string
,
port
:
number
},
localPort
?:
number
,
name
?:
string
):
Promise
<
RemoteTunnel
|
void
>
;
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
}[]
>
)
|
undefined
):
IDisposable
;
refresh
():
Promise
<
void
>
;
onFoundNewCandidates
(
candidates
:
{
host
:
string
,
port
:
number
,
detail
:
string
}[]):
void
;
restore
():
Promise
<
void
>
;
}
...
...
@@ -340,10 +327,6 @@ class RemoteExplorerService implements IRemoteExplorerService {
this
.
_editable
.
data
:
undefined
;
}
registerCandidateFinder
(
finder
:
()
=>
Promise
<
{
host
:
string
,
port
:
number
,
detail
:
string
}[]
>
):
void
{
this
.
tunnelModel
.
registerCandidateFinder
(
finder
);
}
setCandidateFilter
(
filter
:
(
candidates
:
{
host
:
string
,
port
:
number
,
detail
:
string
}[])
=>
Promise
<
{
host
:
string
,
port
:
number
,
detail
:
string
}[]
>
):
IDisposable
{
if
(
!
filter
)
{
return
{
...
...
@@ -358,8 +341,8 @@ class RemoteExplorerService implements IRemoteExplorerService {
};
}
refresh
():
Promise
<
void
>
{
return
this
.
tunnelModel
.
refresh
(
);
onFoundNewCandidates
(
candidates
:
{
host
:
string
,
port
:
number
,
detail
:
string
}[]):
void
{
this
.
tunnelModel
.
setCandidates
(
candidates
);
}
restore
():
Promise
<
void
>
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录