athlon1600/php-cidr-range-optimizer
最新稳定版本:v1.0.2
Composer 安装命令:
composer require athlon1600/php-cidr-range-optimizer
包简介
Given a list of IP ranges, merge them into the smallest possible list of CIDRs.
README 文档
README
Given a list of IP address ranges, minify that list to the smallest possible size by performing the following optimizations:
- removing invalid IP addresses/ranges from the list
- removing duplicates
- removing IP ranges already covered by larger ranges in the list
- merging adjacent IP ranges into larger, contiguous blocks
⭐ Demo
An online tool that uses a near exact version of this library:
Installation
composer require athlon1600/php-cidr-range-optimizer
Usage
Build your list of IP ranges into CIDRList object, then use RangeOptimizer class to optimize it. Example:
use ProxyNova\RangeOptimizer\CIDRList; use ProxyNova\RangeOptimizer\RangeOptimizer; $ranges = CIDRList::fromArray([ "192.168.1.0/26", "192.168.1.64/27", "192.168.1.96/27", "10.1.0.0/26", "10.1.0.64/26" ]); // returns new optimized CIDRList object $optimized = RangeOptimizer::optimize($ranges); echo $optimized;
Output:
10.1.0.0/25
192.168.1.0/25
统计信息
- 总下载量: 77
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 5
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-07-15