|
|
|
@ -43,21 +43,17 @@ public class InetUtils implements Closeable {
@@ -43,21 +43,17 @@ public class InetUtils implements Closeable {
|
|
|
|
|
// TODO: maybe shutdown the thread pool if it isn't being used?
|
|
|
|
|
private final ExecutorService executorService; |
|
|
|
|
private final InetUtilsProperties properties; |
|
|
|
|
private static final InetUtils instance = new InetUtils(new InetUtilsProperties()); |
|
|
|
|
|
|
|
|
|
private final Log log = LogFactory.getLog(InetUtils.class); |
|
|
|
|
|
|
|
|
|
public InetUtils(final InetUtilsProperties properties) { |
|
|
|
|
this.properties = properties; |
|
|
|
|
this.executorService = Executors |
|
|
|
|
.newSingleThreadExecutor(new ThreadFactory() { |
|
|
|
|
@Override |
|
|
|
|
public Thread newThread(Runnable r) { |
|
|
|
|
.newSingleThreadExecutor(r -> { |
|
|
|
|
Thread thread = new Thread(r); |
|
|
|
|
thread.setName(InetUtilsProperties.PREFIX); |
|
|
|
|
thread.setDaemon(true); |
|
|
|
|
return thread; |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -184,31 +180,6 @@ public class InetUtils implements Closeable {
@@ -184,31 +180,6 @@ public class InetUtils implements Closeable {
|
|
|
|
|
return hostInfo; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Find the first non-loopback host info. If there were errors return a host info with |
|
|
|
|
* 'localhost' and '127.0.0.1' for hostname and ipAddress respectively. |
|
|
|
|
* |
|
|
|
|
* @deprecated use the non-static findFirstNonLoopbackHostInfo() instead |
|
|
|
|
*/ |
|
|
|
|
@Deprecated |
|
|
|
|
public static HostInfo getFirstNonLoopbackHostInfo() { |
|
|
|
|
return instance.findFirstNonLoopbackHostInfo(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Convert an internet address to a HostInfo. |
|
|
|
|
* |
|
|
|
|
* @deprecated use the non-static convertAddress() instead |
|
|
|
|
*/ |
|
|
|
|
@Deprecated |
|
|
|
|
public static HostInfo convert(final InetAddress address) { |
|
|
|
|
return instance.convertAddress(address); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static int getIpAddressAsInt(String host) { |
|
|
|
|
return new HostInfo(host).getIpAddressAsInt(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static class HostInfo { |
|
|
|
|
public boolean override; |
|
|
|
|
private String ipAddress; |
|
|
|
|