mirror of
https://github.com/smogon/pokemon-showdown.git
synced 2026-03-21 17:25:10 -05:00
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:
parent
f35be5b51c
commit
ff6a030992
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user