This is an automated email from the ASF dual-hosted git repository.

monkeydluffy pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git


The following commit(s) were added to refs/heads/master by this push:
     new 4ac36cbd6 test: clarify the support for IPV6 (#9386)
4ac36cbd6 is described below

commit 4ac36cbd6cc7ebf1150a1d0ecb50a932180edab2
Author: Abhishek Choudhary <[email protected]>
AuthorDate: Thu May 18 21:17:06 2023 +0530

    test: clarify the support for IPV6 (#9386)
---
 docs/en/latest/admin-api.md |  4 ++--
 docs/zh/latest/admin-api.md |  4 ++--
 t/admin/stream-routes.t     | 44 ++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 48 insertions(+), 4 deletions(-)

diff --git a/docs/en/latest/admin-api.md b/docs/en/latest/admin-api.md
index 2be0a689b..6c40c412c 100644
--- a/docs/en/latest/admin-api.md
+++ b/docs/en/latest/admin-api.md
@@ -1383,8 +1383,8 @@ Stream Route resource request address:  
/apisix/admin/stream_routes/{id}
 | ----------- | -------- | -------- | 
------------------------------------------------------------------- | 
----------------------------- |
 | upstream    | False    | Upstream | Configuration of the 
[Upstream](./terminology/upstream.md). |                               |
 | upstream_id | False    | Upstream | Id of the 
[Upstream](terminology/upstream.md) service.      |                             
  |
-| remote_addr | False    | IP/CIDR  | Filters Upstream forwards by matching 
with client IP.               | "127.0.0.1/32" or "127.0.0.1" |
-| server_addr | False    | IP/CIDR  | Filters Upstream forwards by matching 
with APISIX Server IP.        | "127.0.0.1/32" or "127.0.0.1" |
+| remote_addr | False    | IPv4, IPv4 CIDR, IPv6  | Filters Upstream forwards 
by matching with client IP.               | "127.0.0.1" or "127.0.0.1/32" or 
"::1" |
+| server_addr | False    | IPv4, IPv4 CIDR, IPv6  | Filters Upstream forwards 
by matching with APISIX Server IP.        | "127.0.0.1" or "127.0.0.1/32" or 
"::1" |
 | server_port | False    | Integer  | Filters Upstream forwards by matching 
with APISIX Server port.      | 9090                          |
 | sni         | False    | Host     | Server Name Indication.                  
                           | "test.com"                    |
 | protocol.name | False    | String | Name of the protocol proxyed by xRPC 
framework.                     | "redis"                    |
diff --git a/docs/zh/latest/admin-api.md b/docs/zh/latest/admin-api.md
index f9e0ba3b7..3d049d059 100644
--- a/docs/zh/latest/admin-api.md
+++ b/docs/zh/latest/admin-api.md
@@ -1386,8 +1386,8 @@ Plugin 资源请求地址:/apisix/admin/stream_routes/{id}
 | ---------------- | ------| -------- | 
------------------------------------------------------------------------------| 
------  |
 | upstream         | 否    | Upstream | Upstream 配置,详细信息请参考 
[Upstream](terminology/upstream.md)。             |         |
 | upstream_id      | 否    | Upstream | 需要使用的 Upstream id,详细信息请 
[Upstream](terminology/upstream.md)。       |         |
-| remote_addr      | 否    | IP/CIDR  | 过滤选项:如果客户端 IP 匹配,则转发到上游                 
                     | "127.0.0.1/32" 或 "127.0.0.1" |
-| server_addr      | 否    | IP/CIDR  | 过滤选项:如果 APISIX 服务器的 IP 与 `server_addr` 
匹配,则转发到上游。         | "127.0.0.1/32" 或 "127.0.0.1" |
+| remote_addr      | 否    | IPv4, IPv4 CIDR, IPv6  | 过滤选项:如果客户端 IP 匹配,则转发到上游   
                                   | "127.0.0.1" 或 "127.0.0.1/32" 或 "::1" |
+| server_addr      | 否    | IPv4, IPv4 CIDR, IPv6  | 过滤选项:如果 APISIX 服务器的 IP 与 
`server_addr` 匹配,则转发到上游。         | "127.0.0.1" 或 "127.0.0.1/32" 或 "::1" |
 | server_port      | 否    | 整数     | 过滤选项:如果 APISIX 服务器的端口 与 `server_port` 
匹配,则转发到上游。        | 9090  |
 | sni              | 否    | Host     | 服务器名称。                                  
                                 | "test.com"     |
 | protocol.name    | 否    | 字符串   | xRPC 框架代理的协议的名称。                           
                         | "redis"        |
diff --git a/t/admin/stream-routes.t b/t/admin/stream-routes.t
index a25496d57..77a6d5bad 100644
--- a/t/admin/stream-routes.t
+++ b/t/admin/stream-routes.t
@@ -607,3 +607,47 @@ GET /t
 {"error_msg":"unknown protocol [xxx]"}
 passed
 {"error_msg":"property \"faults\" validation failed: wrong type: expected 
array, got string"}
+
+
+
+=== TEST 17: set route with remote_addr and server_addr in IPV6
+--- config
+    location /t {
+        content_by_lua_block {
+            local t = require("lib.test_admin").test
+            local code, body = t('/apisix/admin/stream_routes/1',
+                ngx.HTTP_PUT,
+                [[{
+                    "remote_addr": "::1",
+                    "server_addr": "::1",
+                    "server_port": 1982,
+                    "plugins": {
+                        "mqtt-proxy": {
+                            "protocol_name": "MQTT",
+                            "protocol_level": 4
+                        }
+                    },
+                    "upstream": {
+                        "type": "chash",
+                        "key": "mqtt_client_id",
+                        "nodes": [
+                            {
+                                "host": "127.0.0.1",
+                                "port": 1980,
+                                "weight": 1
+                            }
+                        ]
+                    }
+                }]]
+                )
+
+            if code >= 300 then
+                ngx.status = code
+            end
+            ngx.say(body)
+        }
+    }
+--- request
+GET /t
+--- response_body
+passed

Reply via email to