fix(middleware): skip New connection message and `access.log` writes for localhost

bfc609c2a8fa0743e72d49278e72ec48cbc416d0

KevinSun <paver.mails+github@gmail.com>

Signed
2 files changed, +4 -3Ignore whitespace
server.js+1 -1
@@ -344,7 +344,7 @@ app.use(CORS);
344344if (listen && basicAuthMode) app.use(basicAuthMiddleware);
345345
346346app.use(whitelistMiddleware(enableWhitelist));
347347app.use(accessLoggerMiddleware(listen));
348348
349349if (enableCorsProxy) {
350350 app.use(bodyParser.json({
src/middleware/accessLogger.js+3 -2
@@ -28,14 +28,15 @@ export function migrateAccessLog() {
2828
2929/**
3030 * Creates middleware for logging access and new connections
31+ * @param {boolean} listen If listen mode is enabled via config or command line
3132 * @returns {import('express').RequestHandler}
3233 */
3334export default function accessLoggerMiddleware(listen) {
3435 return function (req, res, next) {
3536 const clientIp = getRealIpFromHeader(req);
3637 const userAgent = req.headers['user-agent'];
3738
3839 if (listen && !knownIPs.has(clientIp)) {
3940 // Log new connection
4041 console.info(color.yellow(`New connection from ${clientIp}; User Agent: ${userAgent}\n`));
4142 knownIPs.add(clientIp);