|
|
|
@ -3,6 +3,8 @@
|
|
|
|
|
|
|
|
|
|
var async = require('async');
|
|
|
|
|
var request = require('request');
|
|
|
|
|
var LRU = require('lru-cache');
|
|
|
|
|
var checksum = require('checksum');
|
|
|
|
|
|
|
|
|
|
var db = require('../database');
|
|
|
|
|
var meta = require('../meta');
|
|
|
|
@ -12,6 +14,11 @@ var groups = require('../groups');
|
|
|
|
|
var translator = require('../../public/src/modules/translator');
|
|
|
|
|
var utils = require('../../public/src/utils');
|
|
|
|
|
|
|
|
|
|
var sfsCache = LRU({
|
|
|
|
|
max: 500,
|
|
|
|
|
maxAge: 1000*60*60*24 // one day
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
module.exports = function(User) {
|
|
|
|
|
|
|
|
|
@ -163,6 +170,17 @@ module.exports = function(User) {
|
|
|
|
|
return next(null, user);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var sum = checksum(user.ip+user.email+user.username);
|
|
|
|
|
if (sfsCache.has(sum)) {
|
|
|
|
|
var cached = sfsCache.get(sum);
|
|
|
|
|
user.spamData = cached;
|
|
|
|
|
user.usernameSpam = cached.username.frequency > 0 || cached.username.appears > 0;
|
|
|
|
|
user.emailSpam = cached.email.frequency > 0 || cached.email.appears > 0;
|
|
|
|
|
user.ipSpam = cached.ip.frequency > 0 || cached.ip.appears > 0;
|
|
|
|
|
|
|
|
|
|
return next(null, user);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// temporary: see http://www.stopforumspam.com/forum/viewtopic.php?id=6392
|
|
|
|
|
user.ip = user.ip.replace('::ffff:', '');
|
|
|
|
|
|
|
|
|
@ -179,6 +197,7 @@ module.exports = function(User) {
|
|
|
|
|
return next(null, user);
|
|
|
|
|
}
|
|
|
|
|
if (response.statusCode === 200) {
|
|
|
|
|
sfsCache.set(sum, body);
|
|
|
|
|
user.spamData = body;
|
|
|
|
|
user.usernameSpam = body.username.frequency > 0 || body.username.appears > 0;
|
|
|
|
|
user.emailSpam = body.email.frequency > 0 || body.email.appears > 0;
|
|
|
|
|