Details
Description
Hi,all
I have found the FirewallManager.getOriginatingIp() use the following method to get the ip address
/** * @return the IP address of the client on which this code is running. * @throws IOException */ private String getOriginatingIp() throws IOException { if ("stub".equals(clusterSpec.getProvider())) { return "62.217.232.123"; } URL url = new URL("http://checkip.amazonaws.com/"); HttpURLConnection connection = (HttpURLConnection) url.openConnection(); connection.connect(); return IOUtils.toString(connection.getInputStream()).trim() + "/32"; }
I think we should use the InetAddress.getLocalHost() to get the ipaddress, here's some of my reason:
1). I think it is illegal for an application to get the client ip address throght the erternal website, what else if the amazon is broken and we can access the http://checkip.amazonaws.com/ or if the situation of the internet can't worked well, it will be failed to launch the cluster because we can't connect to the http://checkip.amazonaws.com/.
2). If any of the private company want to reuse the whirr project to create the cluster, Some of the company need to use the proxy to access the external website, Although the whirr project support to config the proxy, but it is still complicated for us to apply for the IT Department to authorize the proxy for the VM we have created by the whirr.
3). I think it is simple to use the InetAddress.getLocalHost() to get the local ip address
Thanks
-Jeremy Lv