class IPService (View source)

Constants

IPRANGEFLAG_BLACKLIST

Bit mask for blacklist ranges.

IPRANGEFLAG_WHITELIST

Bit mask for whitelist ranges.

IPRANGEFLAG_MANUAL

Bit mask for manually generated ranges.

IPRANGEFLAG_AUTOMATIC

Bit mask for automatically generated ranges.

IPRANGETYPE_BLACKLIST_MANUAL

IP range type: manually added to the blacklist.

IPRANGETYPE_BLACKLIST_AUTOMATIC

IP range type: automatically added to the blacklist.

IPRANGETYPE_WHITELIST_MANUAL

IP range type: manually added to the whitelist.

Properties

protected Repository $config
protected Connection $connection
protected Request $request

Methods

__construct(Repository $config, Connection $connection, Request $request)

No description

AddressInterface
getRequestIPAddress()

Get the IP address of the current request.

bool
isBlacklisted(AddressInterface $ip = null)

Check if an IP adress is blacklisted.

bool
isWhitelisted(AddressInterface $ip = null)

Check if an IP adress is blacklisted.

string
getErrorMessage()

Get the (localized) message telling the users that their IP address has been banned.

logFailedLogin(AddressInterface $ip = null, bool $ignoreConfig = false)

Add the current IP address to the list of IPs with failed login attempts.

bool
failedLoginsThresholdReached(AddressInterface $ip = null, bool $ignoreConfig = false)

Check if the current IP address has reached the failed login attempts threshold.

addToBlacklistForThresholdReached(AddressInterface $ip = null, bool $ignoreConfig = false)

Add an IP address to the list of IPs banned for too many failed login attempts.

createRange(RangeInterface $range, int $type, DateTime $expiration = null)

Add persist an IP address range type.

getRanges(int $type, bool $includeExpired = false)

Get the list of currently available ranges.

IPRange|null
getRangeByID(int $id)

Find already defined range given its record ID.

deleteRange(IPRange|int $range)

Delete a range record.

int|null
getRangeType(AddressInterface $ip)

Get the range type (if defined) of an IP adress.

getRequestIP() deprecated

No description

isBanned($ip = false) deprecated

No description

createIPBan($ip = false, $ignoreConfig = false) deprecated

No description

logSignupRequest($ignoreConfig = false) deprecated

No description

signupRequestThreshholdReached($ignoreConfig = false) deprecated

No description

signupRequestThresholdReached($ignoreConfig = false) deprecated

No description

Details

__construct(Repository $config, Connection $connection, Request $request)

No description

Parameters

Repository $config
Connection $connection
Request $request

AddressInterface getRequestIPAddress()

Get the IP address of the current request.

Return Value

AddressInterface

bool isBlacklisted(AddressInterface $ip = null)

Check if an IP adress is blacklisted.

Parameters

AddressInterface $ip

Return Value

bool

bool isWhitelisted(AddressInterface $ip = null)

Check if an IP adress is blacklisted.

Parameters

AddressInterface $ip

Return Value

bool

string getErrorMessage()

Get the (localized) message telling the users that their IP address has been banned.

Return Value

string

logFailedLogin(AddressInterface $ip = null, bool $ignoreConfig = false)

Add the current IP address to the list of IPs with failed login attempts.

Parameters

AddressInterface $ip

the IP address to log (if null, we'll use the current IP address)

bool $ignoreConfig

if set to true, we'll add the record even if the IP ban system is disabled in the configuration

bool failedLoginsThresholdReached(AddressInterface $ip = null, bool $ignoreConfig = false)

Check if the current IP address has reached the failed login attempts threshold.

Parameters

AddressInterface $ip

the IP address to log (if null, we'll use the current IP address)

bool $ignoreConfig

if set to true, we'll check the IP even if the IP ban system is disabled in the configuration

Return Value

bool

addToBlacklistForThresholdReached(AddressInterface $ip = null, bool $ignoreConfig = false)

Add an IP address to the list of IPs banned for too many failed login attempts.

Parameters

AddressInterface $ip

the IP to add to the blacklist (if null, we'll use the current IP address)

bool $ignoreConfig

if set to true, we'll add the IP address even if the IP ban system is disabled in the configuration

IPRange createRange(RangeInterface $range, int $type, DateTime $expiration = null)

Add persist an IP address range type.

Parameters

RangeInterface $range

the IP address range to persist

int $type

The range type (one of the IPService::IPRANGETYPE_... constants)

DateTime $expiration

The optional expiration of the range type

Return Value

IPRange

IPRange[]|Generator getRanges(int $type, bool $includeExpired = false)

Get the list of currently available ranges.

Parameters

int $type

(one of the IPService::IPRANGETYPE_... constants)

bool $includeExpired

Include expired records?

Return Value

IPRange[]|Generator

IPRange|null getRangeByID(int $id)

Find already defined range given its record ID.

Parameters

int $id

Return Value

IPRange|null

deleteRange(IPRange|int $range)

Delete a range record.

Parameters

IPRange|int $range

protected int|null getRangeType(AddressInterface $ip)

Get the range type (if defined) of an IP adress.

Parameters

AddressInterface $ip

Return Value

int|null

One of the IPRANGETYPE_... constants (or null if range is not defined).

getRequestIP() deprecated

deprecated Use \Core::make('ip')->getRequestIPAddress()

No description

isBanned($ip = false) deprecated

deprecated Use \Core::make('ip')->isBlacklisted()

No description

Parameters

$ip

createIPBan($ip = false, $ignoreConfig = false) deprecated

deprecated Use \Core::make('ip')->addToBlacklist()

No description

Parameters

$ip
$ignoreConfig

logSignupRequest($ignoreConfig = false) deprecated

deprecated Use \Core::make('ip')->logFailedLogin()

No description

Parameters

$ignoreConfig

signupRequestThreshholdReached($ignoreConfig = false) deprecated

deprecated use signupRequestThresholdReached (same syntax, just fixed the typo in the name)

No description

Parameters

$ignoreConfig

signupRequestThresholdReached($ignoreConfig = false) deprecated

deprecated Use \Core::make('ip')->failedLoginsThresholdReached()

No description

Parameters

$ignoreConfig