support domain for server cluster into k8s

This commit is contained in:
zhanglong 2018-11-11 15:15:09 +08:00
parent 713fe2e635
commit d60c03edcd

View File

@ -29,11 +29,16 @@ public class NetUtils {
public static String localServer() {
try {
InetAddress inetAddress = InetAddress.getLocalHost();
String serverAddress = inetAddress.getHostAddress();
if (PREFER_HOSTNAME_OVER_IP) {
return InetAddress.getLocalHost().getHostName() + ":" + RunningConfig.getServerPort();
} else {
return InetAddress.getLocalHost().getHostAddress() + ":" + RunningConfig.getServerPort();
if (inetAddress.getHostName().equals(inetAddress.getCanonicalHostName())) {
serverAddress = inetAddress.getHostName();
} else {
serverAddress = inetAddress.getCanonicalHostName();
}
}
return serverAddress + UtilsAndCommons.CLUSTER_CONF_IP_SPLITER + RunningConfig.getServerPort();
} catch (UnknownHostException e) {
return "resolve_failed";
}