From 9433f4d6516fd91ea9fd560f08c9a818fbdd4e50 Mon Sep 17 00:00:00 2001 From: kimchy Date: Wed, 26 May 2010 16:33:35 +0300 Subject: [PATCH] Network Settings: Allow to use '_' as well as '#' for special host names, closes #194. --- .../org/elasticsearch/util/network/NetworkService.java | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/util/network/NetworkService.java b/modules/elasticsearch/src/main/java/org/elasticsearch/util/network/NetworkService.java index 64f5a8d31b4..1db3488e2ff 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/util/network/NetworkService.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/util/network/NetworkService.java @@ -61,9 +61,6 @@ public class NetworkService extends AbstractComponent { } public void addCustomNameResolver(String name, CustomNameResolver customNameResolver) { - if (!(name.startsWith("#") && name.endsWith("#"))) { - name = "#" + name + "#"; - } customNameResolvers = MapBuilder.newMapBuilder().putAll(customNameResolvers).put(name, customNameResolver).immutableMap(); } @@ -73,7 +70,7 @@ public class NetworkService extends AbstractComponent { } public InetAddress resolveBindHostAddress(String bindHost, String defaultValue2) throws IOException { - return resolveInetAddress(bindHost, settings.get(settings.get(GLOBAL_NETWORK_BINDHOST_SETTING), settings.get(GLOBAL_NETWORK_HOST_SETTING)), defaultValue2); + return resolveInetAddress(bindHost, settings.get(GLOBAL_NETWORK_BINDHOST_SETTING, settings.get(GLOBAL_NETWORK_HOST_SETTING)), defaultValue2); } public InetAddress resolvePublishHostAddress(String publishHost) throws IOException { @@ -92,7 +89,7 @@ public class NetworkService extends AbstractComponent { } public InetAddress resolvePublishHostAddress(String publishHost, String defaultValue2) throws IOException { - return resolveInetAddress(publishHost, settings.get(settings.get(GLOBAL_NETWORK_PUBLISHHOST_SETTING), settings.get(GLOBAL_NETWORK_HOST_SETTING)), defaultValue2); + return resolveInetAddress(publishHost, settings.get(GLOBAL_NETWORK_PUBLISHHOST_SETTING, settings.get(GLOBAL_NETWORK_HOST_SETTING)), defaultValue2); } public InetAddress resolveInetAddress(String host, String defaultValue1, String defaultValue2) throws UnknownHostException, IOException { @@ -105,7 +102,7 @@ public class NetworkService extends AbstractComponent { if (host == null) { return null; } - if (host.startsWith("#") && host.endsWith("#")) { + if ((host.startsWith("#") && host.endsWith("#")) || (host.startsWith("_") && host.endsWith("_"))) { host = host.substring(1, host.length() - 1); CustomNameResolver customNameResolver = customNameResolvers.get(host);