This commit is contained in:
qingliang.ql 2019-02-25 15:53:23 +08:00
parent 7b60e2ef3f
commit 5b711c676a
2 changed files with 5 additions and 2 deletions

View File

@ -38,9 +38,12 @@ public interface Constants {
*/
String PREFER_HOSTNAME_OVER_IP_PROPERTY_NAME = "nacos.preferHostnameOverIp";
String NACOS_SERVER_IP = "nacos.server.ip";
String USE_ONLY_SITE_INTERFACES = "nacos.inetutils.use-only-site-local-interfaces";
String PREFERRED_NETWORKS = "nacos.inetutils.preferred-networks";
String IGNORED_INTERFACES = "nacos.inetutils.ignored-interfaces";
String IP_ADDRESS = "nacos.inetutils.ip-address";
String PREFER_HOSTNAME_OVER_IP = "nacos.inetutils.prefer-hostname-over-ip";
String SYSTEM_PREFER_HOSTNAME_OVER_IP = "nacos.preferHostnameOverIp";
}

View File

@ -63,7 +63,7 @@ public class InetUtils {
ignoredInterfaces.add(ignored);
}
String nacosIp = System.getProperty("nacos.server.ip");
String nacosIp = System.getProperty(NACOS_SERVER_IP);
if (StringUtils.isBlank(nacosIp)) {
nacosIp = PropertyUtil.getProperty(IP_ADDRESS);
}
@ -75,7 +75,7 @@ public class InetUtils {
selfIp = nacosIp;
if (StringUtils.isBlank(selfIp)) {
preferHostnameOverIp = Boolean.getBoolean("nacos.preferHostnameOverIp");
preferHostnameOverIp = Boolean.getBoolean(SYSTEM_PREFER_HOSTNAME_OVER_IP);
if (!preferHostnameOverIp) {
preferHostnameOverIp = Boolean.parseBoolean(PREFER_HOSTNAME_OVER_IP);