Skip to content

Commit

Permalink
chore(ccfinder): list hostname and pathname for black ip
Browse files Browse the repository at this point in the history
  • Loading branch information
huangyoukun committed Aug 16, 2018
1 parent c5d2ff7 commit 8e0860f
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion bin/tsw/runtime/CCFinder.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,8 @@ this.check = function (req, res) {

maxArr.forEach((max, i) => {
blackIPListText += `<pre>[${max.StdX10}%]${max.ip} [${i + 1}/${max.count}]</pre>`;
blackIPListText += formatCacheList(max.list);

blackIPList.push(max.ip);
});

Expand Down Expand Up @@ -290,7 +292,8 @@ const findMaxIPOnce = function(ipCache) {
const max = {
num: 0,
count: 0,
ip: ''
ip: '',
list: []
};

Object.keys(ipCache).forEach(function (ip, i) {
Expand All @@ -300,6 +303,7 @@ const findMaxIPOnce = function(ipCache) {
if (num > max.num) {
max.num = num;
max.ip = ip;
max.list = ipCache[ip].list;
}
}
});
Expand Down Expand Up @@ -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 += `<pre>  ${num}${key}</pre>`;
});

return content;
};

0 comments on commit 8e0860f

Please sign in to comment.