kayx23 opened a new issue, #9378:
URL: https://github.com/apache/apisix/issues/9378

   ### Current State
   
   In [Admin API reference, Stream 
Route](https://apisix.apache.org/docs/apisix/admin-api/#stream-route), 
`remote_addr` and `server_addr` should support both IPv4 and IPv6. Currently 
only the IPv4 usage is documented and **tested**  
   
   Tests for stream route can be found at `t/admin/stream-routes.t` and 
`t/admin/stream-routes-disable.t`
   
   ### Desired State
   
   `remote_addr` and `server_addr` seem to support IPv6 as well. 
   
   In `apisix/stream/router/ip_port.lua`:
   ```
   if item.value.remote_addr then
       item.value.remote_addr_matcher = 
core_ip.create_ip_matcher({item.value.remote_addr})
   end
   if item.value.server_addr then
       item.value.server_addr_matcher = 
core_ip.create_ip_matcher({item.value.server_addr})
   end
   ```
   where `core_ip` is `local core_ip  = require("apisix.core.ip")`
   
   In `apisix/core/ip`:
   ```
   local ipmatcher = require("resty.ipmatcher")
   ...
   
   function _M.create_ip_matcher(ip_list)
       local ip, err = ipmatcher.new(ip_list)
       if not ip then
           log.error("failed to create ip matcher: ", err,
                     " ip list: ", json.delay_encode(ip_list))
           return nil
       end
   
       return ip
   end
   ```
   where `ipmatcher` can be sourced back to 
[lua-resty-ipmatcher](https://github.com/api7/lua-resty-ipmatcher)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to