have to check on config for proxycheck

This commit is contained in:
HF 2020-04-30 00:27:58 +02:00
parent 5808d8a595
commit 77375eca64
2 changed files with 15 additions and 1 deletions

View File

@ -8,6 +8,9 @@ import webSockets from '../socket/websockets';
import { CHAT_CHANNELS } from './constants';
import { cheapDetector } from './isProxy';
import {
USE_PROXYCHECK,
} from './config';
class ChatProvider {
@ -106,7 +109,7 @@ class ChatProvider {
}
}
if (user.ip && await cheapDetector(user.ip)) {
if (USE_PROXYCHECK && user.ip && await cheapDetector(user.ip)) {
logger.info(
`${name} / ${user.ip} tried to send chat message with proxy`,
);

View File

@ -7,6 +7,10 @@
import type { Request, Response } from 'express';
import getMe from '../../core/me';
import {
USE_PROXYCHECK,
} from '../../core/config';
import { cheapDetector } from '../../core/isProxy';
export default async (req: Request, res: Response) => {
@ -14,6 +18,13 @@ export default async (req: Request, res: Response) => {
const userdata = await getMe(user);
user.updateLogInTimestamp();
const { trueIp: ip } = req;
if (USE_PROXYCHECK && ip !== '0.0.0.1') {
// pre-fire cheap Detector to give it time to get a real result
// once api_pixel needs it
cheapDetector(ip);
}
// https://stackoverflow.com/questions/49547/how-to-control-web-page-caching-across-all-browsers
res.set({
'Cache-Control': 'no-cache, no-store, must-revalidate',