Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
216c8476
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 搜索 >>
提交
216c8476
编写于
8月 11, 2020
作者:
A
Alex Ross
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Watch terminal for ports to forward when remote
Fixes microsoft/vscode-remote-release#3235
上级
69186de4
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
83 addition
and
4 deletion
+83
-4
src/vs/platform/remote/common/tunnel.ts
src/vs/platform/remote/common/tunnel.ts
+0
-2
src/vs/workbench/contrib/remote/browser/remote.ts
src/vs/workbench/contrib/remote/browser/remote.ts
+3
-1
src/vs/workbench/contrib/remote/browser/tunnelView.ts
src/vs/workbench/contrib/remote/browser/tunnelView.ts
+9
-1
src/vs/workbench/contrib/remote/browser/urlFinder.ts
src/vs/workbench/contrib/remote/browser/urlFinder.ts
+71
-0
未找到文件。
src/vs/platform/remote/common/tunnel.ts
浏览文件 @
216c8476
...
...
@@ -56,8 +56,6 @@ export function extractLocalHostUriMetaDataForPortMapping(uri: URI): { address:
};
}
export
abstract
class
AbstractTunnelService
implements
ITunnelService
{
declare
readonly
_serviceBrand
:
undefined
;
...
...
src/vs/workbench/contrib/remote/browser/remote.ts
浏览文件 @
216c8476
...
...
@@ -56,6 +56,7 @@ import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
import
{
RemoteWindowActiveIndicator
}
from
'
vs/workbench/contrib/remote/browser/remoteIndicator
'
;
import
{
inQuickPickContextKeyValue
}
from
'
vs/workbench/browser/quickaccess
'
;
import
{
Codicon
,
registerIcon
}
from
'
vs/base/common/codicons
'
;
import
{
ITerminalService
}
from
'
vs/workbench/contrib/terminal/browser/terminal
'
;
export
interface
HelpInformation
{
extensionDescription
:
IExtensionDescription
;
...
...
@@ -481,6 +482,7 @@ export class RemoteViewPaneContainer extends FilterViewPaneContainer implements
@
IWorkbenchEnvironmentService
private
readonly
environmentService
:
IWorkbenchEnvironmentService
,
@
IContextKeyService
private
readonly
contextKeyService
:
IContextKeyService
,
@
IViewDescriptorService
viewDescriptorService
:
IViewDescriptorService
,
@
ITerminalService
private
readonly
terminalService
:
ITerminalService
)
{
super
(
VIEWLET_ID
,
remoteExplorerService
.
onDidChangeTargetType
,
configurationService
,
layoutService
,
telemetryService
,
storageService
,
instantiationService
,
themeService
,
contextMenuService
,
extensionService
,
contextService
,
viewDescriptorService
);
this
.
addConstantViewDescriptors
([
this
.
helpPanelDescriptor
]);
...
...
@@ -555,7 +557,7 @@ export class RemoteViewPaneContainer extends FilterViewPaneContainer implements
// This context key is set to false in the constructor, but is expected to be changed by resolver extensions to enable the forwarded ports view.
const
viewEnabled
:
boolean
=
!!
forwardedPortsViewEnabled
.
getValue
(
this
.
contextKeyService
);
if
(
this
.
environmentService
.
configuration
.
remoteAuthority
&&
!
this
.
tunnelPanelDescriptor
&&
viewEnabled
)
{
this
.
tunnelPanelDescriptor
=
new
TunnelPanelDescriptor
(
new
TunnelViewModel
(
this
.
remoteExplorerService
),
this
.
environmentService
);
this
.
tunnelPanelDescriptor
=
new
TunnelPanelDescriptor
(
new
TunnelViewModel
(
this
.
remoteExplorerService
,
this
.
terminalService
),
this
.
environmentService
);
const
viewsRegistry
=
Registry
.
as
<
IViewsRegistry
>
(
Extensions
.
ViewsRegistry
);
viewsRegistry
.
registerViews
([
this
.
tunnelPanelDescriptor
!
],
this
.
viewContainer
);
}
...
...
src/vs/workbench/contrib/remote/browser/tunnelView.ts
浏览文件 @
216c8476
...
...
@@ -42,6 +42,8 @@ import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
import
{
KeybindingsRegistry
,
KeybindingWeight
}
from
'
vs/platform/keybinding/common/keybindingsRegistry
'
;
import
{
ITelemetryService
}
from
'
vs/platform/telemetry/common/telemetry
'
;
import
{
ActionViewItem
}
from
'
vs/base/browser/ui/actionbar/actionViewItems
'
;
import
{
ITerminalService
}
from
'
vs/workbench/contrib/terminal/browser/terminal
'
;
import
{
UrlFinder
}
from
'
vs/workbench/contrib/remote/browser/urlFinder
'
;
export
const
forwardedPortsViewEnabled
=
new
RawContextKey
<
boolean
>
(
'
forwardedPortsViewEnabled
'
,
false
);
...
...
@@ -72,7 +74,8 @@ export class TunnelViewModel extends Disposable implements ITunnelViewModel {
private
_candidates
:
Map
<
string
,
{
host
:
string
,
port
:
number
,
detail
:
string
}
>
=
new
Map
();
constructor
(
@
IRemoteExplorerService
private
readonly
remoteExplorerService
:
IRemoteExplorerService
)
{
@
IRemoteExplorerService
private
readonly
remoteExplorerService
:
IRemoteExplorerService
,
@
ITerminalService
readonly
terminalService
:
ITerminalService
)
{
super
();
this
.
model
=
remoteExplorerService
.
tunnelModel
;
this
.
_register
(
this
.
model
.
onForwardPort
(()
=>
this
.
_onForwardedPortsChanged
.
fire
()));
...
...
@@ -86,6 +89,11 @@ export class TunnelViewModel extends Disposable implements ITunnelViewModel {
remotePort
:
0
,
description
:
''
};
const
urlFinder
=
this
.
_register
(
new
UrlFinder
(
terminalService
));
this
.
_register
(
urlFinder
.
onDidMatchLocalUrl
(
localUrl
=>
{
this
.
model
.
forward
(
localUrl
);
}));
}
async
groups
():
Promise
<
ITunnelGroup
[]
>
{
...
...
src/vs/workbench/contrib/remote/browser/urlFinder.ts
0 → 100644
浏览文件 @
216c8476
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import
{
ITerminalInstance
,
ITerminalService
}
from
'
vs/workbench/contrib/terminal/browser/terminal
'
;
import
{
Emitter
}
from
'
vs/base/common/event
'
;
import
{
Disposable
,
IDisposable
}
from
'
vs/base/common/lifecycle
'
;
export
class
UrlFinder
extends
Disposable
{
private
static
readonly
terminalCodesRegex
=
/
(?:\u
001B|
\u
009B
)[\[\]
()#;?
]
*
(?:(?:(?:[
a-zA-Z0-9
]
*
(?:
;
[
a-zA-Z0-9
]
*
)
*
)?\u
0007
)
|
(?:(?:\d{1,4}(?:
;
\d{0,4})
*
)?[
0-9A-PR-TZcf-ntqry=><~
]))
/g
;
/**
* Local server url pattern matching following urls:
* http://localhost:3000/ - commonly used across multiple frameworks
* https://127.0.0.1:5001/ - ASP.NET
* http://:8080 - Beego Golang
* http://0.0.0.0:4000 - Elixir Phoenix
*/
private
static
readonly
localUrlRegex
=
/
\b\w{2,20}
:
\/\/(?:
localhost|127
\.
0
\.
0
\.
1|0
\.
0
\.
0
\.
0|:
\d{2,5})[\w\-\.\~
:
\/\?\#
[
\]\@
!
\$
&
\(\)\*\+\,\;\=]
*/gim
;
private
_onDidMatchLocalUrl
:
Emitter
<
{
host
:
string
,
port
:
number
}
>
=
new
Emitter
();
public
readonly
onDidMatchLocalUrl
=
this
.
_onDidMatchLocalUrl
.
event
;
private
listeners
:
Map
<
ITerminalInstance
,
IDisposable
>
=
new
Map
();
constructor
(
terminalService
:
ITerminalService
)
{
super
();
terminalService
.
terminalInstances
.
forEach
(
instance
=>
{
this
.
listeners
.
set
(
instance
,
instance
.
onData
(
data
=>
{
this
.
processData
(
data
);
}));
});
this
.
_register
(
terminalService
.
onInstanceCreated
(
instance
=>
{
this
.
listeners
.
set
(
instance
,
instance
.
onData
(
data
=>
{
this
.
processData
(
data
);
}));
}));
this
.
_register
(
terminalService
.
onInstanceDisposed
(
instance
=>
{
this
.
listeners
.
delete
(
instance
);
}));
}
dispose
()
{
super
.
dispose
();
const
listeners
=
this
.
listeners
.
values
();
for
(
const
listener
of
listeners
)
{
listener
.
dispose
();
}
}
private
processData
(
data
:
string
)
{
// strip ANSI terminal codes
data
=
data
.
replace
(
UrlFinder
.
terminalCodesRegex
,
''
);
const
urlMatches
=
data
.
match
(
UrlFinder
.
localUrlRegex
)
||
[];
urlMatches
.
forEach
((
match
)
=>
{
// check if valid url
const
serverUrl
=
new
URL
(
match
);
if
(
serverUrl
)
{
// check if the port is a valid integer value
const
port
=
parseFloat
(
serverUrl
.
port
!
);
if
(
!
isNaN
(
port
)
&&
Number
.
isInteger
(
port
)
&&
port
>
0
&&
port
<=
65535
)
{
// normalize the host name
let
host
=
serverUrl
.
hostname
;
if
(
host
!==
'
0.0.0.0
'
)
{
host
=
'
localhost
'
;
}
this
.
_onDidMatchLocalUrl
.
fire
({
port
,
host
});
}
}
});
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录