Skip to content

Commit fab2712

Browse files
committed
Add CONTRIBUTING.md and demo GIF to README
1 parent dd9d148 commit fab2712

File tree

5 files changed

+55
-5
lines changed

5 files changed

+55
-5
lines changed

CONTRIBUTING.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Contributing
2+
3+
## Architecture
4+
5+
Workspaces opened with Coder Remote have the following URI structure:
6+
7+
```
8+
vscode://ssh-remote+coder-vscode--<username>--<workspace>/
9+
```
10+
11+
The `ssh-remote` scheme is used by the [Remote - SSH](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-ssh) extension from Microsoft that connects to remote machines.
12+
13+
Coder uses the `onResolveRemoteAuthority:ssh-remote` [extension activation event](https://code.visualstudio.com/api/references/activation-events) to activate the workspace when this scheme is used. On activation, we check if `vscode.workspace.workspaceFolders` contains the `coder-vscode--` prefix, and if so we delay activation to:
14+
15+
1. Match the workspace owner and name from the URI scheme and validate it's accessible.
16+
2. Download the matching server binary to the client.
17+
3. Add an entry to the users SSH config for VS Code Remote to resolve `coder-vscode--*`.
18+
19+
```
20+
Host coder-vscode--*
21+
ProxyCommand "/tmp/coder" vscodessh --network-info-dir "/home/kyle/.config/Code/User/globalStorage/coder.coder-remote/net" --session-token-file "/home/kyle/.config/Code/User/globalStorage/coder.coder-remote/session_token" --url-file "/home/kyle/.config/Code/User/globalStorage/coder.coder-remote/url" %h
22+
ConnectTimeout 0
23+
StrictHostKeyChecking no
24+
UserKnownHostsFile /dev/null
25+
LogLevel ERROR
26+
```
27+
28+
VS Code SSH uses the `ssh -D <port>` flag to start a SOCKS server on the specified port. This port is printed to the `Remote - SSH` log file in the VS Code Output panel in the format `-> socksPort <port> ->`. We use this port to find the SSH process ID that is being used by the remote session.
29+
30+
The `vscodessh` subcommand on the `coder` binary periodically flushes it's network information to `network-info-dir + "/" + process.ppid`. SSH executes `ProxyCommand`, which means the `process.ppid` will always be the matching SSH command.
31+
32+
Coder Remote periodically reads the `network-info-dir + "/" + matchingSSHPID` file to display network information.
33+
34+
## Development
35+
36+
1. Run `yarn watch` in the background.
37+
2. Compile the `coder` binary and place it in the equivalent of `os.tmpdir() + "/coder"`.
38+
39+
On Linux or Mac:
40+
41+
```bash
42+
# Inside https://github.com/coder/coder
43+
$ go build -o /tmp/coder ./cmd/coder
44+
```
45+
46+
3. Press `F5` or navigate to the "Run and Debug" tab of VS Code and click "Run Extension".

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ The Coder Remote VS Code extension lets you open
1515
- Works in air-gapped or restricted networks. Just connect to your Coder
1616
deployment!
1717

18+
![demo.gif](./demo.gif)
19+
1820
## Getting Started
1921

2022
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press

demo.gif

3 MB
Loading

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"description": "Open any workspace with a single click.",
66
"repository": "https://github.com/coder/vscode-coder",
77
"preview": true,
8-
"version": "0.0.7",
8+
"version": "0.0.8",
99
"engines": {
1010
"vscode": "^1.73.0"
1111
},

src/remote.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -384,13 +384,15 @@ export class Remote {
384384
const parsedConfig = SSHConfig.parse(sshConfigRaw)
385385
const computedHost = parsedConfig.compute(sshHost)
386386

387-
let binaryPath = await this.storage.fetchBinary()
387+
let binaryPath: string | undefined
388+
if (this.mode === vscode.ExtensionMode.Production) {
389+
binaryPath = await this.storage.fetchBinary()
390+
} else {
391+
binaryPath = path.join(os.tmpdir(), "coder")
392+
}
388393
if (!binaryPath) {
389394
throw new Error("Failed to fetch the Coder binary!")
390395
}
391-
if (this.mode === vscode.ExtensionMode.Development) {
392-
binaryPath = path.join(os.tmpdir(), "coder")
393-
}
394396

395397
parsedConfig.remove({ Host: computedHost.Host })
396398
const escape = (str: string): string => `"${str.replace(/"/g, '\\"')}"`

0 commit comments

Comments
 (0)