mirror of
https://github.com/apache/rocketmq.git
synced 2026-08-29 04:13:00 +08:00
* fix issue#2171 * fix the issue#2171 Co-authored-by: fantow <hahaha>
This commit is contained in:
@@ -120,7 +120,7 @@ public class AclUtils {
|
||||
}
|
||||
}
|
||||
|
||||
public static String[] getAddreeStrArray(String netaddress, String partialAddress) {
|
||||
public static String[] getAddresses(String netaddress, String partialAddress) {
|
||||
String[] parAddStrArray = StringUtils.split(partialAddress.substring(1, partialAddress.length() - 1), ",");
|
||||
String address = netaddress.substring(0, netaddress.indexOf("{"));
|
||||
String[] addreeStrArray = new String[parAddStrArray.length];
|
||||
|
||||
@@ -52,14 +52,14 @@ public class RemoteAddressStrategyFactory {
|
||||
if (!last.startsWith("{")) {
|
||||
throw new AclException(String.format("MultipleRemoteAddressStrategy netaddress examine scope Exception netaddress", remoteAddr));
|
||||
}
|
||||
return new MultipleRemoteAddressStrategy(AclUtils.getAddreeStrArray(remoteAddr, last));
|
||||
return new MultipleRemoteAddressStrategy(AclUtils.getAddresses(remoteAddr, last));
|
||||
} else {
|
||||
String[] strArray = StringUtils.split(remoteAddr, ".");
|
||||
String four = strArray[3];
|
||||
if (!four.startsWith("{")) {
|
||||
throw new AclException(String.format("MultipleRemoteAddressStrategy netaddress examine scope Exception netaddress", remoteAddr));
|
||||
}
|
||||
return new MultipleRemoteAddressStrategy(AclUtils.getAddreeStrArray(remoteAddr, four));
|
||||
return new MultipleRemoteAddressStrategy(AclUtils.getAddresses(remoteAddr, four));
|
||||
}
|
||||
} else if (AclUtils.isComma(remoteAddr)) {
|
||||
return new MultipleRemoteAddressStrategy(StringUtils.split(remoteAddr, ","));
|
||||
|
||||
@@ -32,9 +32,9 @@ import org.junit.Test;
|
||||
public class AclUtilsTest {
|
||||
|
||||
@Test
|
||||
public void getAddreeStrArray() {
|
||||
public void getAddresses() {
|
||||
String address = "1.1.1.{1,2,3,4}";
|
||||
String[] addressArray = AclUtils.getAddreeStrArray(address, "{1,2,3,4}");
|
||||
String[] addressArray = AclUtils.getAddresses(address, "{1,2,3,4}");
|
||||
List<String> newAddressList = new ArrayList<>();
|
||||
for (String a : addressArray) {
|
||||
newAddressList.add(a);
|
||||
@@ -49,7 +49,7 @@ public class AclUtilsTest {
|
||||
|
||||
// IPv6 test
|
||||
String ipv6Address = "1:ac41:9987::bb22:666:{1,2,3,4}";
|
||||
String[] ipv6AddressArray = AclUtils.getAddreeStrArray(ipv6Address, "{1,2,3,4}");
|
||||
String[] ipv6AddressArray = AclUtils.getAddresses(ipv6Address, "{1,2,3,4}");
|
||||
List<String> newIPv6AddressList = new ArrayList<>();
|
||||
for (String a : ipv6AddressArray) {
|
||||
newIPv6AddressList.add(a);
|
||||
|
||||
Reference in New Issue
Block a user