Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
381b99f6
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 搜索 >>
未验证
提交
381b99f6
编写于
1月 15, 2021
作者:
A
Alex Ross
提交者:
GitHub
1月 15, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Also run the output based auto port forwarding (#114424)
Fixes microsoft/vscode-internalbacklog#1736
上级
f7e7a954
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
23 addition
and
10 deletion
+23
-10
src/vs/platform/remote/common/tunnel.ts
src/vs/platform/remote/common/tunnel.ts
+7
-3
src/vs/workbench/contrib/remote/browser/remoteExplorer.ts
src/vs/workbench/contrib/remote/browser/remoteExplorer.ts
+13
-6
src/vs/workbench/contrib/remote/browser/urlFinder.ts
src/vs/workbench/contrib/remote/browser/urlFinder.ts
+3
-1
未找到文件。
src/vs/platform/remote/common/tunnel.ts
浏览文件 @
381b99f6
...
...
@@ -5,7 +5,7 @@
import
{
Emitter
,
Event
}
from
'
vs/base/common/event
'
;
import
{
IDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
isWindows
}
from
'
vs/base/common/platform
'
;
import
{
isWindows
,
OperatingSystem
}
from
'
vs/base/common/platform
'
;
import
{
URI
}
from
'
vs/base/common/uri
'
;
import
{
createDecorator
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
ILogService
}
from
'
vs/platform/log/common/log
'
;
...
...
@@ -85,8 +85,12 @@ function getOtherLocalhost(host: string): string | undefined {
return
(
host
===
'
localhost
'
)
?
'
127.0.0.1
'
:
((
host
===
'
127.0.0.1
'
)
?
'
localhost
'
:
undefined
);
}
export
function
isPortPrivileged
(
port
:
number
):
boolean
{
return
!
isWindows
&&
(
port
<
1024
);
export
function
isPortPrivileged
(
port
:
number
,
os
?:
OperatingSystem
):
boolean
{
if
(
os
)
{
return
os
!==
OperatingSystem
.
Windows
&&
(
port
<
1024
);
}
else
{
return
!
isWindows
&&
(
port
<
1024
);
}
}
export
abstract
class
AbstractTunnelService
implements
ITunnelService
{
...
...
src/vs/workbench/contrib/remote/browser/remoteExplorer.ts
浏览文件 @
381b99f6
...
...
@@ -212,10 +212,12 @@ export class AutomaticPortForwarding extends Disposable implements IWorkbenchCon
remoteAgentService
.
getEnvironment
().
then
(
environment
=>
{
if
(
environment
?.
os
===
OperatingSystem
.
Windows
)
{
this
.
_register
(
new
Windows
AutomaticPortForwarding
(
terminalService
,
notificationService
,
openerService
,
remoteExplorerService
,
configurationService
,
debugService
,
tunnelService
));
this
.
_register
(
new
Output
AutomaticPortForwarding
(
terminalService
,
notificationService
,
openerService
,
remoteExplorerService
,
configurationService
,
debugService
,
tunnelService
,
remoteAgentService
,
false
));
}
else
if
(
environment
?.
os
===
OperatingSystem
.
Linux
)
{
this
.
_register
(
new
LinuxAutomaticPortForwarding
(
configurationService
,
remoteExplorerService
,
notificationService
,
openerService
,
tunnelService
));
this
.
_register
(
new
ProcAutomaticPortForwarding
(
configurationService
,
remoteExplorerService
,
notificationService
,
openerService
,
tunnelService
));
this
.
_register
(
new
OutputAutomaticPortForwarding
(
terminalService
,
notificationService
,
openerService
,
remoteExplorerService
,
configurationService
,
debugService
,
tunnelService
,
remoteAgentService
,
true
));
}
});
}
...
...
@@ -355,7 +357,7 @@ class OnAutoForwardedAction extends Disposable {
}
}
class
Windows
AutomaticPortForwarding
extends
Disposable
{
class
Output
AutomaticPortForwarding
extends
Disposable
{
private
portsFeatures
?:
IDisposable
;
private
urlFinder
?:
UrlFinder
;
private
notifier
:
OnAutoForwardedAction
;
...
...
@@ -368,7 +370,9 @@ class WindowsAutomaticPortForwarding extends Disposable {
private
readonly
remoteExplorerService
:
IRemoteExplorerService
,
private
readonly
configurationService
:
IConfigurationService
,
private
readonly
debugService
:
IDebugService
,
readonly
tunnelService
:
ITunnelService
readonly
tunnelService
:
ITunnelService
,
private
readonly
remoteAgentService
:
IRemoteAgentService
,
readonly
privilegedOnly
:
boolean
)
{
super
();
this
.
portsAttributes
=
new
PortsAttributes
(
configurationService
);
...
...
@@ -408,6 +412,9 @@ class WindowsAutomaticPortForwarding extends Disposable {
if
(
this
.
portsAttributes
.
getAttributes
(
localUrl
.
port
)?.
onAutoForward
===
OnPortForward
.
Ignore
)
{
return
;
}
if
(
this
.
privilegedOnly
&&
!
isPortPrivileged
(
localUrl
.
port
,
(
await
this
.
remoteAgentService
.
getEnvironment
())?.
os
))
{
return
;
}
const
forwarded
=
await
this
.
remoteExplorerService
.
forward
(
localUrl
);
if
(
forwarded
)
{
this
.
notifier
.
doAction
([
forwarded
]);
...
...
@@ -423,7 +430,7 @@ class WindowsAutomaticPortForwarding extends Disposable {
}
}
class
Linux
AutomaticPortForwarding
extends
Disposable
{
class
Proc
AutomaticPortForwarding
extends
Disposable
{
private
candidateListener
:
IDisposable
|
undefined
;
private
autoForwarded
:
Set
<
string
>
=
new
Set
();
private
notifier
:
OnAutoForwardedAction
;
...
...
src/vs/workbench/contrib/remote/browser/urlFinder.ts
浏览文件 @
381b99f6
...
...
@@ -18,6 +18,7 @@ export class UrlFinder extends Disposable {
* 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
static
readonly
extractPortRegex
=
/
(
localhost|127
\.
0
\.
0
\.
1|0
\.
0
\.
0
\.
0
)
:
(\d{1,5})
/
;
/**
* https://github.com/microsoft/vscode-remote-release/issues/3949
*/
...
...
@@ -106,7 +107,8 @@ export class UrlFinder extends Disposable {
const
serverUrl
=
new
URL
(
match
);
if
(
serverUrl
)
{
// check if the port is a valid integer value
const
port
=
parseFloat
(
serverUrl
.
port
!
);
const
portMatch
=
match
.
match
(
UrlFinder
.
extractPortRegex
);
const
port
=
parseFloat
(
serverUrl
.
port
?
serverUrl
.
port
:
(
portMatch
?
portMatch
[
2
]
:
'
NaN
'
));
if
(
!
isNaN
(
port
)
&&
Number
.
isInteger
(
port
)
&&
port
>
0
&&
port
<=
65535
)
{
// normalize the host name
let
host
=
serverUrl
.
hostname
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录