mirror of https://github.com/coder/code-server.git
Resolve remote authority to initialize tunnel API (#4105)
* Resolve remote authority to initialize tunnel API * Fix linting * Add comment
This commit is contained in:
parent
b32b4edf3d
commit
b00afbc034
|
@ -9,7 +9,7 @@ import { IWorkbenchExtensionEnablementService, IWebExtensionsScannerService } fr
|
||||||
import { IRemoteAgentService } from 'vs/workbench/services/remote/common/remoteAgentService';
|
import { IRemoteAgentService } from 'vs/workbench/services/remote/common/remoteAgentService';
|
||||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||||
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
|
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
|
||||||
import { IExtensionService, IExtensionHost } from 'vs/workbench/services/extensions/common/extensions';
|
import { IExtensionService, IExtensionHost, ExtensionHostKind, } from 'vs/workbench/services/extensions/common/extensions';
|
||||||
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
|
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
|
||||||
import { IFileService } from 'vs/platform/files/common/files';
|
import { IFileService } from 'vs/platform/files/common/files';
|
||||||
import { IProductService } from 'vs/platform/product/common/productService';
|
import { IProductService } from 'vs/platform/product/common/productService';
|
||||||
|
@ -28,6 +28,7 @@ import { IExtensionManagementService } from 'vs/platform/extensionManagement/com
|
||||||
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
|
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
|
||||||
import { IExtensionManifestPropertiesService } from 'vs/workbench/services/extensions/common/extensionManifestPropertiesService';
|
import { IExtensionManifestPropertiesService } from 'vs/workbench/services/extensions/common/extensionManifestPropertiesService';
|
||||||
import { IUserDataInitializationService } from 'vs/workbench/services/userData/browser/userDataInit';
|
import { IUserDataInitializationService } from 'vs/workbench/services/userData/browser/userDataInit';
|
||||||
|
import { IRemoteExplorerService } from '../../remote/common/remoteExplorerService';
|
||||||
|
|
||||||
export class ExtensionService extends AbstractExtensionService implements IExtensionService {
|
export class ExtensionService extends AbstractExtensionService implements IExtensionService {
|
||||||
|
|
||||||
|
@ -51,6 +52,7 @@ export class ExtensionService extends AbstractExtensionService implements IExten
|
||||||
@ILifecycleService private readonly _lifecycleService: ILifecycleService,
|
@ILifecycleService private readonly _lifecycleService: ILifecycleService,
|
||||||
@IExtensionManifestPropertiesService extensionManifestPropertiesService: IExtensionManifestPropertiesService,
|
@IExtensionManifestPropertiesService extensionManifestPropertiesService: IExtensionManifestPropertiesService,
|
||||||
@IUserDataInitializationService private readonly _userDataInitializationService: IUserDataInitializationService,
|
@IUserDataInitializationService private readonly _userDataInitializationService: IUserDataInitializationService,
|
||||||
|
@IRemoteExplorerService private readonly _remoteExplorerService: IRemoteExplorerService
|
||||||
) {
|
) {
|
||||||
super(
|
super(
|
||||||
new ExtensionRunningLocationClassifier(
|
new ExtensionRunningLocationClassifier(
|
||||||
|
@ -75,7 +77,24 @@ export class ExtensionService extends AbstractExtensionService implements IExten
|
||||||
// Initialize installed extensions first and do it only after workbench is ready
|
// Initialize installed extensions first and do it only after workbench is ready
|
||||||
this._lifecycleService.when(LifecyclePhase.Ready).then(async () => {
|
this._lifecycleService.when(LifecyclePhase.Ready).then(async () => {
|
||||||
await this._userDataInitializationService.initializeInstalledExtensions(this._instantiationService);
|
await this._userDataInitializationService.initializeInstalledExtensions(this._instantiationService);
|
||||||
this._initialize();
|
this._initialize().then(async () => {
|
||||||
|
try {
|
||||||
|
// This enables the `vscode.workspace.registerRemoteAuthorityResolver` API to be executed.
|
||||||
|
//
|
||||||
|
// It's specifically scoped to the "coder-link" scheme at the moment to reduce external
|
||||||
|
// dependency on forking VS Code functionality.
|
||||||
|
//
|
||||||
|
// The remote host doesn't resolve to an extension host like the API expects, but instead
|
||||||
|
// we only utilize the tunnel functionality.
|
||||||
|
const extHost = this._getExtensionHostManager(ExtensionHostKind.Remote);
|
||||||
|
const resolved = await extHost?.resolveAuthority('coder-link+web');
|
||||||
|
if (resolved) {
|
||||||
|
this._remoteExplorerService.setTunnelInformation(resolved.tunnelInformation);
|
||||||
|
}
|
||||||
|
} catch (ex) {
|
||||||
|
this._logOrShowMessage(Severity.Error, nls.localize('link', "Failed to initialize remote Link authority: {0}", ex));
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
this._initFetchFileSystem();
|
this._initFetchFileSystem();
|
||||||
|
|
Loading…
Reference in New Issue