You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@shenyu.apache.org by GitBox <gi...@apache.org> on 2021/06/20 12:27:59 UTC

[GitHub] [incubator-shenyu] MarsOu1995 opened a new issue #1655: feature IpUtils: Add a parameter to get the desired IP based on the prefix.

MarsOu1995 opened a new issue #1655:
URL: https://github.com/apache/incubator-shenyu/issues/1655


   ## Feature Request
   
   When the system has multiple network, "IpUtils" needs to obtain the correct IP that we need. 
   
   #### Is your feature request related to a problem? Please describe
   
   When my computer has multiple network IPs, for example, 172.168.166.12 and 192.168.50.66.
   I need 192.168 network segment to configure shenyu-client (springmvc/springcloud).
   But IPutils may not get "192.168.166.12", it may only get "172.168.50.66". 
   
   #### Describe the solution you'd like
   
   So, I hope to add a method to this tool and let it receive a preferred ip prefix. For example, if you enter '192.168.', it can find '192.168.\*.\*' and return the first one that matches. 
   
   #### Additional context
   
   ```
       @Test
       public void testGetHost() throws Exception {
           Vector<InetAddress> addresses = new Vector<>();
           addresses.add(InetAddress.getByAddress("local", new byte[]{(byte) 192, (byte) 168, (byte) 50, (byte) 66}));
           addresses.add(InetAddress.getByAddress("eth0", new byte[]{(byte) 172, (byte) 168, (byte) 166, (byte) 12}));
           addresses.add(InetAddress.getByAddress("eth1", new byte[]{(byte) 10, (byte) 150, (byte) 111, (byte) 66}));
           NetworkInterface nic = mock(NetworkInterface.class);
           when(nic.getInetAddresses()).thenReturn(addresses.elements());
           Vector<NetworkInterface> nics = new Vector<>();
           nics.add(nic);
           networkInterfaceMockedStatic.when((MockedStatic.Verification) NetworkInterface.getNetworkInterfaces()).thenReturn(nics.elements());
           //assertEquals("192.168.50.66", IpUtils.getHost()); //true, Still available 
           String prefix1 = "172.168";
           assertEquals("172.168.166.12", IpUtils.getHost(prefix1)); //true
       }
   ```
   
   


-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-shenyu] yu199195 closed issue #1655: feature shenyu-common: IpUtils Add a parameter to select the network ip .

Posted by GitBox <gi...@apache.org>.
yu199195 closed issue #1655:
URL: https://github.com/apache/incubator-shenyu/issues/1655


   


-- 
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: notifications-unsubscribe@shenyu.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-shenyu] yu199195 closed issue #1655: feature shenyu-common: IpUtils Add a parameter to select the network ip .

Posted by GitBox <gi...@apache.org>.
yu199195 closed issue #1655:
URL: https://github.com/apache/incubator-shenyu/issues/1655


   


-- 
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: notifications-unsubscribe@shenyu.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org