karelwintersky/arris.toolkit.firewall
Composer 安装命令:
composer require karelwintersky/arris.toolkit.firewall
包简介
Library providing IP filtering features
关键字:
README 文档
README
Readme in Russian - README.RU.md
Library providing IP filtering features
| Type | Syntax | Details |
|---|---|---|
| IPV4 | 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.255and from 192.168.1.0 to 198.168.1.60 |
| Wild card | 192.168.0.* |
IPs starting with 192.168.0Same as IP Range 192.168.0.0-192.168.0.255 |
| CIDR Mask | 192.168.0.0/24 |
IPs starting with 192.168.0Same 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
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
$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|falseFireWallState::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
addWhiteList()- add range to White list (Allowed), alias ofaddAllowed()addBlackList()- add range to Black List (Forbidden), alias ofaddDenied()
Argument is string or array of strings
192.168.0.1- alone IP192.168.0.0-192.168.1.60- range192.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
$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
- 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?
- 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
Firewall is licensed under the MIT license.
karelwintersky/arris.toolkit.firewall 适用场景与选型建议
karelwintersky/arris.toolkit.firewall 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 268 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 02 月 08 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「firewall」 「IP」 「filtering」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 karelwintersky/arris.toolkit.firewall 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 karelwintersky/arris.toolkit.firewall 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 karelwintersky/arris.toolkit.firewall 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
PHP Basic Firewall
Modern PHP Sanitization Library
Laravel package for rapid CRUD API scaffolding with filtering, sorting, pagination and CSV export
A Laravel package that contains queries for constructing a datatable
Official PHP integration for Optidash - AI-powered image optimization and processing API. We will drastically speed-up your websites and save you money on bandwidth and storage.
Web Application Firewall (WAF) package for Laravel
统计信息
- 总下载量: 268
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 14
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-02-08