morsvox/ip-range-checker
Composer 安装命令:
composer require morsvox/ip-range-checker
包简介
This package is a little helper to check if a given IP address is in a certain IP range.
关键字:
README 文档
README
This is a simple helper package that I use when I need to check if an IP is in a given IP range.
All ideas, contributions and criticism are welcome.
Installation
composer require morsvox/ip-range-checker
Usage
Import the class in your script:
use IlkerMutlu\IPRangeChecker\Checker; $ip = '192.168.0.22'; $checker = Checker::forIp($ip);
Pass the start IP and end IP in an array to the setRange() method.
$checker->setRange([ '192.168.0.1', '192.168.0.28' ]); // $checker->check() will return true for IPs between // 192.168.0.1 and 192.168.0.28 // 192.168.0.19 will return TRUE // 192.168.1.41 will return FALSE
You can also use a wildcard.
$checker->setRange('192.168.0.*'); // $checker->check() will return TRUE for IPs between // 192.168.0.1 and 192.168.0.255 // 192.168.0.41 will return TRUE // 192.168.1.41 will return FALSE
OR, you can pass in two IPs separated with a dash.
$checker->setRange('192.168.0.4-192.168.0.54'); // $checker->check() will return TRUE for IPs between // 192.168.0.4 and 192.168.0.54 // 192.168.0.41 will return TRUE // 192.168.0.61 will return FALSE
After setting the range, just call the check() method on the checker instance, which will return a boolean value.
$checker->check();
TODO
- Tests
Support dashed IP range strings- Support CIDR
统计信息
- 总下载量: 17k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-03-06