Node.js based forum software built for the modern web
fixes #6596
Julian Lam68c9c8c5d985
diff --git a/src/upgrades/1.10.0/hash_recent_ip_addresses.js b/src/upgrades/1.10.0/hash_recent_ip_addresses.jsnew file mode 100644index 0000000000..9dbaea885c--- /dev/null+++ b/src/upgrades/1.10.0/hash_recent_ip_addresses.js@@ -0,0 +1,35 @@+'use strict';++var db = require('../../database');+var batch = require('../../batch');++var async = require('async');+var crypto = require('crypto');+var nconf = require('nconf');++module.exports = {+ name: 'Hash all IP addresses stored in Recent IPs zset',+ timestamp: Date.UTC(2017, 5, 22),+ method: function (callback) {+ var hashed = /[a-f0-9]{32}/;+ let hash;++ batch.processSortedSet('ip:recent', function (ips, next) {+ async.each(ips, function (set, next) {+ // Short circuit if already processed+ if (hashed.test(set.value)) {+ console.log('done already', set);+ return setImmediate(next);+ }++ hash = crypto.createHash('sha1').update(set.value + nconf.get('secret')).digest('hex');+ console.log('processing');++ async.series([+ async.apply(db.sortedSetAdd, 'ip:recent', set.score, hash),+ async.apply(db.sortedSetRemove, 'ip:recent', set.value),+ ], next);+ }, next);+ }, { withScores: 1 }, callback);+ },+};