diff --git a/package.json b/package.json index 143b54c0..69c8b61d 100644 --- a/package.json +++ b/package.json @@ -299,12 +299,12 @@ "eslint-config-prettier": "^9.1.0", "eslint-plugin-import": "^2.31.0", "eslint-plugin-md": "^1.0.19", - "eslint-plugin-prettier": "^5.2.6", + "eslint-plugin-prettier": "^5.4.0", "glob": "^10.4.2", "nyc": "^17.1.0", "prettier": "^3.3.3", "ts-loader": "^9.5.1", - "tsc-watch": "^6.2.0", + "tsc-watch": "^6.2.1", "typescript": "^5.4.5", "utf-8-validate": "^6.0.5", "vitest": "^0.34.6", @@ -324,8 +324,8 @@ "proxy-agent": "^6.4.0", "semver": "^7.6.2", "ua-parser-js": "^1.0.38", - "ws": "^8.18.1", - "zod": "^3.23.8" + "ws": "^8.18.2", + "zod": "^3.24.3" }, "resolutions": { "semver": "7.6.2", diff --git a/src/remote.ts b/src/remote.ts index 5b8a9694..540525ed 100644 --- a/src/remote.ts +++ b/src/remote.ts @@ -19,7 +19,7 @@ import { Inbox } from "./inbox" import { SSHConfig, SSHValues, mergeSSHConfigValues } from "./sshConfig" import { computeSSHProperties, sshSupportsSetEnv } from "./sshSupport" import { Storage } from "./storage" -import { AuthorityPrefix, expandPath, parseRemoteAuthority } from "./util" +import { AuthorityPrefix, expandPath, findPort, parseRemoteAuthority } from "./util" import { WorkspaceMonitor } from "./workspaceMonitor" export interface RemoteDetails extends vscode.Disposable { @@ -698,8 +698,18 @@ export class Remote { derp_latency: { [key: string]: number } upload_bytes_sec: number download_bytes_sec: number + using_coder_connect: boolean }) => { let statusText = "$(globe) " + + // Coder Connect doesn't populate any other stats + if (network.using_coder_connect) { + networkStatus.text = statusText + "Coder Connect " + networkStatus.tooltip = "You're connected using Coder Connect." + networkStatus.show() + return + } + if (network.p2p) { statusText += "Direct " networkStatus.tooltip = "You're connected peer-to-peer ✨." @@ -783,14 +793,7 @@ export class Remote { // this to find the SSH process that is powering this connection. That SSH // process will be logging network information periodically to a file. const text = await fs.readFile(logPath, "utf8") - const matches = text.match(/-> socksPort (\d+) ->/) - if (!matches) { - return - } - if (matches.length < 2) { - return - } - const port = Number.parseInt(matches[1]) + const port = await findPort(text) if (!port) { return } diff --git a/src/util.ts b/src/util.ts index 8253f152..87707210 100644 --- a/src/util.ts +++ b/src/util.ts @@ -13,6 +13,33 @@ export interface AuthorityParts { // they should be handled by this extension. export const AuthorityPrefix = "coder-vscode" +// `ms-vscode-remote.remote-ssh`: `-> socksPort ->` +// `codeium.windsurf-remote-openssh`, `jeanp413.open-remote-ssh`: `=> (socks) =>` +// Windows `ms-vscode-remote.remote-ssh`: `between local port ` +export const RemoteSSHLogPortRegex = /(?:-> socksPort (\d+) ->|=> (\d+)\(socks\) =>|between local port (\d+))/ + +/** + * Given the contents of a Remote - SSH log file, find a port number used by the + * SSH process. This is typically the socks port, but the local port works too. + * + * Returns null if no port is found. + */ +export async function findPort(text: string): Promise { + const matches = text.match(RemoteSSHLogPortRegex) + if (!matches) { + return null + } + if (matches.length < 2) { + return null + } + const portStr = matches[1] || matches[2] || matches[3] + if (!portStr) { + return null + } + + return Number.parseInt(portStr) +} + /** * Given an authority, parse into the expected parts. * diff --git a/yarn.lock b/yarn.lock index c57cfe49..cb80191d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2482,10 +2482,10 @@ eslint-plugin-md@^1.0.19: remark-preset-lint-markdown-style-guide "^2.1.3" requireindex "~1.1.0" -eslint-plugin-prettier@^5.2.6: - version "5.2.6" - resolved "https://registry.yarnpkg.com/eslint-plugin-prettier/-/eslint-plugin-prettier-5.2.6.tgz#be39e3bb23bb3eeb7e7df0927cdb46e4d7945096" - integrity sha512-mUcf7QG2Tjk7H055Jk0lGBjbgDnfrvqjhXh9t2xLMSCjZVcw9Rb1V6sVNXO0th3jgeO7zllWPTNRil3JW94TnQ== +eslint-plugin-prettier@^5.4.0: + version "5.4.0" + resolved "https://registry.yarnpkg.com/eslint-plugin-prettier/-/eslint-plugin-prettier-5.4.0.tgz#54d4748904e58eaf1ffe26c4bffa4986ca7f952b" + integrity sha512-BvQOvUhkVQM1i63iMETK9Hjud9QhqBnbtT1Zc642p9ynzBuCe5pybkOnvqZIBypXmMlsGcnU4HZ8sCTPfpAexA== dependencies: prettier-linter-helpers "^1.0.0" synckit "^0.11.0" @@ -6311,10 +6311,10 @@ ts-loader@^9.5.1: semver "^7.3.4" source-map "^0.7.4" -tsc-watch@^6.2.0: - version "6.2.0" - resolved "https://registry.yarnpkg.com/tsc-watch/-/tsc-watch-6.2.0.tgz#4b191c36c6ed24c2bf6e721013af0825cd73d217" - integrity sha512-2LBhf9kjKXnz7KQ/puLHlozMzzUNHAdYBNMkg3eksQJ9GBAgMg8czznM83T5PmsoUvDnXzfIeQn2lNcIYDr8LA== +tsc-watch@^6.2.1: + version "6.2.1" + resolved "https://registry.yarnpkg.com/tsc-watch/-/tsc-watch-6.2.1.tgz#861801be929b2fd3d597c5f608db2b7ddba503db" + integrity sha512-GLwdz5Dy9K3sVm3RzgkLcyDpl5cvU9HEcE1A3gf5rqEwlUe7gDLxNCgcuNEw3zoKOiegMo3LnbF1t6HLqxhrSA== dependencies: cross-spawn "^7.0.3" node-cleanup "^2.1.2" @@ -6708,9 +6708,9 @@ vite-node@0.34.6: vite "^3.0.0 || ^4.0.0 || ^5.0.0-0" "vite@^3.0.0 || ^4.0.0 || ^5.0.0-0", "vite@^3.1.0 || ^4.0.0 || ^5.0.0-0": - version "5.4.18" - resolved "https://registry.yarnpkg.com/vite/-/vite-5.4.18.tgz#b5af357f9d5ebb2e0c085779b7a37a77f09168a4" - integrity sha512-1oDcnEp3lVyHCuQ2YFelM4Alm2o91xNoMncRm1U7S+JdYfYOvbiGZ3/CxGttrOu2M/KcGz7cRC2DoNUA6urmMA== + version "5.4.19" + resolved "https://registry.yarnpkg.com/vite/-/vite-5.4.19.tgz#20efd060410044b3ed555049418a5e7d1998f959" + integrity sha512-qO3aKv3HoQC8QKiNSTuUM1l9o/XX3+c+VTgLHbJWHZGeTPVAg2XwazI9UWzoxjIJCGCV2zU60uqMzjeLZuULqA== dependencies: esbuild "^0.21.3" postcss "^8.4.43" @@ -6965,10 +6965,10 @@ write@1.0.3: dependencies: mkdirp "^0.5.1" -ws@^8.18.1: - version "8.18.1" - resolved "https://registry.yarnpkg.com/ws/-/ws-8.18.1.tgz#ea131d3784e1dfdff91adb0a4a116b127515e3cb" - integrity sha512-RKW2aJZMXeMxVpnZ6bck+RswznaxmzdULiBr6KY7XkTnW8uvt0iT9H5DkHUChXrc+uurzwa0rVI16n/Xzjdz1w== +ws@^8.18.2: + version "8.18.2" + resolved "https://registry.yarnpkg.com/ws/-/ws-8.18.2.tgz#42738b2be57ced85f46154320aabb51ab003705a" + integrity sha512-DMricUmwGZUVr++AEAe2uiVM7UoO9MAVZMDu05UQOaUII0lp+zOzLLU4Xqh/JvTqklB1T4uELaaPBKyjE1r4fQ== xml2js@^0.5.0: version "0.5.0" @@ -7053,7 +7053,7 @@ yocto-queue@^1.0.0: resolved "https://registry.yarnpkg.com/yocto-queue/-/yocto-queue-1.0.0.tgz#7f816433fb2cbc511ec8bf7d263c3b58a1a3c251" integrity sha512-9bnSc/HEW2uRy67wc+T8UwauLuPJVn28jb+GtJY16iiKWyvmYJRXVT4UamsAEGQfPohgr2q4Tq0sQbQlxTfi1g== -zod@^3.23.8: - version "3.23.8" - resolved "https://registry.yarnpkg.com/zod/-/zod-3.23.8.tgz#e37b957b5d52079769fb8097099b592f0ef4067d" - integrity sha512-XBx9AXhXktjUqnepgTiE5flcKIYWi/rme0Eaj+5Y0lftuGBq+jyRu/md4WnuxqgP1ubdpNCsYEYPxrzVHD8d6g== +zod@^3.24.3: + version "3.24.3" + resolved "https://registry.yarnpkg.com/zod/-/zod-3.24.3.tgz#1f40f750a05e477396da64438e0e1c0995dafd87" + integrity sha512-HhY1oqzWCQWuUqvBFnsyrtZRhyPeR7SUGv+C4+MsisMuVfSPx8HpwWqH8tRahSlt6M3PiFAcoeFhZAqIXTxoSg==