rocketmq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From huzongt...@apache.org
Subject [rocketmq] branch develop updated: [ISSUE #1290] Acl IP Address Matching Range enhancement
Date Tue, 09 Jul 2019 04:29:29 GMT
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 92ec70b  [ISSUE #1290] Acl IP Address Matching Range enhancement
92ec70b is described below

commit 92ec70b42de1bd219c471eeac01a515e93de322d
Author: githublaohu <2372554140@qq.com>
AuthorDate: Tue Jul 9 12:29:18 2019 +0800

    [ISSUE #1290] Acl IP Address Matching Range enhancement
---
 .../rocketmq/acl/plain/RemoteAddressStrategyFactory.java     |  4 ++--
 .../apache/rocketmq/acl/plain/RemoteAddressStrategyTest.java | 12 ++++++++++++
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/acl/src/main/java/org/apache/rocketmq/acl/plain/RemoteAddressStrategyFactory.java
b/acl/src/main/java/org/apache/rocketmq/acl/plain/RemoteAddressStrategyFactory.java
index de29e92..cc2dcee 100644
--- a/acl/src/main/java/org/apache/rocketmq/acl/plain/RemoteAddressStrategyFactory.java
+++ b/acl/src/main/java/org/apache/rocketmq/acl/plain/RemoteAddressStrategyFactory.java
@@ -41,7 +41,7 @@ public class RemoteAddressStrategyFactory {
         if (StringUtils.isBlank(remoteAddr)) {
             return BLANK_NET_ADDRESS_STRATEGY;
         }
-        if ("*".equals(remoteAddr)) {
+        if ("*".equals(remoteAddr) || "*.*.*.*".equals(remoteAddr)) {
             return NULL_NET_ADDRESS_STRATEGY;
         }
         if (remoteAddr.endsWith("}")) {
@@ -122,7 +122,7 @@ public class RemoteAddressStrategyFactory {
 
         public RangeRemoteAddressStrategy(String remoteAddr) {
             String[] strArray = StringUtils.split(remoteAddr, ".");
-            if (analysis(strArray, 2) || analysis(strArray, 3)) {
+            if (analysis(strArray, 1) || analysis(strArray, 2) || analysis(strArray, 3))
{
                 AclUtils.verify(remoteAddr, index - 1);
                 StringBuffer sb = new StringBuffer().append(strArray[0].trim()).append(".").append(strArray[1].trim()).append(".");
                 if (index == 3) {
diff --git a/acl/src/test/java/org/apache/rocketmq/acl/plain/RemoteAddressStrategyTest.java
b/acl/src/test/java/org/apache/rocketmq/acl/plain/RemoteAddressStrategyTest.java
index 53391f4..2c2e76b 100644
--- a/acl/src/test/java/org/apache/rocketmq/acl/plain/RemoteAddressStrategyTest.java
+++ b/acl/src/test/java/org/apache/rocketmq/acl/plain/RemoteAddressStrategyTest.java
@@ -39,6 +39,10 @@ public class RemoteAddressStrategyTest {
         plainAccessResource.setWhiteRemoteAddress("*");
         RemoteAddressStrategy remoteAddressStrategy = remoteAddressStrategyFactory.getRemoteAddressStrategy(plainAccessResource);
         Assert.assertEquals(remoteAddressStrategy, RemoteAddressStrategyFactory.NULL_NET_ADDRESS_STRATEGY);
+        
+        plainAccessResource.setWhiteRemoteAddress("*.*.*.*");
+        remoteAddressStrategy = remoteAddressStrategyFactory.getRemoteAddressStrategy(plainAccessResource);
+        Assert.assertEquals(remoteAddressStrategy, RemoteAddressStrategyFactory.NULL_NET_ADDRESS_STRATEGY);
 
         plainAccessResource.setWhiteRemoteAddress("127.0.0.1");
         remoteAddressStrategy = remoteAddressStrategyFactory.getRemoteAddressStrategy(plainAccessResource);
@@ -165,6 +169,14 @@ public class RemoteAddressStrategyTest {
         plainAccessResource.setWhiteRemoteAddress("127.0.1-200.*");
         remoteAddressStrategy = remoteAddressStrategyFactory.getRemoteAddressStrategy(plainAccessResource);
         rangeNetaddressStrategyThirdlyTest(remoteAddressStrategy, head, 1, 200);
+        
+        plainAccessResource.setWhiteRemoteAddress("127.*.*.*");
+        remoteAddressStrategy = remoteAddressStrategyFactory.getRemoteAddressStrategy(plainAccessResource);
+        rangeNetaddressStrategyThirdlyTest(remoteAddressStrategy, head, 1, 200);
+        
+        plainAccessResource.setWhiteRemoteAddress("127.1-150.*.*");
+        remoteAddressStrategy = remoteAddressStrategyFactory.getRemoteAddressStrategy(plainAccessResource);
+        rangeNetaddressStrategyThirdlyTest(remoteAddressStrategy, head, 1, 200);
     }
 
     private void rangeNetaddressStrategyTest(RemoteAddressStrategy remoteAddressStrategy,
String head, int start,


Mime
View raw message