Add a --no-security flag (#7648)

* Add a --no-security flag

* Handle port detection better

* Update server/index.ts

Co-authored-by: Guangcong Luo <guangcongluo@gmail.com>

Co-authored-by: Guangcong Luo <guangcongluo@gmail.com>
This commit is contained in:
Mia 2020-12-24 12:11:11 -06:00 committed by GitHub
parent f35be5b51c
commit ff6a030992
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 3 deletions

View File

@ -86,8 +86,7 @@ if (!process.argv[2] || /^[0-9]+$/.test(process.argv[2])) {
case 'start':
{
process.argv.splice(2, 1);
if (process.argv[2] === '--skip-build') {
process.argv.splice(2, 1);
if (process.argv.includes('--skip-build')) {
built = true;
}
if (!built) build();

View File

@ -15,6 +15,10 @@ export type ConfigType = typeof defaults & {
greatergroupscache: {[combo: string]: GroupSymbol},
[k: string]: any,
};
/** Map<process flag, config settings for it to turn on> */
const FLAG_PRESETS = new Map([
['--no-security', ['nothrottle', 'noguestsecurity', 'noipchecks']],
]);
const CONFIG_PATH = require.resolve('../config/config');
@ -33,6 +37,12 @@ export function load(invalidate = false) {
}
}
for (const [preset, values] of FLAG_PRESETS) {
if (process.argv.includes(preset)) {
for (const value of values) config[value] = true;
}
}
cacheGroupData(config);
return config;
}

View File

@ -163,7 +163,12 @@ if (require.main === module) {
// in the case of app.js being imported as a module (e.g. unit tests),
// postpone launching until app.listen() is called.
let port;
if (process.argv[2]) port = parseInt(process.argv[2]);
for (const arg of process.argv) {
if (/^[0-9]+$/.test(arg)) {
port = parseInt(arg);
break;
}
}
Sockets.listen(port);
}