This commit is contained in:
Sefinek 2024-09-15 23:24:46 +02:00
parent 541a6a52ee
commit 3ec2d702b4
3 changed files with 9 additions and 6 deletions

View file

@ -122,7 +122,6 @@ const reportIP = async (event, country, hostname, endpoint, userAgent, cycleErro
const userIp = clientIp.getAddress(); const userIp = clientIp.getAddress();
if (!userIp) log('warn', `Your IP address is missing! Received: ${userIp}`); if (!userIp) log('warn', `Your IP address is missing! Received: ${userIp}`);
let reportedIPs = readReportedIPs();
let cycleImageSkippedCount = 0, cycleProcessedCount = 0, cycleReportedCount = 0, cycleSkippedCount = 0; let cycleImageSkippedCount = 0, cycleProcessedCount = 0, cycleReportedCount = 0, cycleSkippedCount = 0;
const cycleErrorCounts = { blocked: 0, noResponse: 0, otherErrors: 0 }; const cycleErrorCounts = { blocked: 0, noResponse: 0, otherErrors: 0 };
let imageRequestLogged = false; let imageRequestLogged = false;
@ -130,7 +129,13 @@ const reportIP = async (event, country, hostname, endpoint, userAgent, cycleErro
for (const event of blockedIPEvents) { for (const event of blockedIPEvents) {
cycleProcessedCount++; cycleProcessedCount++;
const ip = event.clientIP; const ip = event.clientIP;
if (ip === userIp) {
log('log', `The IP address ${ip} belongs to this machine. Ignoring...`);
cycleSkippedCount++;
continue;
}
const reportedIPs = readReportedIPs();
const { recentlyReported, timeDifference } = isIPReportedRecently(event.rayName, ip, reportedIPs); const { recentlyReported, timeDifference } = isIPReportedRecently(event.rayName, ip, reportedIPs);
if (recentlyReported) { if (recentlyReported) {
const hoursAgo = Math.floor(timeDifference / (1000 * 60 * 60)); const hoursAgo = Math.floor(timeDifference / (1000 * 60 * 60));
@ -156,8 +161,6 @@ const reportIP = async (event, country, hostname, endpoint, userAgent, cycleErro
if (wasReported) { if (wasReported) {
cycleReportedCount++; cycleReportedCount++;
await new Promise(resolve => setTimeout(resolve, SUCCESS_COOLDOWN_MS)); await new Promise(resolve => setTimeout(resolve, SUCCESS_COOLDOWN_MS));
} else {
reportedIPs = readReportedIPs();
} }
} }

4
package-lock.json generated
View file

@ -1,12 +1,12 @@
{ {
"name": "cf-waf-to-abuseipdb", "name": "cf-waf-to-abuseipdb",
"version": "1.1.3", "version": "1.1.4",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "cf-waf-to-abuseipdb", "name": "cf-waf-to-abuseipdb",
"version": "1.1.3", "version": "1.1.4",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"axios": "^1.7.7", "axios": "^1.7.7",

View file

@ -1,6 +1,6 @@
{ {
"name": "cf-waf-to-abuseipdb", "name": "cf-waf-to-abuseipdb",
"version": "1.1.3", "version": "1.1.4",
"description": "A Node.js project that enables automatic reporting of incidents detected by Cloudflare WAF to the AbuseIPDB database.", "description": "A Node.js project that enables automatic reporting of incidents detected by Cloudflare WAF to the AbuseIPDB database.",
"keywords": [ "keywords": [
"abuseipdb", "abuseipdb",