Skip to content

Commit 9433f4d

Browse files
committed
Network Settings: Allow to use '_' as well as '#' for special host names, closes #194.
1 parent 40d4a35 commit 9433f4d

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

modules/elasticsearch/src/main/java/org/elasticsearch/util/network/NetworkService.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,6 @@ public static interface CustomNameResolver {
6161
}
6262

6363
public void addCustomNameResolver(String name, CustomNameResolver customNameResolver) {
64-
if (!(name.startsWith("#") && name.endsWith("#"))) {
65-
name = "#" + name + "#";
66-
}
6764
customNameResolvers = MapBuilder.<String, CustomNameResolver>newMapBuilder().putAll(customNameResolvers).put(name, customNameResolver).immutableMap();
6865
}
6966

@@ -73,7 +70,7 @@ public InetAddress resolveBindHostAddress(String bindHost) throws IOException {
7370
}
7471

7572
public InetAddress resolveBindHostAddress(String bindHost, String defaultValue2) throws IOException {
76-
return resolveInetAddress(bindHost, settings.get(settings.get(GLOBAL_NETWORK_BINDHOST_SETTING), settings.get(GLOBAL_NETWORK_HOST_SETTING)), defaultValue2);
73+
return resolveInetAddress(bindHost, settings.get(GLOBAL_NETWORK_BINDHOST_SETTING, settings.get(GLOBAL_NETWORK_HOST_SETTING)), defaultValue2);
7774
}
7875

7976
public InetAddress resolvePublishHostAddress(String publishHost) throws IOException {
@@ -92,7 +89,7 @@ public InetAddress resolvePublishHostAddress(String publishHost) throws IOExcept
9289
}
9390

9491
public InetAddress resolvePublishHostAddress(String publishHost, String defaultValue2) throws IOException {
95-
return resolveInetAddress(publishHost, settings.get(settings.get(GLOBAL_NETWORK_PUBLISHHOST_SETTING), settings.get(GLOBAL_NETWORK_HOST_SETTING)), defaultValue2);
92+
return resolveInetAddress(publishHost, settings.get(GLOBAL_NETWORK_PUBLISHHOST_SETTING, settings.get(GLOBAL_NETWORK_HOST_SETTING)), defaultValue2);
9693
}
9794

9895
public InetAddress resolveInetAddress(String host, String defaultValue1, String defaultValue2) throws UnknownHostException, IOException {
@@ -105,7 +102,7 @@ public InetAddress resolveInetAddress(String host, String defaultValue1, String
105102
if (host == null) {
106103
return null;
107104
}
108-
if (host.startsWith("#") && host.endsWith("#")) {
105+
if ((host.startsWith("#") && host.endsWith("#")) || (host.startsWith("_") && host.endsWith("_"))) {
109106
host = host.substring(1, host.length() - 1);
110107

111108
CustomNameResolver customNameResolver = customNameResolvers.get(host);

0 commit comments

Comments
 (0)