mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Fix server crash if whitelist.txt is missing
This commit is contained in:
16
server.js
16
server.js
@ -32,11 +32,15 @@ const webp = require('webp-converter');
|
||||
const config = require(path.join(process.cwd(), './config.conf'));
|
||||
const server_port = process.env.SILLY_TAVERN_PORT || config.port;
|
||||
|
||||
let whitelistTxt = null;
|
||||
try {
|
||||
whitelistTxt = fs.readFileSync(path.join(process.cwd(), "./whitelist.txt"));
|
||||
} catch (e) {}
|
||||
const whitelist = whitelistTxt.toString().split("\n").filter(ip => ip) || config.whitelist;
|
||||
const whitelistPath = path.join(process.cwd(), "./whitelist.txt");
|
||||
let whitelist = config.whitelist;
|
||||
|
||||
if (fs.existsSync(whitelistPath)) {
|
||||
try {
|
||||
let whitelistTxt = fs.readFileSync(whitelistPath, 'utf-8');
|
||||
whitelist = whitelistTxt.split("\n").filter(ip => ip).map(ip => ip.trim());
|
||||
} catch (e) { }
|
||||
}
|
||||
|
||||
const whitelistMode = config.whitelistMode;
|
||||
const autorun = config.autorun;
|
||||
@ -2500,4 +2504,4 @@ function ensurePublicDirectoriesExist() {
|
||||
fs.mkdirSync(dir, { recursive: true });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user