Browse Source

Added startup option to disable helmet

pull/193/head
Anthony Jund 6 years ago
parent
commit
981b0b2059
  1. 6
      index.js
  2. 6
      src/server/index.ts
  3. 1
      src/server/interfaces.ts
  4. 9
      src/server/server.ts

6
index.js

@ -94,6 +94,12 @@ if (require.main === module) {
type: 'string', type: 'string',
default: process.env.COMMAND || 'login', default: process.env.COMMAND || 'login',
}, },
'no-helmet': {
demand: false,
description: 'disable helmet from placing security restrictions',
type: 'boolean',
default: false,
},
help: { help: {
demand: false, demand: false,
alias: 'h', alias: 'h',

6
src/server/index.ts

@ -17,6 +17,7 @@ export interface Options {
port: number; port: number;
title: string; title: string;
command?: string; command?: string;
disableHelmet?: boolean;
} }
interface CLI extends Options { interface CLI extends Options {
@ -38,6 +39,7 @@ export default class Server {
command, command,
sslkey, sslkey,
sslcert, sslcert,
disableHelmet,
}: Options): Promise<void> { }: Options): Promise<void> {
wetty wetty
.on('exit', ({ code, msg }: { code: number; msg: string }) => { .on('exit', ({ code, msg }: { code: number; msg: string }) => {
@ -56,11 +58,11 @@ export default class Server {
host: sshhost, host: sshhost,
auth: sshauth, auth: sshauth,
port: sshport, port: sshport,
title: title, title,
pass: sshpass, pass: sshpass,
key: sshkey, key: sshkey,
}, },
{ base, host, port, title }, { base, host, port, title, disableHelmet },
command, command,
{ key: sslkey, cert: sslcert } { key: sslkey, cert: sslcert }
); );

1
src/server/interfaces.ts

@ -21,4 +21,5 @@ export interface Server {
port: number; port: number;
host: string; host: string;
base: string; base: string;
disableHelmet: boolean;
} }

9
src/server/server.ts

@ -17,7 +17,7 @@ const distDir = path.join(__dirname, 'client');
const trim = (str: string): string => str.replace(/\/*$/, ''); const trim = (str: string): string => str.replace(/\/*$/, '');
export default function createServer( export default function createServer(
{ base, port, host, title }: Server, { base, port, host, title, disableHelmet }: Server,
{ key, cert }: SSLBuffer { key, cert }: SSLBuffer
): SocketIO.Server { ): SocketIO.Server {
const basePath = trim(base); const basePath = trim(base);
@ -49,7 +49,7 @@ export default function createServer(
</div> </div>
<div id="options"> <div id="options">
<a class="toggler" <a class="toggler"
href="#" href="#"
alt="Toggle options"><i class="fas fa-cogs"></i></a> alt="Toggle options"><i class="fas fa-cogs"></i></a>
<textarea class="editor"></textarea> <textarea class="editor"></textarea>
</div> </div>
@ -61,7 +61,6 @@ export default function createServer(
const app = express(); const app = express();
app app
.use(morgan('combined', { stream: logger.stream })) .use(morgan('combined', { stream: logger.stream }))
.use(helmet())
.use(compression()) .use(compression())
.use(favicon(path.join(distDir, 'favicon.ico'))) .use(favicon(path.join(distDir, 'favicon.ico')))
.use(`${basePath}/public`, express.static(distDir)) .use(`${basePath}/public`, express.static(distDir))
@ -77,6 +76,10 @@ export default function createServer(
.get(basePath, html) .get(basePath, html)
.get(`${basePath}/ssh/:user`, html); .get(`${basePath}/ssh/:user`, html);
if (!disableHelmet) {
app.use(helmet());
}
return socket( return socket(
!isUndefined(key) && !isUndefined(cert) !isUndefined(key) && !isUndefined(cert)
? https.createServer({ key, cert }, app).listen(port, host, () => { ? https.createServer({ key, cert }, app).listen(port, host, () => {

Loading…
Cancel
Save