Skip to content

Commit

Permalink
Not check serverAddr. (alibaba#7892)
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielLiu1123 authored and CherishCai committed Apr 12, 2022
1 parent 4e32cd6 commit 8e796e6
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 12 deletions.
11 changes: 1 addition & 10 deletions common/src/main/java/com/alibaba/nacos/common/utils/IPUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ public class IPUtil {

private static final String CHECK_OK = "ok";

private static final Pattern DOMAIN_PATTERN = Pattern.compile("[a-zA-Z0-9][-a-zA-Z0-9]{0,62}(\\.[a-zA-Z0-9][-a-zA-Z0-9]{0,62})+\\.?");

private static final String IPV4_TUPLE = "(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])";

private static final Pattern IPV4_PATTERN = Pattern
Expand Down Expand Up @@ -129,14 +127,7 @@ public static String[] splitIPPortStr(String str) {
throw new IllegalArgumentException("The IPv6 address(\"" + serverAddrArr[0] + "\") is incorrect.");
}
} else {
serverAddrArr = str.split(":");
if (serverAddrArr.length > SPLIT_IP_PORT_RESULT_LENGTH) {
throw new IllegalArgumentException("The IP address(\"" + str
+ "\") is incorrect. If it is an IPv6 address, please use [] to enclose the IP part!");
}
if (!isIPv4(serverAddrArr[0]) && !DOMAIN_PATTERN.matcher(serverAddrArr[0]).matches()) {
throw new IllegalArgumentException("The IPv4 or Domain address(\"" + serverAddrArr[0] + "\") is incorrect.");
}
serverAddrArr = str.split(IP_PORT_SPLITER);
}
return serverAddrArr;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,7 @@ public void testSplitIpPort() {
checkSplitIPPortStr("[2001:DB8:0:0:1::1]:88", false, "[2001:DB8:0:0:1::1]", "88");
checkSplitIPPortStr("[fe80::3ce6:7132:808e:707a%19]:88", false, "[fe80::3ce6:7132:808e:707a%19]", "88");

checkSplitIPPortStr("::1:88", true);
checkSplitIPPortStr("[::1:88", true);
checkSplitIPPortStr("nacos-server", false, "nacos-server");
checkSplitIPPortStr("[127.0.0.1]:88", true);
}

Expand Down

0 comments on commit 8e796e6

Please sign in to comment.