From 81e8f2c5f24bb350e06b1b12f34a82a26ec38be8 Mon Sep 17 00:00:00 2001 From: Sefinek Date: Thu, 19 Dec 2024 15:55:58 +0100 Subject: [PATCH] Update README.md etc --- README.md | 53 ++++++++++++++++++++------------------------- ecosystem.config.js | 27 ++++++++++++++++++++++- eslint.config.mjs | 48 ++++++++++++++++++++-------------------- 3 files changed, 73 insertions(+), 55 deletions(-) diff --git a/README.md b/README.md index 62987a7..14a7106 100644 --- a/README.md +++ b/README.md @@ -10,29 +10,27 @@ See also this: [sefinek/Cloudflare-WAF-To-AbuseIPDB](https://github.com/sefinek/ ## πŸ“‹ Requirements -- Node.js + npm -- Git - - -## πŸ§ͺ Tested operating systems -- **Ubuntu Server:** 20.04 & 22.04 - -*If the distribution you're using to run this tool isn't listed here but works correctly, please create a new [Issue](https://github.com/sefinek/UFW-AbuseIPDB-Reporter/issues) or submit a [Pull request](https://github.com/sefinek/UFW-AbuseIPDB-Reporter/pulls).* +- [Node.js + npm](https://nodejs.org) +- [Git](https://git-scm.com) ## πŸ“₯ Installation -### curl ```bash -bash <(curl -s https://raw.githubusercontent.com/sefinek/UFW-AbuseIPDB-Reporter/main/install.sh) +cd ~ +git clone https://github.com/sefinek/UFW-AbuseIPDB-Reporter.git +cd UFW-AbuseIPDB-Reporter +npm install +cp default.config.js config.js +sudo chmod 644 /var/log/ufw.log +node . +^C +npm uninstall corepack -g +npm install pm2 -g +pm2 startup +[Wklej komendΔ™ wygenerowana przez pm2 startup] +pm2 save ``` -### wget -```bash -bash <(wget -qO- https://raw.githubusercontent.com/sefinek/UFW-AbuseIPDB-Reporter/main/install.sh) -``` - -The installation script will automatically download and configure the tool on your machine. During the installation process, you will be prompted to provide an [AbuseIPDB API token](https://www.abuseipdb.com/account/api). - ## πŸ–₯️ Usage After successful installation, the script will run continuously in the background, monitoring UFW logs and automatically reporting malicious IP addresses. @@ -41,25 +39,20 @@ The tool requires no additional user action after installation. However, it's wo Servers open to the world are constantly scanned by bots, usually looking for vulnerabilities or other security gaps. So don't be surprised if the next day, the number of reports to AbuseIPDB exceeds a thousand. -### πŸ” Checking service status +### πŸ” Checking logs ```bash -sudo systemctl status abuseipdb-ufw.service -``` - -To see the current logs generated by the process, use the command: -```bash -journalctl -u abuseipdb-ufw.service -f +pm2 logs ufw-abuseipdb ``` ### πŸ“„ Example report ``` -Blocked by UFW (TCP on 80) -Source port: 28586 -TTL: 116 -Packet length: 48 -TOS: 0x08 +Blocked by UFW on vserver1 [80/tcp] +Source port: 23639 +TTL: 247 +Packet length: 40 +TOS: 0x00 -This report (for 46.174.191.31) was generated by: +This report (for 45.156.129.52) was generated by: https://github.com/sefinek/UFW-AbuseIPDB-Reporter ``` diff --git a/ecosystem.config.js b/ecosystem.config.js index a099545..d29f7f6 100644 --- a/ecosystem.config.js +++ b/ecosystem.config.js @@ -1 +1,26 @@ -module.exports = {}; \ No newline at end of file +module.exports = { + apps: [{ + name: 'ufw-abuseipdb', + script: './index.js', + + // Logging configuration + log_date_format: 'HH:mm:ss.SSS DD.MM.YYYY', + merge_logs: true, + log_file: '/var/log/ufw-abuseipdb/combined.log', + out_file: '/var/log/ufw-abuseipdb/out.log', + error_file: '/var/log/ufw-abuseipdb/error.log', + + // Application restart policy settings + wait_ready: true, + autorestart: true, + max_restarts: 10, + min_uptime: 20000, + restart_delay: 5000, + exp_backoff_restart_delay: 3000, + + // Environment variables configuration + env: { + NODE_ENV: 'production', + }, + }], +}; \ No newline at end of file diff --git a/eslint.config.mjs b/eslint.config.mjs index 1b986f0..ae1f169 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -12,42 +12,42 @@ export default [ }, }, rules: { - 'arrow-spacing': [1, { before: true, after: true }], - 'comma-dangle': [1, { arrays: 'always-multiline', objects: 'always-multiline' }], - 'comma-spacing': 1, + 'arrow-spacing': ['warn', { before: true, after: true }], + 'comma-dangle': ['warn', { arrays: 'always-multiline', objects: 'always-multiline' }], + 'comma-spacing': 'warn', 'comma-style': 'error', 'curly': ['error', 'multi-line', 'consistent'], 'dot-location': ['error', 'property'], 'handle-callback-err': 'off', - 'indent': [1, 'tab'], - 'keyword-spacing': 1, + 'indent': ['warn', 'tab'], + 'keyword-spacing': 'warn', 'max-nested-callbacks': ['error', { max: 4 }], 'max-statements-per-line': ['error', { max: 2 }], 'no-console': 'off', - 'no-empty': 1, - 'no-empty-function': 1, + 'no-empty': 'warn', + 'no-empty-function': 'warn', 'no-floating-decimal': 'error', - 'no-lonely-if': 1, - 'no-multi-spaces': 1, - 'no-multiple-empty-lines': [1, { max: 3, maxEOF: 1, maxBOF: 0 }], + 'no-lonely-if': 'warn', + 'no-multi-spaces': 'warn', + 'no-multiple-empty-lines': ['warn', { max: 3, maxEOF: 1, maxBOF: 0 }], 'no-shadow': ['error', { allow: ['err', 'resolve', 'reject'] }], - 'no-trailing-spaces': 1, - 'no-unreachable': 1, - 'no-unused-vars': 1, + 'no-trailing-spaces': 'warn', + 'no-unreachable': 'warn', + 'no-unused-vars': 'warn', 'no-use-before-define': ['error', { functions: false, classes: true }], 'no-var': 'error', - 'object-curly-spacing': [1, 'always'], + 'object-curly-spacing': ['warn', 'always'], 'prefer-const': 'error', - 'quotes': [1, 'single'], - 'semi': [1, 'always'], - 'sort-vars': 1, - 'space-before-blocks': 1, - 'space-before-function-paren': [1, { anonymous: 'never', named: 'never', asyncArrow: 'always' }], - 'space-in-parens': 1, - 'space-infix-ops': 1, - 'space-unary-ops': 1, - 'spaced-comment': 1, - 'wrap-regex': 1, + 'quotes': ['warn', 'single'], + 'semi': ['warn', 'always'], + 'sort-vars': 'warn', + 'space-before-blocks': 'warn', + 'space-before-function-paren': ['warn', { anonymous: 'never', named: 'never', asyncArrow: 'always' }], + 'space-in-parens': 'warn', + 'space-infix-ops': 'warn', + 'space-unary-ops': 'warn', + 'spaced-comment': 'warn', + 'wrap-regex': 'warn', 'yoda': 'error', }, ignores: ['node_modules', '*min.js', '*bundle*', 'build/*', 'dist/*'],