
Security News
ECMAScript 2025 Finalized with Iterator Helpers, Set Methods, RegExp.escape, and More
ECMAScript 2025 introduces Iterator Helpers, Set methods, JSON modules, and more in its latest spec update approved by Ecma in June 2025.
ddos-firewall
Advanced tools
This package adds protection against ddos attacks by returning a very small page resource. Since it returns a very small html resource, it is not affected by the attack. Compatible with Express. DDOS firewall
This project is designed to help you prevent DDOS attacks. The logic of the project is to return a very small page resource to requests that do not meet the appropriate conditions. Attacks sent to an HTML source that is small in size and does not make database queries will largely not work.
LIVE DEMO (VERCEL) | LIVE DEMO SOURCE CODE | LIVE ATTACK TEST
setConfig
function later. Even though we use Turnstile Captcha, we perform many checks in the background. Turnstile is only added for additional precaution.cookie-parser
The library needs to be used.
This library was a middleware available with Express.js. You can install and use it as follows.
npm install ddos-firewall
const { checkReq, setConfig } = require('ddos-firewall')
app.use(checkReq)
const express = require('express');
const { createProxyMiddleware } = require('http-proxy-middleware');
const { checkReq, setConfig, getConfig } = require('ddos-firewall')
const cookieParser = require('cookie-parser');
const bodyParser = require('body-parser');
const app = express();
app.use(cookieParser());
app.use(bodyParser.json({ limit: '50mb' }));
app.use(bodyParser.urlencoded({ extended: true, limit: '50mb' }));
app.use(checkReq)
setConfig({
protect: true,
// turnstile_public_key: '<cloudflare-turnstile-site-key>',
// turnstile_private_key: '<cloudflare-turnstile-secret-key>',
// waf_private_key: 'zfc_ddos_waf',
session_active_time: 1000 * 60 * 60 * 24, // Mili seconds
skip_country: [],
skip_ip: []
})
app.use(createProxyMiddleware({ target: 'https://www.google.com', changeOrigin: true }));
var port = process.env.PORT || 3000
app.listen(port, () => {
console.log('Server is running on port ' + port)
});
In this example incoming requests are filtered and google.com is reflected for those that pass the protection. You can find this example in the test brach. you can add an additional server layer in between and filter the requests and then reflect the ip or a link.
setConfig
The following variables can be passed to the function
You can change all of the following variables at any time using the setConfig
function. By creating an api, you can manually activate it when an attack comes and manually stop it when the attack is over.
protect
Allows you to specify whether protection is active or not. If true, waf is activated. If false is sent, no one will receive waf.
turnstile_public_key
You must send the Site Key you received from Cloudflare Turnstile settings.
turnstile_private_key
You must send the Secret Key you received from Cloudflare Turnstile settings.
session_active_time
You must send the number of milliseconds in milliseconds how long a user's session will remain active after passing the captcha.
skip_country
It checks the country location of the ip address and the WAF screen does not come to the countries you send. You should send 2-character country codes like ["TR"] in array format. If you are not using cloudflare, it queries with a local library. It is recommended to use Cloudflare.
skip_ip
It does not display waf to ip addresses in the array.
No settings are required to use the library, but it is recommended to do the following to filter DDOS attacks to a large extent. (The = sign indicates that the value of that setting should be the value opposite the = sign.)
When you are under attack and you make these adjustments, you will largely prevent the attack. If you include this library, the attack will probably not work.
This library is completely open source and is constantly being updated. Please star this repo to keep these updates coming. Starring the repo will support us to improve it.
Distributed under the MIT License. See LICENSE for more information.
FAQs
This package adds protection against ddos attacks by returning a very small page resource. Since it returns a very small html resource, it is not affected by the attack. Compatible with Express. DDOS firewall
The npm package ddos-firewall receives a total of 0 weekly downloads. As such, ddos-firewall popularity was classified as not popular.
We found that ddos-firewall demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
ECMAScript 2025 introduces Iterator Helpers, Set methods, JSON modules, and more in its latest spec update approved by Ecma in June 2025.
Security News
A new Node.js homepage button linking to paid support for EOL versions has sparked a heated discussion among contributors and the wider community.
Research
North Korean threat actors linked to the Contagious Interview campaign return with 35 new malicious npm packages using a stealthy multi-stage malware loader.