Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[API] Let remote extensions expose a remote port to the client machine #81131

Closed
mjbvz opened this issue Sep 19, 2019 · 3 comments
Closed

[API] Let remote extensions expose a remote port to the client machine #81131

mjbvz opened this issue Sep 19, 2019 · 3 comments

Comments

@mjbvz
Copy link
Contributor

mjbvz commented Sep 19, 2019

Problem
Imagine a remote extension that spawns two processes: static html server and api server.

The extension can pass the localhost uri for the html server to openExternal and this will automatically establish port forwarding from the client machine to the target port on the remote machine. However the extension cannot currently open the port for the api server so the served up html will not be functional

Proposed API
Rather than letting extensions directly manage port forwarding, introduce a asExternalUri function that hides most of these details. This function would transparently establish port forwarding if it is required but would be a no-op for UI extensions or when VS Code is run locally.

Here's what this api could look like:

/**
 * Resolves a uri that points at a resource where the extension is running to a uri to the same resource on
 * the client machine.
 * 
 * This is a noop if the extension is running locally
 * 
 * If the extension is running remotely, this function establishes port forwarding from
 * the local machine to `target` on the remote and returns the local port for this connection
 * 
 * Note that uris passed through `openExternal` are automatically resolved. 
 */
asExternalUri(
	target: Uri,
): Thenable<Uri>;

In the remote case, the implementation of resolveUri would use VS Code's tunnel service to setup the port forwarding.

@mjbvz mjbvz self-assigned this Sep 19, 2019
@mjbvz mjbvz added this to the September 2019 milestone Sep 19, 2019
@mjbvz mjbvz changed the title API — Let remote extensions expose a remote port the client machine [API] Let remote extensions expose a remote port the client machine Sep 19, 2019
@mjbvz
Copy link
Contributor Author

mjbvz commented Sep 19, 2019

First version of this was checked in with 27bac59

@mjbvz mjbvz changed the title [API] Let remote extensions expose a remote port the client machine [API] Let remote extensions expose a remote port to the client machine Sep 19, 2019
mjbvz added a commit that referenced this issue Sep 23, 2019
…le result

For #81131

We had trouble coming up with cases where extensions could actually reliably dispose of the resolved uri
@mjbvz
Copy link
Contributor Author

mjbvz commented Sep 30, 2019

Renaming this from resolveExternalUri to asExternalUri to be consistent with our asWebviewUri and asExtensionUri apis

@mjbvz
Copy link
Contributor Author

mjbvz commented Sep 30, 2019

Closing this for verification

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant