未验证 提交 c286600c 编写于 作者: Z zhangjidi2016 提交者: GitHub

Fix error in ipCheck method (#2376)

Co-authored-by: Nzhangjidi2016 <zhangjidi@cmss.chinamobile.com>
上级 0b600484
......@@ -461,33 +461,9 @@ public class UtilAll {
if (ip.length != 4) {
throw new RuntimeException("illegal ipv4 bytes");
}
if (ip[0] >= (byte) 1 && ip[0] <= (byte) 126) {
if (ip[1] == (byte) 1 && ip[2] == (byte) 1 && ip[3] == (byte) 1) {
return false;
}
if (ip[1] == (byte) 0 && ip[2] == (byte) 0 && ip[3] == (byte) 0) {
return false;
}
return true;
} else if (ip[0] >= (byte) 128 && ip[0] <= (byte) 191) {
if (ip[2] == (byte) 1 && ip[3] == (byte) 1) {
return false;
}
if (ip[2] == (byte) 0 && ip[3] == (byte) 0) {
return false;
}
return true;
} else if (ip[0] >= (byte) 192 && ip[0] <= (byte) 223) {
if (ip[3] == (byte) 1) {
return false;
}
if (ip[3] == (byte) 0) {
return false;
}
return true;
}
return false;
InetAddressValidator validator = InetAddressValidator.getInstance();
return validator.isValidInet4Address(ipToIPv4Str(ip));
}
private static boolean ipV6Check(byte[] ip) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册