|
|
|
@ -119,15 +119,32 @@ public class IpUtils {
|
|
|
|
|
* 验证IP区间是否符合要求
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* @param ipAddressList 支持格式:x.x.x.x-x.x.x.x,x.x.x.x-x.x.x.x。多个IP段逗号隔开
|
|
|
|
|
* @param ipRangeAddressList 支持格式:x.x.x.x-x.x.x.x,x.x.x.x-x.x.x.x。多个IP段逗号隔开
|
|
|
|
|
*/
|
|
|
|
|
public static void verifyIpRange(String ipAddressList) {
|
|
|
|
|
Assert.notBlank(ipAddressList, "待验证的IP区间,不能为空!");
|
|
|
|
|
for (String ipRange : ipAddressList.split(SEPARATOR)) {
|
|
|
|
|
public static void verifyIpRange(String ipRangeAddressList) {
|
|
|
|
|
Assert.notBlank(ipRangeAddressList, "待验证的IP区间,不能为空!");
|
|
|
|
|
for (String ipRange : ipRangeAddressList.split(SEPARATOR)) {
|
|
|
|
|
// IP区间的正则
|
|
|
|
|
String reg = "^((2(5[0-5]|[0-4]\\d))|[0-1]?\\d{1,2})(\\.((2(5[0-5]|[0-4]\\d))|[0-1]?\\d{1,2})){3}" +
|
|
|
|
|
"-((2(5[0-5]|[0-4]\\d))|[0-1]?\\d{1,2})(\\.((2(5[0-5]|[0-4]\\d))|[0-1]?\\d{1,2})){3}$";
|
|
|
|
|
Assert.isTrue(ReUtil.isMatch(reg, ipRange),
|
|
|
|
|
() -> new PlatformException("ipAddressList 参数格式化错误!支持格式:x.x.x.x-x.x.x.x,x.x.x.x-x.x.x.x"));
|
|
|
|
|
() -> new PlatformException("ipRangeAddressList 参数格式化错误!支持格式:x.x.x.x-x.x.x.x,x.x.x.x-x.x.x.x"));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 验证IP是否符合要求
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* @param ipAddressList 支持格式:x.x.x.x 多个IP段逗号隔开
|
|
|
|
|
*/
|
|
|
|
|
public static void verifyIp(String ipAddressList) {
|
|
|
|
|
Assert.notBlank(ipAddressList, "待验证的IP,不能为空!");
|
|
|
|
|
for (String ip : ipAddressList.split(SEPARATOR)) {
|
|
|
|
|
// 单IP的正则
|
|
|
|
|
String reg = "^((2(5[0-5]|[0-4]\\d))|[0-1]?\\d{1,2})(\\.((2(5[0-5]|[0-4]\\d))|[0-1]?\\d{1,2})){3}$";
|
|
|
|
|
Assert.isTrue(ReUtil.isMatch(reg, ip),
|
|
|
|
|
() -> new PlatformException("ipAddressList 参数格式化错误!支持格式:x.x.x.x,x.x.x.x"));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|