H2如何处理多个网络接口? 目前我在一台计算机上禁用了两个ips,其函数为getOwnIpAddress,如果找到两个带IP的接口,则会返回错误消息。
private String getOwnIpAddress()
{
ArrayList<String> ipAddresses = new ArrayList<>();
try
{
/*find out my own ip address*/
Enumeration<NetworkInterface> networkInterfaces;
networkInterfaces = NetworkInterface.getNetworkInterfaces();
for (NetworkInterface netint : Collections.list(networkInterfaces))
{
Enumeration<InetAddress> inetAddresses = netint.getInetAddresses();
for (InetAddress inetAddress : Collections.list(inetAddresses))
{
if (isIPAddress(inetAddress.getHostAddress())
&& !inetAddress.getHostAddress().equals("127.0.0.1"))
{
ipAddresses.add(inetAddress.getHostAddress());
}
}
}
if (ipAddresses.size() > 1)
{
DialogMessage.showMessage(null, Resource.getResourceString("tooManyInterfacesError"), "",
JOptionPane.ERROR_MESSAGE);
Main.quit();
}
else if (ipAddresses.size() > 0)
{
return ipAddresses.get(0);
}
else
{
return null;
}
}
catch (SocketException ex)
{
ex.printStackTrace();
}
return null;
}
我可以让H2更喜欢一个IP吗?或者都可以在auto_server模式下由H2处理?