diff --git a/.gitignore b/.gitignore index 0643702..d34d121 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ node_modules tmp -config.js \ No newline at end of file +config.js +whitelist.txt \ No newline at end of file diff --git a/README.md b/README.md index db34b0a..f5946dc 100644 --- a/README.md +++ b/README.md @@ -26,14 +26,17 @@ Also, check this out: [sefinek/Cloudflare-WAF-To-AbuseIPDB](https://github.com/s ## ✅ Features 1. **Easy Configuration** – The [`config.js`](config.default.js) file allows for quick and simple configuration. 2. **Simple Installer** – Enables fast and seamless integration deployment. -3. **Bulk Reporting Support** – If the script encounters a rate limit, it will start buffering collected IPs and send a bulk report. -4. **Self-IP Protection (IPv4 & IPv6)** – The script will never report IP addresses belonging to you or your server, even if you're using a dynamic IP address. -5. **Local IP Filtering** – Local IP addresses will never be reported. -6. **Discord Webhooks Integration**: +3. **Self-IP Protection (IPv4 & IPv6)** – The script will never report IP addresses belonging to you or your server, even if you're using a dynamic IP address. +4. **IP Filtering** – Local and special-purpose IP addresses will never be reported. +5. **IP Whitelist** – Maintain a `whitelist.txt` file with IP addresses that should never be reported (e.g., your home IP when running on a VPS). +6. **UDP Traffic Filtering** – UDP traffic is automatically skipped in accordance with [AbuseIPDB's policy](https://github.com/sefinek/UFW-AbuseIPDB-Reporter/discussions/2). +7. **Report Cooldown** – Prevents duplicate reports of the same IP within a configurable time window (default: 12 hours). +8. **Bulk Reporting Support** – If the script encounters a rate limit, it will start buffering collected IPs and send a bulk report. +9. **Discord Webhooks Integration**: - Critical notifications - Script error alerts - Daily summaries of reported IPs -7. **Automatic Updates** – The script regularly fetches and applies the latest updates. You can disable this feature if you'd prefer. +10. **Automatic Updates** – The script regularly fetches and applies the latest updates. You can disable this feature if you'd prefer. ## 📥 Installation (Ubuntu & Debian) diff --git a/index.js b/index.js index 828ffa4..ee5ba5a 100644 --- a/index.js +++ b/index.js @@ -13,6 +13,7 @@ const ABUSE_STATE = require('./scripts/services/state.js'); const { refreshServerIPs, getServerIPs } = require('./scripts/services/ipFetcher.js'); const { repoSlug, repoUrl } = require('./scripts/repo.js'); const isSpecialPurposeIP = require('./scripts/isSpecialPurposeIP.js'); +const { initWhitelist, isWhitelisted } = require('./scripts/services/whitelist.js'); const logger = require('./scripts/logger.js'); const { UFW_LOG_FILE, SERVER_ID, EXTENDED_LOGS, AUTO_UPDATE_ENABLED, AUTO_UPDATE_SCHEDULE, DISCORD_WEBHOOK_ENABLED, DISCORD_WEBHOOK_URL } = config.MAIN; @@ -121,8 +122,14 @@ const processLogLine = async (line, test = false) => { return; } - if (isSpecialPurposeIP(srcIp)) { - if (EXTENDED_LOGS) logger.info(`Ignoring local IP address: PROTO=${proto?.toLowerCase()} SRC=${srcIp} DPT=${dpt} ID=${data.id}`); + if (isWhitelisted(srcIp)) { + if (EXTENDED_LOGS) logger.info(`Ignoring whitelisted IP address: PROTO=${proto?.toLowerCase()} SRC=${srcIp} DPT=${dpt} ID=${data.id}`); + return; + } + + const specialIP = isSpecialPurposeIP(srcIp); + if (specialIP.is) { + if (EXTENDED_LOGS) logger.info(`Ignoring ${specialIP.range} IP address: PROTO=${proto?.toLowerCase()} SRC=${srcIp} DPT=${dpt} ID=${data.id}`); return; } @@ -174,6 +181,9 @@ const processLogLine = async (line, test = false) => { // Fetch IPs await refreshServerIPs(); + // Whitelist + initWhitelist(); + // Load cache await loadReportedIPs(); diff --git a/scripts b/scripts index b84eaa0..046e9dd 160000 --- a/scripts +++ b/scripts @@ -1 +1 @@ -Subproject commit b84eaa02ce4772f6e72937a4984d83a9266e9d49 +Subproject commit 046e9dd27299cdb54069564875f9538a465b9fdd