Compare commits

...

4 Commits

Author SHA1 Message Date
Asher
e14362f322 Pass along Node options 2019-11-14 17:20:23 -06:00
Asher
917aa48072 Update enterprise link
Fixes #1172.
2019-11-14 11:16:08 -06:00
Asher
938c6ef829 Update fail2ban configuration
Fixes #1177.
2019-11-14 11:14:27 -06:00
Sandro
0add01d383 Delete apt lists from final image (#1174) 2019-11-14 11:12:21 -06:00
5 changed files with 22 additions and 14 deletions

View File

@@ -33,7 +33,8 @@ RUN apt-get update && apt-get install -y \
dumb-init \ dumb-init \
vim \ vim \
curl \ curl \
wget wget \
&& rm -rf /var/lib/apt/lists/*
RUN locale-gen en_US.UTF-8 RUN locale-gen en_US.UTF-8
# We cannot use update-locale because docker will not use the env variables # We cannot use update-locale because docker will not use the env variables

View File

@@ -188,8 +188,8 @@ Our changes include:
## Enterprise ## Enterprise
Visit [our enterprise page](https://coder.com/enterprise) for more information Visit [our enterprise page](https://coder.com) for more information about our
about our enterprise offering. enterprise offering.
## Commercialization ## Commercialization

View File

@@ -2,11 +2,11 @@
[Definition] [Definition]
failregex = ^INFO\s+Failed login attempt\s+{\"password\":\"(\\.|[^"])*\",\"remoteAddress\":\"<HOST>\" failregex = ^Failed login attempt\s+{\"remoteAddress\":\"<HOST>\"
# Use this instead for proxies (ensure the proxy is configured to send the # Use this instead for proxies (ensure the proxy is configured to send the
# X-Forwarded-For header). # X-Forwarded-For header).
# failregex = ^INFO\s+Failed login attempt\s+{\"password\":\"(\\.|[^"])*\",\"xForwardedFor\":\"<HOST>\" # failregex = ^Failed login attempt\s+{\"xForwardedFor\":\"<HOST>\"
ignoreregex = ignoreregex =

View File

@@ -30,6 +30,6 @@ accessible from the internet (use localhost or block it in your firewall).
## Fail2Ban ## Fail2Ban
Fail2Ban allows for automatically banning and logging repeated failed Fail2Ban allows for automatically banning and logging repeated failed
authentication attempts for many applications through regex filters. A working authentication attempts for many applications through regex filters. A working
filter for code-server can be found in `./code-server.fail2ban.conf`. Once this filter for code-server can be found in `./examples/fail2ban.conf`. Once this
is installed and configured correctly, repeated failed login attempts should is installed and configured correctly, repeated failed login attempts should
automatically be banned from connecting to your server. automatically be banned from connecting to your server.

View File

@@ -47,7 +47,6 @@ const getArgs = (): Args => {
case "wait": case "wait":
case "disable-gpu": case "disable-gpu":
// TODO: pretty sure these don't work but not 100%. // TODO: pretty sure these don't work but not 100%.
case "max-memory":
case "prof-startup": case "prof-startup":
case "inspect-extensions": case "inspect-extensions":
case "inspect-brk-extensions": case "inspect-brk-extensions":
@@ -82,8 +81,7 @@ const getArgs = (): Args => {
return validatePaths(args); return validatePaths(args);
}; };
const startVscode = async (): Promise<void | void[]> => { const startVscode = async (args: Args): Promise<void | void[]> => {
const args = getArgs();
const extra = args["_"] || []; const extra = args["_"] || [];
const options = { const options = {
auth: args.auth || AuthType.Password, auth: args.auth || AuthType.Password,
@@ -155,8 +153,7 @@ const startVscode = async (): Promise<void | void[]> => {
} }
}; };
const startCli = (): boolean | Promise<void> => { const startCli = (args: Args): boolean | Promise<void> => {
const args = getArgs();
if (args.help) { if (args.help) {
const executable = `${product.applicationName}${os.platform() === "win32" ? ".exe" : ""}`; const executable = `${product.applicationName}${os.platform() === "win32" ? ".exe" : ""}`;
console.log(buildHelpMessage(product.nameLong, executable, product.codeServerVersion, OPTIONS, false)); console.log(buildHelpMessage(product.nameLong, executable, product.codeServerVersion, OPTIONS, false));
@@ -198,7 +195,7 @@ export class WrapperProcess {
private started?: Promise<void>; private started?: Promise<void>;
private currentVersion = product.codeServerVersion; private currentVersion = product.codeServerVersion;
public constructor() { public constructor(private readonly args: Args) {
ipcMain.onMessage(async (message) => { ipcMain.onMessage(async (message) => {
switch (message.type) { switch (message.type) {
case "relaunch": case "relaunch":
@@ -235,6 +232,14 @@ export class WrapperProcess {
} }
private spawn(): cp.ChildProcess { private spawn(): cp.ChildProcess {
// Flags to pass along to the Node binary. We use the environment variable
// since otherwise the code-server binary will swallow them.
const maxMemory = this.args["max-memory"] || 2048;
let nodeOptions = `${process.env.NODE_OPTIONS || ""} ${this.args["js-flags"] || ""}`;
if (!/max_old_space_size=(\d+)/g.exec(nodeOptions)) {
nodeOptions += ` --max_old_space_size=${maxMemory}`;
}
// If we're using loose files then we need to specify the path. If we're in // If we're using loose files then we need to specify the path. If we're in
// the binary we need to let the binary determine the path (via nbin) since // the binary we need to let the binary determine the path (via nbin) since
// it could be different between binaries which presents a problem when // it could be different between binaries which presents a problem when
@@ -246,6 +251,7 @@ export class WrapperProcess {
LAUNCH_VSCODE: "true", LAUNCH_VSCODE: "true",
NBIN_BYPASS: undefined, NBIN_BYPASS: undefined,
VSCODE_PARENT_PID: process.pid.toString(), VSCODE_PARENT_PID: process.pid.toString(),
NODE_OPTIONS: nodeOptions,
}, },
stdio: ["inherit", "inherit", "inherit", "ipc"], stdio: ["inherit", "inherit", "inherit", "ipc"],
}); });
@@ -253,11 +259,12 @@ export class WrapperProcess {
} }
const main = async(): Promise<boolean | void | void[]> => { const main = async(): Promise<boolean | void | void[]> => {
const args = getArgs();
if (process.env.LAUNCH_VSCODE) { if (process.env.LAUNCH_VSCODE) {
await ipcMain.handshake(); await ipcMain.handshake();
return startVscode(); return startVscode(args);
} }
return startCli() || new WrapperProcess().start(); return startCli(args) || new WrapperProcess(args).start();
}; };
const exit = process.exit; const exit = process.exit;