Control whitelist mode with console flag

This commit is contained in:
Cohee
2024-04-12 01:33:39 +03:00
parent a3da248e3c
commit 58359c9682
2 changed files with 10 additions and 4 deletions

View File

@ -8,7 +8,6 @@ const { color, getConfigValue } = require('../util');
const whitelistPath = path.join(process.cwd(), './whitelist.txt');
let whitelist = getConfigValue('whitelist', []);
let knownIPs = new Set();
const whitelistMode = getConfigValue('whitelistMode', true);
if (fs.existsSync(whitelistPath)) {
try {
@ -21,10 +20,11 @@ if (fs.existsSync(whitelistPath)) {
/**
* Returns a middleware function that checks if the client IP is in the whitelist.
* @param {boolean} whitelistMode If whitelist mode is enabled via config or command line
* @param {boolean} listen If listen mode is enabled via config or command line
* @returns {import('express').RequestHandler} The middleware function
*/
function whitelistMiddleware(listen) {
function whitelistMiddleware(whitelistMode, listen) {
return function (req, res, next) {
const clientIp = getIpFromRequest(req);