Giter VIP home page Giter VIP logo

node-ddos's Introduction

Configurable Denial-Of-Service prevention for http services

Build Status

example

var Ddos = require('ddos')
var ddos = new Ddos;
var express = require('express')
var app = express();
app.use(ddos.express)

How does this ddos prevention module work?

Every request marks the internal table. This is how an entry in the table managed by this module looks

{ host : <ip address>, count: 1, expiry: 1 }

When a second request is made

{ host : <ip address>, count: 2, expiry: 1 }

and the third

{ host : <ip address>, count: 3, expiry: 1 }

and so on. If the count exceeds the configurable burst amount, then the expiry goes up by twice the previous expiry, 1, 2, 4, 8, 16, etc.

When count exceeds the limit, then the request is denied, otherwise, the request is permitted.

Every time the internal table is checked, the expiration goes down by the time elapsed.

The only way for a user who has denied requests to continue is for them to let the expiration time pass, and when expiration hits 0, the entry is deleted from the table, and new requests are allowed like normal.

Processing and Memory Usage by this module

There is only ONE table, and within it only one small entry per IP, and that entry is transient and will be deleted within normal parameters. The table itself is combed over at the configurable checkinterval in seconds.

Yes, this will not deal with distributed denial-of-service attacks

But it will deal with simple DOS ones, but the concept is associated with DDOS whereas DOS is about the classic operating system from the 90's.

Let's review Configuration

Let's go over the configuration options to help illustrate how this module works. All of the configurations default to the following:

_params.maxcount = 30;
_params.burst = 5;
_params.limit = _params.burst * 4;  
_params.maxexpiry = 120;
_params.checkinterval = 1;
_params.errormessage = 'Error';

params.limit

limit is the number of maximum counts allowed. If the count exceeds the limit, then the request is denied. Recommended limit is to use a multiple of the number of bursts.

params.burst

Burst is the number or amount of allowable burst requests before the client starts being penalized. When the client is penalized, the expiration is increased by twice the previous expiration.

params.maxexpiry

maxexpiry is the seconds of maximum amount of expiration time. In order for the user to use whatever service you are providing again, they have to wait through the expiration time.

params.checkinterval

checkinterval is the seconds between updating the internal table.

params.errormessage

When a request is denied, the user receives a 500 and the error message.

node-ddos's People

Contributors

rook2pawn avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.