Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
c4b7d109
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,发现更多精彩内容 >>
提交
c4b7d109
编写于
11月 24, 2020
作者:
A
Alex Ross
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Use property bag for tunnel creation elevation
Fixes #110795
上级
197f1341
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
36 addition
and
15 deletion
+36
-15
src/vs/platform/remote/common/tunnel.ts
src/vs/platform/remote/common/tunnel.ts
+13
-2
src/vs/platform/remote/node/tunnelService.ts
src/vs/platform/remote/node/tunnelService.ts
+4
-1
src/vs/vscode.proposed.d.ts
src/vs/vscode.proposed.d.ts
+8
-1
src/vs/workbench/api/browser/mainThreadTunnelService.ts
src/vs/workbench/api/browser/mainThreadTunnelService.ts
+3
-3
src/vs/workbench/api/common/extHost.protocol.ts
src/vs/workbench/api/common/extHost.protocol.ts
+2
-2
src/vs/workbench/api/common/extHostTunnelService.ts
src/vs/workbench/api/common/extHostTunnelService.ts
+2
-2
src/vs/workbench/api/node/extHostTunnelService.ts
src/vs/workbench/api/node/extHostTunnelService.ts
+4
-4
未找到文件。
src/vs/platform/remote/common/tunnel.ts
浏览文件 @
c4b7d109
...
...
@@ -26,8 +26,12 @@ export interface TunnelOptions {
label
?:
string
;
}
export
interface
TunnelCreationInformation
{
elevationRequired
?:
boolean
;
}
export
interface
ITunnelProvider
{
forwardPort
(
tunnelOptions
:
TunnelOptions
):
Promise
<
RemoteTunnel
>
|
undefined
;
forwardPort
(
tunnelOptions
:
TunnelOptions
,
tunnelCreationInformation
:
TunnelCreationInformation
):
Promise
<
RemoteTunnel
>
|
undefined
;
}
export
interface
ITunnelService
{
...
...
@@ -198,6 +202,10 @@ export abstract class AbstractTunnelService implements ITunnelService {
}
protected
abstract
retainOrCreateTunnel
(
addressProvider
:
IAddressProvider
,
remoteHost
:
string
,
remotePort
:
number
,
localPort
?:
number
):
Promise
<
RemoteTunnel
>
|
undefined
;
protected
isPortPrivileged
(
port
:
number
):
boolean
{
return
port
<
1024
;
}
}
export
class
TunnelService
extends
AbstractTunnelService
{
...
...
@@ -209,7 +217,10 @@ export class TunnelService extends AbstractTunnelService {
}
if
(
this
.
_tunnelProvider
)
{
const
tunnel
=
this
.
_tunnelProvider
.
forwardPort
({
remoteAddress
:
{
host
:
remoteHost
,
port
:
remotePort
}
});
const
preferredLocalPort
=
localPort
===
undefined
?
remotePort
:
localPort
;
const
tunnelOptions
=
{
remoteAddress
:
{
host
:
remoteHost
,
port
:
remotePort
},
localAddressPort
:
localPort
};
const
creationInfo
=
{
elevationRequired
:
this
.
isPortPrivileged
(
preferredLocalPort
)
};
const
tunnel
=
this
.
_tunnelProvider
.
forwardPort
(
tunnelOptions
,
creationInfo
);
if
(
tunnel
)
{
this
.
addTunnelToMap
(
remoteHost
,
remotePort
,
tunnel
);
}
...
...
src/vs/platform/remote/node/tunnelService.ts
浏览文件 @
c4b7d109
...
...
@@ -146,7 +146,10 @@ export class TunnelService extends AbstractTunnelService {
}
if
(
this
.
_tunnelProvider
)
{
const
tunnel
=
this
.
_tunnelProvider
.
forwardPort
({
remoteAddress
:
{
host
:
remoteHost
,
port
:
remotePort
},
localAddressPort
:
localPort
});
const
preferredLocalPort
=
localPort
===
undefined
?
remotePort
:
localPort
;
const
creationInfo
=
{
elevationRequired
:
this
.
isPortPrivileged
(
preferredLocalPort
)
};
const
tunnelOptions
=
{
remoteAddress
:
{
host
:
remoteHost
,
port
:
remotePort
},
localAddressPort
:
localPort
};
const
tunnel
=
this
.
_tunnelProvider
.
forwardPort
(
tunnelOptions
,
creationInfo
);
if
(
tunnel
)
{
this
.
addTunnelToMap
(
remoteHost
,
remotePort
,
tunnel
);
}
...
...
src/vs/vscode.proposed.d.ts
浏览文件 @
c4b7d109
...
...
@@ -223,6 +223,13 @@ declare module 'vscode' {
}
export
interface
TunnelCreationInformation
{
/**
* True when the local operating system will require elevation to use the requested local port.
*/
elevationRequired
?:
boolean
;
}
export
type
ResolverResult
=
ResolvedAuthority
&
ResolvedOptions
&
TunnelInformation
;
export
class
RemoteAuthorityResolverError
extends
Error
{
...
...
@@ -239,7 +246,7 @@ declare module 'vscode' {
* When not implemented, the core will use its default forwarding logic.
* When implemented, the core will use this to forward ports.
*/
tunnelFactory
?:
(
tunnelOptions
:
TunnelOptions
,
elevate
?:
boolea
n
)
=>
Thenable
<
Tunnel
>
|
undefined
;
tunnelFactory
?:
(
tunnelOptions
:
TunnelOptions
,
tunnelCreationInformation
:
TunnelCreationInformatio
n
)
=>
Thenable
<
Tunnel
>
|
undefined
;
/**
* Provides filtering for candidate ports.
...
...
src/vs/workbench/api/browser/mainThreadTunnelService.ts
浏览文件 @
c4b7d109
...
...
@@ -7,7 +7,7 @@ import { MainThreadTunnelServiceShape, IExtHostContext, MainContext, ExtHostCont
import
{
TunnelDto
}
from
'
vs/workbench/api/common/extHostTunnelService
'
;
import
{
extHostNamedCustomer
}
from
'
vs/workbench/api/common/extHostCustomers
'
;
import
{
IRemoteExplorerService
,
makeAddress
}
from
'
vs/workbench/services/remote/common/remoteExplorerService
'
;
import
{
ITunnelProvider
,
ITunnelService
,
TunnelOptions
}
from
'
vs/platform/remote/common/tunnel
'
;
import
{
ITunnelProvider
,
ITunnelService
,
Tunnel
CreationInformation
,
Tunnel
Options
}
from
'
vs/platform/remote/common/tunnel
'
;
import
{
Disposable
}
from
'
vs/base/common/lifecycle
'
;
import
type
{
TunnelDescription
}
from
'
vs/platform/remote/common/remoteAuthorityResolver
'
;
...
...
@@ -57,8 +57,8 @@ export class MainThreadTunnelService extends Disposable implements MainThreadTun
async
$setTunnelProvider
():
Promise
<
void
>
{
const
tunnelProvider
:
ITunnelProvider
=
{
forwardPort
:
(
tunnelOptions
:
TunnelOptions
)
=>
{
const
forward
=
this
.
_proxy
.
$forwardPort
(
tunnelOptions
);
forwardPort
:
(
tunnelOptions
:
TunnelOptions
,
tunnelCreationInformation
:
TunnelCreationInformation
)
=>
{
const
forward
=
this
.
_proxy
.
$forwardPort
(
tunnelOptions
,
tunnelCreationInformation
);
if
(
forward
)
{
return
forward
.
then
(
tunnel
=>
{
return
{
...
...
src/vs/workbench/api/common/extHost.protocol.ts
浏览文件 @
c4b7d109
...
...
@@ -47,7 +47,7 @@ import * as search from 'vs/workbench/services/search/common/search';
import
{
EditorGroupColumn
,
SaveReason
}
from
'
vs/workbench/common/editor
'
;
import
{
ExtensionActivationReason
}
from
'
vs/workbench/api/common/extHostExtensionActivator
'
;
import
{
TunnelDto
}
from
'
vs/workbench/api/common/extHostTunnelService
'
;
import
{
TunnelOptions
}
from
'
vs/platform/remote/common/tunnel
'
;
import
{
Tunnel
CreationInformation
,
Tunnel
Options
}
from
'
vs/platform/remote/common/tunnel
'
;
import
{
Timeline
,
TimelineChangeEvent
,
TimelineOptions
,
TimelineProviderDescriptor
,
InternalTimelineOptions
}
from
'
vs/workbench/contrib/timeline/common/timeline
'
;
import
{
revive
}
from
'
vs/base/common/marshalling
'
;
import
{
IProcessedOutput
,
INotebookDisplayOrder
,
NotebookCellMetadata
,
NotebookDocumentMetadata
,
ICellEditOperation
,
NotebookCellsChangedEventDto
,
NotebookDataDto
,
IMainCellDto
,
INotebookDocumentFilter
,
INotebookKernelInfoDto2
,
TransientMetadata
,
INotebookCellStatusBarEntry
,
ICellRange
,
INotebookDecorationRenderOptions
,
INotebookExclusiveDocumentFilter
}
from
'
vs/workbench/contrib/notebook/common/notebookCommon
'
;
...
...
@@ -1742,7 +1742,7 @@ export interface MainThreadThemingShape extends IDisposable {
}
export
interface
ExtHostTunnelServiceShape
{
$forwardPort
(
tunnelOptions
:
TunnelOptions
):
Promise
<
TunnelDto
>
|
undefined
;
$forwardPort
(
tunnelOptions
:
TunnelOptions
,
tunnelCreationInformation
:
TunnelCreationInformation
):
Promise
<
TunnelDto
>
|
undefined
;
$closeTunnel
(
remote
:
{
host
:
string
,
port
:
number
},
silent
?:
boolean
):
Promise
<
void
>
;
$onDidTunnelsChange
():
Promise
<
void
>
;
}
...
...
src/vs/workbench/api/common/extHostTunnelService.ts
浏览文件 @
c4b7d109
...
...
@@ -6,7 +6,7 @@
import
{
ExtHostTunnelServiceShape
,
MainContext
,
MainThreadTunnelServiceShape
}
from
'
vs/workbench/api/common/extHost.protocol
'
;
import
{
createDecorator
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
*
as
vscode
from
'
vscode
'
;
import
{
RemoteTunnel
,
TunnelOptions
}
from
'
vs/platform/remote/common/tunnel
'
;
import
{
RemoteTunnel
,
Tunnel
CreationInformation
,
Tunnel
Options
}
from
'
vs/platform/remote/common/tunnel
'
;
import
{
IDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
Emitter
}
from
'
vs/base/common/event
'
;
import
{
IExtHostRpcService
}
from
'
vs/workbench/api/common/extHostRpcService
'
;
...
...
@@ -61,7 +61,7 @@ export class ExtHostTunnelService implements IExtHostTunnelService {
await
this
.
_proxy
.
$tunnelServiceReady
();
return
{
dispose
:
()
=>
{
}
};
}
$forwardPort
(
tunnelOptions
:
TunnelOptions
):
Promise
<
TunnelDto
>
|
undefined
{
return
undefined
;
}
$forwardPort
(
tunnelOptions
:
TunnelOptions
,
tunnelCreationInformation
:
TunnelCreationInformation
):
Promise
<
TunnelDto
>
|
undefined
{
return
undefined
;
}
async
$closeTunnel
(
remote
:
{
host
:
string
,
port
:
number
}):
Promise
<
void
>
{
}
async
$onDidTunnelsChange
():
Promise
<
void
>
{
}
}
src/vs/workbench/api/node/extHostTunnelService.ts
浏览文件 @
c4b7d109
...
...
@@ -16,7 +16,7 @@ import { isLinux } from 'vs/base/common/platform';
import
{
IExtHostTunnelService
,
TunnelDto
}
from
'
vs/workbench/api/common/extHostTunnelService
'
;
import
{
asPromise
}
from
'
vs/base/common/async
'
;
import
{
Event
,
Emitter
}
from
'
vs/base/common/event
'
;
import
{
TunnelOptions
}
from
'
vs/platform/remote/common/tunnel
'
;
import
{
TunnelOptions
,
TunnelCreationInformation
}
from
'
vs/platform/remote/common/tunnel
'
;
class
ExtensionTunnel
implements
vscode
.
Tunnel
{
private
_onDispose
:
Emitter
<
void
>
=
new
Emitter
();
...
...
@@ -36,7 +36,7 @@ class ExtensionTunnel implements vscode.Tunnel {
export
class
ExtHostTunnelService
extends
Disposable
implements
IExtHostTunnelService
{
readonly
_serviceBrand
:
undefined
;
private
readonly
_proxy
:
MainThreadTunnelServiceShape
;
private
_forwardPortProvider
:
((
tunnelOptions
:
TunnelOptions
)
=>
Thenable
<
vscode
.
Tunnel
>
|
undefined
)
|
undefined
;
private
_forwardPortProvider
:
((
tunnelOptions
:
TunnelOptions
,
tunnelCreationInformation
:
TunnelCreationInformation
)
=>
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
,
{
tunnel
:
vscode
.
Tunnel
,
disposeListener
:
IDisposable
}
>>
=
new
Map
();
private
_onDidChangeTunnels
:
Emitter
<
void
>
=
new
Emitter
<
void
>
();
...
...
@@ -119,9 +119,9 @@ export class ExtHostTunnelService extends Disposable implements IExtHostTunnelSe
this
.
_onDidChangeTunnels
.
fire
();
}
$forwardPort
(
tunnelOptions
:
TunnelOptions
):
Promise
<
TunnelDto
>
|
undefined
{
$forwardPort
(
tunnelOptions
:
TunnelOptions
,
tunnelCreationInformation
:
TunnelCreationInformation
):
Promise
<
TunnelDto
>
|
undefined
{
if
(
this
.
_forwardPortProvider
)
{
const
providedPort
=
this
.
_forwardPortProvider
!
(
tunnelOptions
);
const
providedPort
=
this
.
_forwardPortProvider
(
tunnelOptions
,
tunnelCreationInformation
);
if
(
providedPort
!==
undefined
)
{
return
asPromise
(()
=>
providedPort
).
then
(
tunnel
=>
{
if
(
!
this
.
_extensionTunnels
.
has
(
tunnelOptions
.
remoteAddress
.
host
))
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录