Skip to content

Commit 88cb7cc

Browse files
authored
Merge pull request coder#1 from codercom/master
test
2 parents 0535fd5 + 60937c6 commit 88cb7cc

File tree

15 files changed

+76
-31
lines changed

15 files changed

+76
-31
lines changed

.github/ISSUE_TEMPLATE/bug_report.md

+8-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name: Bug Report
33
about: Report problems and unexpected behavior.
44
title: ''
5-
labels: ''
5+
labels: 'bug'
66
assignees: ''
77
---
88

@@ -12,7 +12,11 @@ assignees: ''
1212
- `code-server` version: <!-- The version of code-server -->
1313
- OS Version: <!-- OS version, cloud provider, -->
1414

15-
#### Steps to Reproduce
15+
## Description
1616

17-
1.
18-
2.
17+
<!-- Describes the problem here -->
18+
19+
## Steps to Reproduce
20+
21+
1. <!-- step 1: click ... -->
22+
1. <!-- step 2: ... -->

.github/ISSUE_TEMPLATE/extension_bug.md

+7-3
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@ assignees: ''
1212
- OS Version: <!-- OS version, cloud provider, -->
1313
- Extension: <!-- Link to extension -->
1414

15-
#### Steps to Reproduce
15+
## Description
1616

17-
1.
18-
2.
17+
<!-- Describes the problem here -->
18+
19+
## Steps to Reproduce
20+
21+
1. <!-- step 1: click ... -->
22+
1. <!-- step 2: ... -->

.github/ISSUE_TEMPLATE/feature_request.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name: Feature Request
33
about: Suggest an idea for this project.
44
title: ''
5-
labels: ''
5+
labels: 'feature'
66
assignees: ''
77
---
88

.github/ISSUE_TEMPLATE/question.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@
22
name: Question
33
about: Ask a question.
44
title: ''
5-
labels: ''
5+
labels: 'question'
66
assignees: ''
77
---
88

99
<!-- Please search existing issues to avoid creating duplicates. -->
1010

11-
#### Description
11+
## Description
1212

1313
<!-- A description of the the question. -->
1414

15-
#### Related Issues
15+
## Related Issues
1616

1717
<!-- Any issues related to your question. -->

Dockerfile

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ COPY . .
1515
# directly which should be fast as it is slow because it populates its own cache every time.
1616
RUN yarn && yarn task build:server:binary
1717

18-
# We deploy with ubuntu so that devs have a familiar environemnt.
18+
# We deploy with ubuntu so that devs have a familiar environment.
1919
FROM ubuntu:18.10
2020
WORKDIR /root/project
2121
COPY --from=0 /src/packages/server/cli-linux-x64 /usr/local/bin/code-server
@@ -28,5 +28,5 @@ RUN apt-get install -y locales && \
2828
# We unfortunately cannot use update-locale because docker will not use the env variables
2929
# configured in /etc/default/locale so we need to set it manually.
3030
ENV LANG=en_US.UTF-8
31-
# Unfortunately `.` does not work with code-server.
32-
CMD code-server $PWD
31+
ENTRYPOINT code-server
32+
CMD ["."]

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
Try it out:
1111
```bash
12-
docker run -p 127.0.0.1:8443:8443 -v "${PWD}:/root/project" codercom/code-server code-server --allow-http --no-auth
12+
docker run -t -p 127.0.0.1:8443:8443 -v "${PWD}:/root/project" codercom/code-server --allow-http --no-auth
1313
```
1414

1515
- Code on your Chromebook, tablet, and laptop with a consistent dev environment.

build/tasks.ts

+6-7
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ const libPath = path.join(__dirname, "../lib");
1010
const vscodePath = path.join(libPath, "vscode");
1111
const pkgsPath = path.join(__dirname, "../packages");
1212
const defaultExtensionsPath = path.join(libPath, "VSCode-linux-x64/resources/app/extensions");
13+
const vscodeVersion = "1.32";
1314

1415
const buildServerBinary = register("build:server:binary", async (runner) => {
1516
await ensureInstalled();
@@ -219,17 +220,11 @@ const ensureCloned = register("vscode:clone", async (runner) => {
219220
} else {
220221
fse.mkdirpSync(libPath);
221222
runner.cwd = libPath;
222-
const clone = await runner.execute("git", ["clone", "https://github.com/microsoft/vscode"]);
223+
const clone = await runner.execute("git", ["clone", "https://github.com/microsoft/vscode", "--branch", `release/${vscodeVersion}`, "--single-branch", "--depth=1"]);
223224
if (clone.exitCode !== 0) {
224225
throw new Error(`Failed to clone: ${clone.exitCode}`);
225226
}
226227
}
227-
228-
runner.cwd = vscodePath;
229-
const checkout = await runner.execute("git", ["checkout", "tags/1.32.0"]);
230-
if (checkout.exitCode !== 0) {
231-
throw new Error(`Failed to checkout: ${checkout.stderr}`);
232-
}
233228
});
234229

235230
const ensureClean = register("vscode:clean", async (runner) => {
@@ -246,6 +241,10 @@ const ensureClean = register("vscode:clean", async (runner) => {
246241
throw new Error(`Failed to remove unstaged files: ${removeUnstaged.stderr}`);
247242
}
248243
}
244+
const fetch = await runner.execute("git", ["fetch", "--prune"]);
245+
if (fetch.exitCode !== 0) {
246+
throw new Error(`Failed to fetch latest changes: ${fetch.stderr}`);
247+
}
249248
});
250249

251250
const ensurePatched = register("vscode:patch", async (runner) => {

doc/self-hosted/index.md

+15
Original file line numberDiff line numberDiff line change
@@ -74,5 +74,20 @@ OPTIONS
7474
7575
> To ensure the connection between you and your server is encrypted view our guide on [securing your setup](../security/ssl.md)
7676
77+
### Nginx Reverse Proxy
78+
Nginx is for reverse proxy. Here is a example virtual host that works with code-server. Please also pass --allow-http. You can also use certbot by EFF to get a ssl certificates for free.
79+
```
80+
server {
81+
listen 80;
82+
listen [::]:80;
83+
server_name code.example.com code.example.org;
84+
location / {
85+
proxy_pass http://localhost:8443/;
86+
proxy_set_header Upgrade $http_upgrade;
87+
proxy_set_header Connection upgrade;
88+
}
89+
}
90+
```
91+
7792
### Help
7893
Use `code-server -h` or `code-server --help` to view the usage for the cli. This is also shown at the beginning of this section.

packages/ide/src/fill/client.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,9 @@ class WebsocketConnection implements ReadWriteConnection {
9191
*/
9292
private async openSocket(): Promise<WebSocket> {
9393
this.dispose();
94+
const wsProto = location.protocol === "https:" ? "wss" : "ws";
9495
const socket = new WebSocket(
95-
`${location.protocol === "https:" ? "wss" : "ws"}://${location.host}`,
96+
`${wsProto}://${location.host}${location.pathname}`,
9697
);
9798
socket.binaryType = "arraybuffer";
9899
this.activeSocket = socket;

packages/server/package.json

+2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"node-netstat": "^1.6.0",
2020
"pem": "^1.14.1",
2121
"promise.prototype.finally": "^3.1.0",
22+
"safe-compare": "^1.1.4",
2223
"ws": "^6.1.2",
2324
"xhr2": "^0.1.4"
2425
},
@@ -28,6 +29,7 @@
2829
"@types/mime-types": "^2.1.0",
2930
"@types/opn": "^5.1.0",
3031
"@types/pem": "^1.9.4",
32+
"@types/safe-compare": "^1.1.0",
3133
"@types/ws": "^6.0.1",
3234
"fs-extra": "^7.0.1",
3335
"nexe": "^2.0.0-rc.34",

packages/server/src/cli.ts

+7-3
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { requireModule, requireFork, forkModule } from "./vscode/bootstrapFork";
1212
import { SharedProcess, SharedProcessState } from "./vscode/sharedProcess";
1313
import { setup as setupNativeModules } from "./modules";
1414
import { fillFs } from "./fill";
15-
import { isCli, serveStatic, buildDir } from "./constants";
15+
import { isCli, serveStatic, buildDir, dataHome, cacheHome } from "./constants";
1616
import opn = require("opn");
1717

1818
export class Entry extends Command {
@@ -49,7 +49,7 @@ export class Entry extends Command {
4949
}
5050

5151
const { args, flags } = this.parse(Entry);
52-
const dataDir = path.resolve(flags["data-dir"] || path.join(os.homedir(), ".code-server"));
52+
const dataDir = path.resolve(flags["data-dir"] || path.join(dataHome, "code-server"));
5353
const workingDir = path.resolve(args["workdir"]);
5454

5555
setupNativeModules(dataDir);
@@ -81,7 +81,11 @@ export class Entry extends Command {
8181
fs.mkdirSync(dataDir);
8282
}
8383

84-
const logDir = path.join(dataDir, "logs", new Date().toISOString().replace(/[-:.TZ]/g, ""));
84+
if (!fs.existsSync(cacheHome)) {
85+
fs.mkdirSync(cacheHome);
86+
}
87+
88+
const logDir = path.join(cacheHome, "code-server/logs", new Date().toISOString().replace(/[-:.TZ]/g, ""));
8589
process.env.VSCODE_LOGS = logDir;
8690

8791
const certPath = flags.cert ? path.resolve(flags.cert) : undefined;

packages/server/src/constants.ts

+6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
import * as path from "path";
2+
import * as os from "os";
23

34
export const isCli = typeof process.env.CLI !== "undefined" && process.env.CLI !== "false";
45
export const serveStatic = typeof process.env.SERVE_STATIC !== "undefined" && process.env.SERVE_STATIC !== "false";
56
export const buildDir = process.env.BUILD_DIR ? path.resolve(process.env.BUILD_DIR) : "";
7+
const xdgResolve = (primary: string | undefined, fallback: string): string => {
8+
return primary ? path.resolve(primary) : path.resolve(process.env.HOME || os.homedir(), fallback);
9+
};
10+
export const dataHome = xdgResolve(process.env.XDG_DATA_HOME, ".local/share");
11+
export const cacheHome = xdgResolve(process.env.XDG_CACHE_HOME, ".cache");

packages/server/src/server.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import * as path from "path";
1616
import * as pem from "pem";
1717
import * as util from "util";
1818
import * as ws from "ws";
19+
import safeCompare = require("safe-compare");
1920
import { TunnelCloseCode } from "@coder/tunnel/src/common";
2021
import { handle as handleTunnel } from "@coder/tunnel/src/server";
2122
import { createPortScanner } from "./portScanner";
@@ -67,7 +68,7 @@ export const createApp = async (options: CreateAppOptions): Promise<{
6768

6869
// Try/catch placed here just in case
6970
const cookies = parseCookies(req);
70-
if (cookies.password && cookies.password === options.password) {
71+
if (cookies.password && safeCompare(cookies.password, options.password)) {
7172
return true;
7273
}
7374
} catch (ex) {

packages/server/yarn.lock

+12
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,11 @@
148148
resolved "https://registry.yarnpkg.com/@types/range-parser/-/range-parser-1.2.3.tgz#7ee330ba7caafb98090bece86a5ee44115904c2c"
149149
integrity sha512-ewFXqrQHlFsgc09MK5jP5iR7vumV/BYayNC6PgJO2LPe8vrnNFyjQjSppfEngITi0qvfKtzFvgKymGheFM9UOA==
150150

151+
"@types/safe-compare@^1.1.0":
152+
version "1.1.0"
153+
resolved "https://registry.yarnpkg.com/@types/safe-compare/-/safe-compare-1.1.0.tgz#47ed9b9ca51a3a791b431cd59b28f47fa9bf1224"
154+
integrity sha512-1ri+LJhh0gRxIa37IpGytdaW7yDEHeJniBSMD1BmitS07R1j63brcYCzry+l0WJvGdEKQNQ7DYXO2epgborWPw==
155+
151156
"@types/serve-static@*":
152157
version "1.13.2"
153158
resolved "https://registry.yarnpkg.com/@types/serve-static/-/serve-static-1.13.2.tgz#f5ac4d7a6420a99a6a45af4719f4dcd8cd907a48"
@@ -3155,6 +3160,13 @@ [email protected], safe-buffer@^5.0.1, safe-buffer@^5.1.1, safe-buffer@^5.1.2, s
31553160
resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.2.tgz#991ec69d296e0313747d59bdfd2b745c35f8828d"
31563161
integrity sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==
31573162

3163+
safe-compare@^1.1.4:
3164+
version "1.1.4"
3165+
resolved "https://registry.yarnpkg.com/safe-compare/-/safe-compare-1.1.4.tgz#5e0128538a82820e2e9250cd78e45da6786ba593"
3166+
integrity sha512-b9wZ986HHCo/HbKrRpBJb2kqXMK9CEWIE1egeEvZsYn69ay3kdfl9nG3RyOcR+jInTDf7a86WQ1d4VJX7goSSQ==
3167+
dependencies:
3168+
buffer-alloc "^1.2.0"
3169+
31583170
safe-regex@^1.1.0:
31593171
version "1.1.0"
31603172
resolved "https://registry.yarnpkg.com/safe-regex/-/safe-regex-1.1.0.tgz#40a3669f3b077d1e943d44629e157dd48023bf2e"

scripts/install-packages.ts

+1-4
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,7 @@ const handlePackages = async (dir: string): Promise<void> => {
4141
const pkgDir = join(dir, pkg);
4242
const pkgJsonPath = join(pkgDir, "package.json");
4343
if (existsSync(pkgJsonPath)) {
44-
const ip = doInstall(pkg, pkgDir);
45-
if (os.platform() === "win32") {
46-
await ip;
47-
}
44+
const ip = await doInstall(pkg, pkgDir);
4845
}
4946
}
5047
};

0 commit comments

Comments
 (0)