Update
This commit is contained in:
parent
301fa84032
commit
66a842846d
1 changed files with 14 additions and 1 deletions
15
index.js
15
index.js
|
|
@ -11,6 +11,7 @@ const log = require('./scripts/log.js');
|
||||||
|
|
||||||
const COOLDOWN_MS = 2000;
|
const COOLDOWN_MS = 2000;
|
||||||
const REPORTED_IP_COOLDOWN_MS = 7 * 60 * 60 * 1000;
|
const REPORTED_IP_COOLDOWN_MS = 7 * 60 * 60 * 1000;
|
||||||
|
const MAX_URL_LENGTH = 2000;
|
||||||
|
|
||||||
const fetchBlockedIPs = async () => {
|
const fetchBlockedIPs = async () => {
|
||||||
try {
|
try {
|
||||||
|
|
@ -39,6 +40,18 @@ const isIPReportedRecently = (ip, reportedIPs) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const reportIP = async (event, url, country, cycleErrorCounts) => {
|
const reportIP = async (event, url, country, cycleErrorCounts) => {
|
||||||
|
if (!url) {
|
||||||
|
logToCSV(new Date(), event.rayName, event.clientIP, url, 'Failed - URL too long', country);
|
||||||
|
log('fail', `Error while reporting: ${event.clientIP}; URL: ${url}; (Missing URL)`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (url.length > MAX_URL_LENGTH) {
|
||||||
|
logToCSV(new Date(), event.rayName, event.clientIP, url, 'Failed - URL too long', country);
|
||||||
|
log('fail', `Error 422 while reporting: ${event.clientIP}; URL: ${url}; (URL too long)`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await axios.post('https://api.abuseipdb.com/api/v2/report', {
|
await axios.post('https://api.abuseipdb.com/api/v2/report', {
|
||||||
ip: event.clientIP,
|
ip: event.clientIP,
|
||||||
|
|
@ -57,7 +70,7 @@ const reportIP = async (event, url, country, cycleErrorCounts) => {
|
||||||
log('warn', `Rate limited (429) while reporting: ${event.clientIP}; URL: ${url};`);
|
log('warn', `Rate limited (429) while reporting: ${event.clientIP}; URL: ${url};`);
|
||||||
cycleErrorCounts.blocked++;
|
cycleErrorCounts.blocked++;
|
||||||
} else {
|
} else {
|
||||||
log('error', `Error ${err.response.status} while reporting: ${event.clientIP}; URL: ${url}; Message: ${err.response.data}`);
|
log('fail', `Error ${err.response.status} while reporting: ${event.clientIP}; URL: ${url}; (${err.response.data})`);
|
||||||
cycleErrorCounts.otherErrors++;
|
cycleErrorCounts.otherErrors++;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue