This is an automated email from the ASF dual-hosted git repository.
huzongtang pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/rocketmq.git
The following commit(s) were added to refs/heads/develop by this push:
new c286600 Fix error in ipCheck method (#2376)
c286600 is described below
commit c286600ca14a4b45eaf12ae76184165b9aee791a
Author: zhangjidi2016 <[email protected]>
AuthorDate: Fri Nov 13 09:49:57 2020 +0800
Fix error in ipCheck method (#2376)
Co-authored-by: zhangjidi2016 <[email protected]>
---
.../java/org/apache/rocketmq/common/UtilAll.java | 30 +++-------------------
1 file changed, 3 insertions(+), 27 deletions(-)
diff --git a/common/src/main/java/org/apache/rocketmq/common/UtilAll.java
b/common/src/main/java/org/apache/rocketmq/common/UtilAll.java
index 639a200..aa69208 100644
--- a/common/src/main/java/org/apache/rocketmq/common/UtilAll.java
+++ b/common/src/main/java/org/apache/rocketmq/common/UtilAll.java
@@ -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) {