ozziest/overdose

Overdose is a guardian which is protects your sistem from request flood.

1.0.0 2015-02-06 12:38 UTC

This package is not auto-updated.

Last update: 2024-04-13 14:39:50 UTC


README

Overdose is a guardian which is protects your system from request floods.

Installation

To install through composer, simply put the following in your composer.json file:

{
    "require": {
        "ozziest/overdose": "1.*"
    }
}
$ composer install

Usage

This library depended to desarrolla2/cache. You must create cache object and sending to Overdose for usage.

// Creating new cache object
use Desarrolla2\Cache\Cache;
use Desarrolla2\Cache\Adapter\File;

$cacheDir = '/tmp';
$adapter = new File($cacheDir);
$adapter->setOption('ttl', 3600);
$cache = new Cache($adapter);

// Creating overdose
$overdose = new Ozziest\Overdose\Overdose($cache);
try {
    $overdose->isSecure();
} catch (Ozziest\Overdose\OverdoseException $e) {
    exit($e->getMessage());
}

Configuration

You can change runtime options for security.

$overdose = new Ozziest\Overdose\Overdose($cache);
$overdose->set([
                'acceptable' => 5,
                'safe'       => 10,
                'max'        => 3,
                'recreation' => 60
            ]) 
         ->isSecure();
  • acceptable: Acceptable sec for every request interval. If request interval smaller than acceptable, that request is a overdose.
  • safe: Safety sec. for every request interval. If request interval greater than safe, overdose count will reduce.
  • max: Maximum overdose count for recreation time activation.
  • recreation: Recreation time. (sec)