mirror of
https://github.com/tiennm99/zfoo.git
synced 2026-09-06 22:18:06 +00:00
fix[net]: Empty string judgment in CIDR block
This commit is contained in:
@@ -482,6 +482,12 @@ public class NetUtils {
|
||||
* 是否在一个ip网段下
|
||||
*/
|
||||
public static boolean isInRange(String ip, String cidr) {
|
||||
if (StringUtils.isBlank(ip)) {
|
||||
return false;
|
||||
}
|
||||
if (StringUtils.isBlank(cidr)) {
|
||||
return false;
|
||||
}
|
||||
var ips = ip.split(StringUtils.PERIOD_REGEX);
|
||||
var ipAddr = (Integer.parseInt(ips[0]) << 24)
|
||||
| (Integer.parseInt(ips[1]) << 16)
|
||||
|
||||
Reference in New Issue
Block a user