Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 6.8k
fix: wrap socket in proxy before passing to vscode#4840
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
Merged
Uh oh!
There was an error while loading. Please reload this page.
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
db2eb4e
chore: add ipc hook to e2e script
jsjoeio 0541ecb
refactor: allow codeServerArgs in e2e tests
jsjoeio 85f9f7f
feat: add --cert e2e extension test
jsjoeio 9c6db5d
fix: wrap websocket in proxy
jsjoeio 1a145ea
fixup: remvoe ignoreHTTPSErrors
jsjoeio 7f5f32c
fixup: make codeServerArgs readonly
jsjoeio 6049dd3
fixup! add back ignoreHTTPSErrors
jsjoeio File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -5,6 +5,7 @@ import { logError } from "../../common/util" | ||
| import { toVsCodeArgs } from "../cli" | ||
| import { isDevMode } from "../constants" | ||
| import { authenticated, ensureAuthenticated, redirect, self } from "../http" | ||
| import { SocketProxyProvider } from "../socket" | ||
| import { loadAMDModule } from "../util" | ||
| import { Router as WsRouter } from "../wsRouter" | ||
| import { errorHandler } from "./errors" | ||
| @@ -13,6 +14,7 @@ export class CodeServerRouteWrapper { | ||
| /** Assigned in `ensureCodeServerLoaded` */ | ||
| private _codeServerMain!: CodeServerLib.IServerAPI | ||
| private _wsRouterWrapper = WsRouter() | ||
| private _socketProxyProvider = new SocketProxyProvider() | ||
| public router = express.Router() | ||
| public get wsRouter() { | ||
| @@ -77,9 +79,10 @@ export class CodeServerRouteWrapper { | ||
| } | ||
| private $proxyWebsocket = async (req: WebsocketRequest) => { | ||
| this._codeServerMain.handleUpgrade(req, req.socket) | ||
| const wrappedSocket = await this._socketProxyProvider.createProxy(req.ws) | ||
| this._codeServerMain.handleUpgrade(req, wrappedSocket) | ||
| req.socket.resume() | ||
| req.ws.resume() | ||
jsjoeio marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| } | ||
| //#endregion | ||
| @@ -130,5 +133,6 @@ export class CodeServerRouteWrapper { | ||
| dispose() { | ||
| this._codeServerMain?.dispose() | ||
| this._socketProxyProvider.stop() | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| import { describe, test } from "./baseFixture" | ||
| describe("Extensions", true, () => { | ||
| function runTestExtensionTests() { | ||
jsjoeio marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| // This will only work if the test extension is loaded into code-server. | ||
| test("should have access to VSCODE_PROXY_URI", async ({ codeServerPage }) => { | ||
| const address = await codeServerPage.address() | ||
| @@ -9,4 +9,12 @@ describe("Extensions", true, () => { | ||
| await codeServerPage.page.waitForSelector(`text=${address}/proxy/{{port}}`) | ||
| }) | ||
| } | ||
| describe("Extensions", true, [], () => { | ||
| runTestExtensionTests() | ||
| }) | ||
| describe("Extensions with --cert", true, ["--cert"], () => { | ||
| runTestExtensionTests() | ||
| }) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -31,7 +31,7 @@ export class CodeServer { | ||
| public readonly logger: Logger | ||
| private closed = false | ||
| constructor(name: string) { | ||
| constructor(name: string, private readonly codeServerArgs: string[]) { | ||
| this.logger = logger.named(name) | ||
| } | ||
| @@ -78,6 +78,7 @@ export class CodeServer { | ||
| "node", | ||
| [ | ||
| process.env.CODE_SERVER_TEST_ENTRY || ".", | ||
| ...this.codeServerArgs, | ||
jsjoeio marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| // Using port zero will spawn on a random port. | ||
| "--bind-addr", | ||
| "127.0.0.1:0", | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.