PHPackages                             karelwintersky/arris.toolkit.firewall - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Security](/categories/security)
4. /
5. karelwintersky/arris.toolkit.firewall

ActiveLibrary[Security](/categories/security)

karelwintersky/arris.toolkit.firewall
=====================================

Library providing IP filtering features

1.0.0(1y ago)0266MITPHPPHP 8.\*

Since Feb 8Pushed 1y ago1 watchersCompare

[ Source](https://github.com/ArrisFramework/Arris.Toolkit.Firewall)[ Packagist](https://packagist.org/packages/karelwintersky/arris.toolkit.firewall)[ RSS](/packages/karelwintersky-arristoolkitfirewall/feed)WikiDiscussions main Synced 3w ago

READMEChangelog (3)Dependencies (1)Versions (4)Used By (0)

Arris.Toolkit.Firewall
======================

[](#arristoolkitfirewall)

Readme in Russian - [README.RU.md](README.RU.md)

Library providing IP filtering features

TypeSyntaxDetailsIPV4`192.168.0.1`Range`192.168.0.0-192.168.1.60`Includes all IPs from `192.168.0.0` to `192.168.0.255`
and from `192.168.1.0` to `198.168.1.60`Wild card`192.168.0.*`IPs starting with `192.168.0`
Same as IP Range `192.168.0.0-192.168.0.255`CIDR Mask`192.168.0.0/24`IPs starting with `192.168.0`
Same as `192.168.0.0-192.168.0.255` and `192.168.0.*`
and `192.168.0.0/255.255.255.0`*NB!* Range like `192.168.0.0/255.255.255.0` with subnet mask not supported (as deprecated)!

Basic usage
-----------

[](#basic-usage)

Use composer:

```
composer require karelwintersky/arris.toolkit.firewall

```

```
use Arris\Toolkit\FireWall;

$whiteList = [
    '127.0.0.1',
    '192.168.0.*',
];

$blackList = [
    '192.168.0.50',
];

$firewall = new FireWall(
    defaultState: false,
    deferred_range_sorting: true
);

$connAllowed = $firewall
    ->addWhiteList($whiteList)
    ->addBlackList($blackList)
    ->validate('195.88.195.146')
    ->isAllowed()
;

if (!$connAllowed) {
    http_response_code(403); // Forbidden
    exit();
}
```

#### Constructor

[](#constructor)

```
$firewall = new FireWall(
    defaultState: false,
    deferred_range_sorting: true
);
```

- `defaultState` - rule for range `*.*.*.*`. Default **false**, i.e. **FORBIDDEN**. Allowed options:
    - `null` (equal to false)
    - `true|false`
    - `FireWallState::FORBIDDEN` или `FireWallState::ALLOWED`
- `deferred_range_sorting` - use lazy range sorting:
    - `true`: at validate() call; use it if you test only one IP at once, most cases)
    - `false`: at addAnyList() call; use it if you test a lot if IPs with one ruleset

#### Add ranges

[](#add-ranges)

- `addWhiteList()` - add range to White list (Allowed), alias of `addAllowed()`
- `addBlackList()` - add range to Black List (Forbidden), alias of `addDenied()`

Argument is string or array of strings

- `192.168.0.1` - alone IP
- `192.168.0.0-192.168.1.60` - range
- `192.168.0.*` - wildcard range (allowed range `*`, that is equal to `*.*.*.*`)
- `192.168.0.0/24` - CIDR range

Range `192.168.0.0/255.255.255.0` not supported now.

- `addRange(range, type)` - type is FireWallState enum value

Сomplex and redundant example
-----------------------------

[](#сomplex-and-redundant-example)

```
$firewall = new FireWall();
$i = $firewall
    ->addBlackList('192.168.0.0/16')            // 192.168.0.0 - 192.168.255.255
    ->addWhiteList('192.168.0.0/24')            // + 0-255
    ->addBlackList('192.168.0.10-192.168.0.80') // - 10-80
    ->addBlackList('192.168.0.100-192.168.0.121') // - 100-121
    ->addWhiteList('192.168.0.42')  // + 42
    ->addWhiteList('192.168.0.120') // + 120
    ->addBlackList('192.168.0.5')   // - 5

$equals = [
    '192.168.0.0'   =>  true,
    '192.168.0.1'   =>  true,
    '192.168.0.10'  =>  false,
    '192.168.0.42'  =>  true,
    '192.168.0.99'  =>  true,
    '192.168.0.100' =>  false,
    '192.168.0.5'   =>  false,
    '192.168.0.200' =>  true,
    '192.168.0.70'  =>  false
];
```

Nuances
-------

[](#nuances)

- when ranges overlap, the one with the lower power is "stronger"
- when ranges of equal power overlap, the result is not defined (most likely, the one that was declared earlier will be used)

How does it work?
-----------------

[](#how-does-it-work)

- We set IP ranges (white and black)
- Whether the full range (`*.*.*.*`) belongs to the black/white list depends on the settings
- Range powers are calculated
- Ranges are sorted by power
- The shortest range is found that includes the tested IP
- The type of this range is the state for the IP - ALLOWED or FORBIDDEN

License
-------

[](#license)

Firewall is licensed under the [MIT license](LICENSE).

###  Health Score

30

—

LowBetter than 62% of packages

Maintenance49

Moderate activity, may be stable

Popularity15

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity40

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~64 days

Total

3

Last Release

375d ago

Major Versions

0.99.99 → 1.0.02025-06-16

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/2164874?v=4)[Karel Wintersky](/maintainers/KarelWintersky)[@KarelWintersky](https://github.com/KarelWintersky)

---

Top Contributors

[![KarelWintersky](https://avatars.githubusercontent.com/u/2164874?v=4)](https://github.com/KarelWintersky "KarelWintersky (1 commits)")

---

Tags

filteringfirewallip-filterIPfilteringfirewall

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/karelwintersky-arristoolkitfirewall/health.svg)

```
[![Health](https://phpackages.com/badges/karelwintersky-arristoolkitfirewall/health.svg)](https://phpackages.com/packages/karelwintersky-arristoolkitfirewall)
```

###  Alternatives

[pragmarx/firewall

A Laravel IP whitelisting and blacklisting

1.4k999.8k](/packages/pragmarx-firewall)[akaunting/laravel-firewall

Web Application Firewall (WAF) package for Laravel

1.0k494.9k2](/packages/akaunting-laravel-firewall)[shieldon/shieldon

Web application firewall for PHP.

87229.7k1](/packages/shieldon-shieldon)[mchev/banhammer

Banhammer for Laravel allows you to ban any Model by key and by IP.

373104.9k2](/packages/mchev-banhammer)[jeroenvisser101/leakybucket

An implementation of the Leaky Bucket algorithm.

44117.5k](/packages/jeroenvisser101-leakybucket)[websoftwares/throttle

Ban identifier after certain amount of requests in a given timeframe.

1251.2k](/packages/websoftwares-throttle)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
