Skip to content

Commit

Permalink
Use unique socket path per user.
Browse files Browse the repository at this point in the history
  • Loading branch information
sleexyz committed Jun 21, 2023
1 parent 8b27c26 commit 351d9b4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
5 changes: 2 additions & 3 deletions src/node/vscodeSocket.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import { logger } from "@coder/logger"
import express from "express"
import * as http from "http"
import * as os from "os"
import * as path from "path"
import { HttpCode } from "../common/http"
import { listen } from "./app"
import { canConnect } from "./util"
import { canConnect, paths } from "./util"

// Socket path of the daemonized code-server instance.
export const DEFAULT_SOCKET_PATH = path.join(os.tmpdir(), "code-server-ipc.sock")
export const DEFAULT_SOCKET_PATH = path.join(paths.data, `code-server-ipc.sock`)

export interface EditorSessionEntry {
workspace: {
Expand Down
13 changes: 12 additions & 1 deletion test/unit/node/vscodeSocket.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
import { logger } from "@coder/logger"
import * as app from "../../../src/node/app"
import { EditorSessionManager, makeEditorSessionManagerServer } from "../../../src/node/vscodeSocket"
import { paths } from "../../../src/node/util"
import {
DEFAULT_SOCKET_PATH,
EditorSessionManager,
makeEditorSessionManagerServer,
} from "../../../src/node/vscodeSocket"
import { clean, tmpdir, listenOn, mockLogger } from "../../utils/helpers"

describe("DEFAULT_SOCKET_PATH", () => {
it("should be a unique path per user", () => {
expect(DEFAULT_SOCKET_PATH.startsWith(paths.data)).toBe(true)
})
})

describe("makeEditorSessionManagerServer", () => {
let tmpDirPath: string

Expand Down

0 comments on commit 351d9b4

Please sign in to comment.