@@ -19,6 +19,13 @@ For the `asExternalUri` changes, you'll need to test manually by:
19
19
Do the same thing but set `VSCODE_PROXY_URI: "https://{{port}}-main-workspace-name-user-name.coder.com"`
20
20
and the output should replace `{{port}}` with port used in input url.
21
21
22
+ This also enables the forwared ports view panel by default.
23
+
24
+ Lastly, it adds a tunnelProvider so that ports are forwarded using code-server's
25
+ built-in proxy. You can test this by starting a server i.e. `python3 -m
26
+ http.server` and it should show a notification and show up in the ports panel
27
+ using the /proxy/port.
28
+
22
29
Index: code-server/lib/vscode/src/vs/base/common/product.ts
23
30
===================================================================
24
31
--- code-server.orig/lib/vscode/src/vs/base/common/product.ts
@@ -77,7 +84,7 @@ Index: code-server/lib/vscode/src/vs/server/node/webClientServer.ts
77
84
rootEndpoint: base,
78
85
updateEndpoint: !this._environmentService.args['disable-update-check'] ? base + '/update/check' : undefined,
79
86
logoutEndpoint: this._environmentService.args['auth'] && this._environmentService.args['auth'] !== "none" ? base + '/logout' : undefined,
80
- + proxyEndpointTemplate: process.env.VSCODE_PROXY_URI ?? base + '/proxy/{{port}}',
87
+ + proxyEndpointTemplate: process.env.VSCODE_PROXY_URI ?? base + '/proxy/{{port}}/ ',
81
88
embedderIdentifier: 'server-distro',
82
89
extensionsGallery: this._productService.extensionsGallery,
83
90
},
@@ -115,21 +122,21 @@ Index: code-server/lib/vscode/src/vs/code/browser/workbench/workbench.ts
115
122
import type { IURLCallbackProvider } from 'vs/workbench/services/url/browser/urlService';
116
123
import type { IWorkbenchConstructionOptions } from 'vs/workbench/browser/web.api';
117
124
import type { IWorkspace, IWorkspaceProvider } from 'vs/workbench/services/host/browser/browserHostService';
118
- + import { extractLocalHostUriMetaDataForPortMapping } from 'vs/platform/tunnel/common/tunnel';
125
+ + import { extractLocalHostUriMetaDataForPortMapping, TunnelOptions, TunnelCreationOptions } from 'vs/platform/tunnel/common/tunnel';
119
126
120
127
interface ICredential {
121
128
service: string;
122
- @@ -511,6 +512,21 @@ function doCreateUri(path: string, query
129
+ @@ -511,6 +512,38 @@ function doCreateUri(path: string, query
123
130
} : undefined,
124
131
workspaceProvider: WorkspaceProvider.create(config),
125
132
urlCallbackProvider: new LocalStorageURLCallbackProvider(config.callbackRoute),
126
133
- credentialsProvider: config.remoteAuthority ? undefined : new LocalStorageCredentialsProvider() // with a remote, we don't use a local credentials provider
127
134
+ credentialsProvider: config.remoteAuthority ? undefined : new LocalStorageCredentialsProvider(), // with a remote, we don't use a local credentials provider
128
135
+ resolveExternalUri: (uri: URI): Promise<URI> => {
129
136
+ let resolvedUri = uri
130
- + const localhostMatch = extractLocalHostUriMetaDataForPortMapping(uri )
137
+ + const localhostMatch = extractLocalHostUriMetaDataForPortMapping(resolvedUri )
131
138
+
132
- + if (localhostMatch) {
139
+ + if (localhostMatch && resolvedUri.authority !== location.host ) {
133
140
+ if (config.productConfiguration && config.productConfiguration.proxyEndpointTemplate) {
134
141
+ resolvedUri = URI.parse(new URL(config.productConfiguration.proxyEndpointTemplate.replace('{{port}}', localhostMatch.port.toString()), window.location.href).toString())
135
142
+ } else {
@@ -139,6 +146,36 @@ Index: code-server/lib/vscode/src/vs/code/browser/workbench/workbench.ts
139
146
+
140
147
+ // If not localhost, return unmodified
141
148
+ return Promise.resolve(resolvedUri)
149
+ + },
150
+ + tunnelProvider: {
151
+ + tunnelFactory: (tunnelOptions: TunnelOptions, tunnelCreationOptions: TunnelCreationOptions) => {
152
+ + const onDidDispose: Emitter<void> = new Emitter();
153
+ + let isDisposed = false;
154
+ + return Promise.resolve({
155
+ + remoteAddress: tunnelOptions.remoteAddress,
156
+ + localAddress: `localhost:${tunnelOptions.remoteAddress.port}`,
157
+ + onDidDispose: onDidDispose.event,
158
+ + dispose: () => {
159
+ + if (!isDisposed) {
160
+ + isDisposed = true;
161
+ + onDidDispose.fire();
162
+ + }
163
+ + }
164
+ + })
165
+ + }
142
166
+ }
143
167
});
144
168
})();
169
+ Index: code-server/lib/vscode/src/vs/workbench/contrib/remote/browser/remoteExplorer.ts
170
+ ===================================================================
171
+ --- code-server.orig/lib/vscode/src/vs/workbench/contrib/remote/browser/remoteExplorer.ts
172
+ +++ code-server/lib/vscode/src/vs/workbench/contrib/remote/browser/remoteExplorer.ts
173
+ @@ -73,7 +73,7 @@ export class ForwardedPortsView extends
174
+ this.contextKeyListener = undefined;
175
+ }
176
+
177
+ - const viewEnabled: boolean = !!forwardedPortsViewEnabled.getValue(this.contextKeyService);
178
+ + const viewEnabled: boolean = true;
179
+
180
+ if (this.environmentService.remoteAuthority && viewEnabled) {
181
+ const viewContainer = await this.getViewContainer();
0 commit comments