From 8e0860f57f699bd57ed3e47a4977c2a6445a9402 Mon Sep 17 00:00:00 2001 From: youkunhuang Date: Thu, 16 Aug 2018 11:59:48 +0800 Subject: [PATCH] chore(ccfinder): list hostname and pathname for black ip --- bin/tsw/runtime/CCFinder.js | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/bin/tsw/runtime/CCFinder.js b/bin/tsw/runtime/CCFinder.js index 0b142371..2ba00d87 100644 --- a/bin/tsw/runtime/CCFinder.js +++ b/bin/tsw/runtime/CCFinder.js @@ -218,6 +218,8 @@ this.check = function (req, res) { maxArr.forEach((max, i) => { blackIPListText += `
[${max.StdX10}%]${max.ip} [${i + 1}/${max.count}]
`; + blackIPListText += formatCacheList(max.list); + blackIPList.push(max.ip); }); @@ -290,7 +292,8 @@ const findMaxIPOnce = function(ipCache) { const max = { num: 0, count: 0, - ip: '' + ip: '', + list: [] }; Object.keys(ipCache).forEach(function (ip, i) { @@ -300,6 +303,7 @@ const findMaxIPOnce = function(ipCache) { if (num > max.num) { max.num = num; max.ip = ip; + max.list = ipCache[ip].list; } } }); @@ -337,3 +341,21 @@ const formatIP = function(ipCache) { return content; }; + + +const formatCacheList = function(list) { + const map = {}; + let content = ''; + + list.forEach((info, i) => { + const key = encodeURI(info.hostname) + encodeURI(info.pathname); + map[key] = ~~map[key] + 1; + }); + + Object.keys(map).forEach((key, i) => { + const num = (map[key] + '--------').slice(0, 8); + content += `
  ${num}${key}
`; + }); + + return content; +};