Skip to content

Commit

Permalink
Add protocol to portsAttributes
Browse files Browse the repository at this point in the history
Part of #123750
  • Loading branch information
alexr00 committed May 18, 2021
1 parent 45aafeb commit e4159c8
Show file tree
Hide file tree
Showing 6 changed files with 194 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,14 @@
"type": "boolean",
"markdownDescription": "When true, a modal dialog will show if the chosen local port isn't used for forwarding.",
"default": false
},
"protocol": {
"type": "string",
"enum": [
"http",
"https"
],
"description": "The protocol to use when forwarding this port."
}
},
"default": {
Expand All @@ -85,7 +93,13 @@
"properties": {
"onAutoForward": {
"type": "string",
"enum": ["notify", "openBrowser", "openPreview", "silent", "ignore"],
"enum": [
"notify",
"openBrowser",
"openPreview",
"silent",
"ignore"
],
"enumDescriptions": [
"Shows a notification when a port is automatically forwarded.",
"Opens the browser when the port is automatically forwarded. Depending on your settings, this could open an embedded browser.",
Expand All @@ -110,9 +124,23 @@
"type": "boolean",
"markdownDescription": "When true, a modal dialog will show if the chosen local port isn't used for forwarding.",
"default": false
},
"protocol": {
"type": "string",
"enum": [
"http",
"https"
],
"description": "The protocol to use when forwarding this port."
}
},
"defaultSnippets": [{ "body": { "onAutoForward": "ignore" } }],
"defaultSnippets": [
{
"body": {
"onAutoForward": "ignore"
}
}
],
"markdownDescription": "Set default properties that are applied to all ports that don't get properties from the setting `remote.portsAttributes`. For example:\n\n```\n{\n \"onAutoForward\": \"ignore\"\n}\n```",
"additionalProperties": false
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,14 @@
"type": "boolean",
"markdownDescription": "When true, a modal dialog will show if the chosen local port isn't used for forwarding.",
"default": false
},
"protocol": {
"type": "string",
"enum": [
"http",
"https"
],
"description": "The protocol to use when forwarding this port."
}
},
"default": {
Expand Down Expand Up @@ -225,6 +233,14 @@
"type": "boolean",
"markdownDescription": "When true, a modal dialog will show if the chosen local port isn't used for forwarding.",
"default": false
},
"protocol": {
"type": "string",
"enum": [
"http",
"https"
],
"description": "The protocol to use when forwarding this port."
}
},
"defaultSnippets": [
Expand Down Expand Up @@ -476,6 +492,14 @@
"type": "boolean",
"markdownDescription": "When true, a modal dialog will show if the chosen local port isn't used for forwarding.",
"default": false
},
"protocol": {
"type": "string",
"enum": [
"http",
"https"
],
"description": "The protocol to use when forwarding this port."
}
},
"default": {
Expand Down Expand Up @@ -534,6 +558,14 @@
"type": "boolean",
"markdownDescription": "When true, a modal dialog will show if the chosen local port isn't used for forwarding.",
"default": false
},
"protocol": {
"type": "string",
"enum": [
"http",
"https"
],
"description": "The protocol to use when forwarding this port."
}
},
"defaultSnippets": [
Expand Down Expand Up @@ -761,6 +793,14 @@
"type": "boolean",
"markdownDescription": "When true, a modal dialog will show if the chosen local port isn't used for forwarding.",
"default": false
},
"protocol": {
"type": "string",
"enum": [
"http",
"https"
],
"description": "The protocol to use when forwarding this port."
}
},
"default": {
Expand Down Expand Up @@ -819,6 +859,14 @@
"type": "boolean",
"markdownDescription": "When true, a modal dialog will show if the chosen local port isn't used for forwarding.",
"default": false
},
"protocol": {
"type": "string",
"enum": [
"http",
"https"
],
"description": "The protocol to use when forwarding this port."
}
},
"defaultSnippets": [
Expand Down Expand Up @@ -1012,6 +1060,14 @@
"type": "boolean",
"markdownDescription": "When true, a modal dialog will show if the chosen local port isn't used for forwarding.",
"default": false
},
"protocol": {
"type": "string",
"enum": [
"http",
"https"
],
"description": "The protocol to use when forwarding this port."
}
},
"default": {
Expand Down Expand Up @@ -1070,6 +1126,14 @@
"type": "boolean",
"markdownDescription": "When true, a modal dialog will show if the chosen local port isn't used for forwarding.",
"default": false
},
"protocol": {
"type": "string",
"enum": [
"http",
"https"
],
"description": "The protocol to use when forwarding this port."
}
},
"defaultSnippets": [
Expand Down Expand Up @@ -1232,6 +1296,14 @@
"type": "boolean",
"markdownDescription": "When true, a modal dialog will show if the chosen local port isn't used for forwarding.",
"default": false
},
"protocol": {
"type": "string",
"enum": [
"http",
"https"
],
"description": "The protocol to use when forwarding this port."
}
},
"default": {
Expand Down Expand Up @@ -1290,6 +1362,14 @@
"type": "boolean",
"markdownDescription": "When true, a modal dialog will show if the chosen local port isn't used for forwarding.",
"default": false
},
"protocol": {
"type": "string",
"enum": [
"http",
"https"
],
"description": "The protocol to use when forwarding this port."
}
},
"defaultSnippets": [
Expand Down Expand Up @@ -1379,4 +1459,4 @@
"additionalProperties": false
}
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@
"type": "boolean",
"markdownDescription": "When true, a modal dialog will show if the chosen local port isn't used for forwarding.",
"default": false
},
"protocol": {
"type": "string",
"enum": ["http", "https"],
"description": "The protocol to use when forwarding this port."
}
},
"default": {
Expand Down Expand Up @@ -130,6 +135,11 @@
"type": "boolean",
"markdownDescription": "When true, a modal dialog will show if the chosen local port isn't used for forwarding.",
"default": false
},
"protocol": {
"type": "string",
"enum": ["http", "https"],
"description": "The protocol to use when forwarding this port."
}
},
"defaultSnippets": [
Expand Down
23 changes: 8 additions & 15 deletions src/vs/workbench/contrib/remote/browser/tunnelView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,7 @@ class TunnelItem implements ITunnelItem {
tunnel.source ?? (tunnel.userForwarded ? nls.localize('tunnel.user', "User Forwarded") :
(type === TunnelType.Detected ? nls.localize('tunnel.staticallyForwarded', "Statically Forwarded") : nls.localize('tunnel.automatic', "Auto Forwarded"))),
!!tunnel.hasRunningProcess,
tunnel.localUri,
tunnel.localAddress,
tunnel.localPort,
closeable === undefined ? tunnel.closeable : closeable,
Expand All @@ -559,6 +560,7 @@ class TunnelItem implements ITunnelItem {
public remotePort: number,
public source: string,
public hasRunningProcess: boolean,
public localUri?: URI,
public localAddress?: string,
public localPort?: number,
public closeable?: boolean,
Expand Down Expand Up @@ -1167,12 +1169,8 @@ export namespace OpenPortInBrowserAction {

export function run(model: TunnelModel, openerService: IOpenerService, key: string) {
const tunnel = model.forwarded.get(key) || model.detected.get(key);
let address: string | undefined;
if (tunnel && tunnel.localAddress && (address = model.address(tunnel.remoteHost, tunnel.remotePort))) {
if (!address.startsWith('http')) {
address = `http://${address}`;
}
return openerService.open(URI.parse(address), { allowContributedOpeners: false });
if (tunnel) {
return openerService.open(tunnel.localUri, { allowContributedOpeners: false });
}
return Promise.resolve();
}
Expand Down Expand Up @@ -1201,18 +1199,13 @@ export namespace OpenPortInPreviewAction {

export async function run(model: TunnelModel, openerService: IOpenerService, externalOpenerService: IExternalUriOpenerService, key: string) {
const tunnel = model.forwarded.get(key) || model.detected.get(key);
let address: string | undefined;
if (tunnel && tunnel.localAddress && (address = model.address(tunnel.remoteHost, tunnel.remotePort))) {
if (!address.startsWith('http')) {
address = `http://${address}`;
}
const uri = URI.parse(address);
if (tunnel) {
const sourceUri = URI.parse(`http://${tunnel.remoteHost}:${tunnel.remotePort}`);
const opener = await externalOpenerService.getOpener(uri, { sourceUri }, new CancellationTokenSource().token);
const opener = await externalOpenerService.getOpener(tunnel.localUri, { sourceUri }, new CancellationTokenSource().token);
if (opener) {
return opener.openExternalUri(uri, { sourceUri }, new CancellationTokenSource().token);
return opener.openExternalUri(tunnel.localUri, { sourceUri }, new CancellationTokenSource().token);
}
return openerService.open(uri);
return openerService.open(tunnel.localUri);
}
return Promise.resolve();
}
Expand Down
10 changes: 10 additions & 0 deletions src/vs/workbench/contrib/remote/common/remote.contribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,11 @@ Registry.as<IConfigurationRegistry>(ConfigurationExtensions.Configuration)
type: 'boolean',
markdownDescription: localize('remote.portsAttributes.requireLocalPort', "When true, a modal dialog will show if the chosen local port isn't used for forwarding."),
default: false
},
'protocol': {
type: 'string',
enum: ['http', 'https'],
description: localize('remote.portsAttributes.protocol', "The protocol to use when forwarding this port.")
}
},
default: {
Expand Down Expand Up @@ -226,6 +231,11 @@ Registry.as<IConfigurationRegistry>(ConfigurationExtensions.Configuration)
type: 'boolean',
markdownDescription: localize('remote.portsAttributes.requireLocalPort', "When true, a modal dialog will show if the chosen local port isn't used for forwarding."),
default: false
},
'protocol': {
type: 'string',
enum: ['http', 'https'],
description: localize('remote.portsAttributes.protocol', "The protocol to use when forwarding this port.")
}
},
defaultSnippets: [{ body: { onAutoForward: 'ignore' } }],
Expand Down
Loading

0 comments on commit e4159c8

Please sign in to comment.