提交 59c152d1 authored 作者: Thomas Mueller's avatar Thomas Mueller

The server tool now displays the correct IP address if networked.

上级 57d96a84
......@@ -150,7 +150,12 @@ public class NetUtils {
boolean result = true;
//## Java 1.4 begin ##
result = socket.getInetAddress().isLoopbackAddress();
if (result) {
return result;
}
//## Java 1.4 end ##
String s = getLocalAddress();
result = socket.getInetAddress().getHostAddress().equals(s);
return result;
}
......@@ -180,10 +185,17 @@ public class NetUtils {
InetAddress bind = null;
try {
bind = getBindAddress();
if (bind == null) {
bind = InetAddress.getLocalHost();
}
} catch (UnknownHostException e) {
// ignore
}
return bind == null ? "localhost" : bind.getHostAddress();
String address = bind == null ? "localhost" : bind.getHostAddress();
if (address.equals("127.0.0.1")) {
address = "localhost";
}
return address;
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论