Documentation

TrafficLimiter extends AbstractPersistence
in package

TrafficLimiter

Handles traffic limiting, so no user does more than one call per 10 seconds.

Table of Contents

Properties

$_store  : AbstractData
data storage to use to persist something
$_creators  : string|null
listed IPs are the only ones allowed to create, defaults to null
$_exempted  : string|null
listed IPs are exempted from limits, defaults to null
$_ipKey  : string
key to fetch IP address
$_limit  : int
time limit in seconds, defaults to 10s

Methods

canPass()  : true
make sure the IP address is allowed to perfom a request
getHash()  : string
get a HMAC of the current visitors IP address
setConfiguration()  : mixed
set configuration options of the traffic limiter
setCreators()  : mixed
set a list of creator IP(-ranges) as string
setExempted()  : mixed
set a list of exempted IP(-ranges) as string
setLimit()  : mixed
set the time limit in seconds
setStore()  : mixed
set the path
matchIp()  : bool
validate $_ipKey against configured ipranges. If matched we will ignore the ip

Properties

$_creators

listed IPs are the only ones allowed to create, defaults to null

private static string|null $_creators = null
Tags
access

private

static

$_exempted

listed IPs are exempted from limits, defaults to null

private static string|null $_exempted = null
Tags
access

private

static

$_ipKey

key to fetch IP address

private static string $_ipKey = 'REMOTE_ADDR'
Tags
access

private

static

$_limit

time limit in seconds, defaults to 10s

private static int $_limit = 10
Tags
access

private

static

Methods

canPass()

make sure the IP address is allowed to perfom a request

public static canPass() : true
Tags
access

public

static
throws
Exception
Return values
true

getHash()

get a HMAC of the current visitors IP address

public static getHash([string $algo = 'sha512' ]) : string
Parameters
$algo : string = 'sha512'
Tags
access

public

static
Return values
string

setCreators()

set a list of creator IP(-ranges) as string

public static setCreators(string $creators) : mixed
Parameters
$creators : string
Tags
access

public

static

setExempted()

set a list of exempted IP(-ranges) as string

public static setExempted(string $exempted) : mixed
Parameters
$exempted : string
Tags
access

public

static

setLimit()

set the time limit in seconds

public static setLimit(int $limit) : mixed
Parameters
$limit : int
Tags
access

public

static

matchIp()

validate $_ipKey against configured ipranges. If matched we will ignore the ip

private static matchIp([string $ipRange = null ]) : bool
Parameters
$ipRange : string = null
Tags
access

private

static
Return values
bool

        
On this page

Search results