diff options
author | Benoit Foucher <benoit@zeroc.com> | 2015-08-13 18:21:31 +0200 |
---|---|---|
committer | Benoit Foucher <benoit@zeroc.com> | 2015-08-13 18:21:31 +0200 |
commit | 406e393f2be3a29830a7758e58e4e674afc5e21e (patch) | |
tree | 00a28864d0855177a639dd34be623185de3cc9a2 /cpp/src | |
parent | ICE-6407 java udp test failure (diff) | |
download | ice-406e393f2be3a29830a7758e58e4e674afc5e21e.tar.bz2 ice-406e393f2be3a29830a7758e58e4e674afc5e21e.tar.xz ice-406e393f2be3a29830a7758e58e4e674afc5e21e.zip |
Fixed ICE-6707 - default interface for discovery is now Ice.Default.Host if it is set
Diffstat (limited to 'cpp/src')
-rw-r--r-- | cpp/src/IceDiscovery/PluginI.cpp | 23 | ||||
-rw-r--r-- | cpp/src/IceGrid/RegistryI.cpp | 23 | ||||
-rw-r--r-- | cpp/src/IceLocatorDiscovery/PluginI.cpp | 23 |
3 files changed, 68 insertions, 1 deletions
diff --git a/cpp/src/IceDiscovery/PluginI.cpp b/cpp/src/IceDiscovery/PluginI.cpp index e0e1a7f9849..cbc9a22c5f0 100644 --- a/cpp/src/IceDiscovery/PluginI.cpp +++ b/cpp/src/IceDiscovery/PluginI.cpp @@ -14,6 +14,8 @@ #include <IceDiscovery/LocatorI.h> #include <IceDiscovery/LookupI.h> +#include <Ice/Network.h> + using namespace std; using namespace IceDiscovery; @@ -72,6 +74,27 @@ PluginI::initialize() } int port = properties->getPropertyAsIntWithDefault("IceDiscovery.Port", 4061); string interface = properties->getProperty("IceDiscovery.Interface"); + string defaultHost = properties->getProperty("Ice.Default.Host"); + if(interface.empty() && !defaultHost.empty()) + { + // + // Make sure the interface is an IP address, the UDP --interface option + // doesn't support DNS names. + // + IceInternal::ProtocolSupport protocol = ipv4 && !preferIPv6 ? IceInternal::EnableIPv4 : IceInternal::EnableIPv6; + try + { + IceInternal::Address address = IceInternal::getAddressForServer(defaultHost, 0, protocol, preferIPv6); + if(IceInternal::isAddressValid(address)) + { + interface = IceInternal::inetAddrToString(address); + } + } + catch(const Ice::LocalException&) + { + // Ignore + } + } if(properties->getProperty("IceDiscovery.Multicast.Endpoints").empty()) { diff --git a/cpp/src/IceGrid/RegistryI.cpp b/cpp/src/IceGrid/RegistryI.cpp index d8a406931f4..ac126a43dd8 100644 --- a/cpp/src/IceGrid/RegistryI.cpp +++ b/cpp/src/IceGrid/RegistryI.cpp @@ -11,7 +11,6 @@ #include <IceUtil/FileUtil.h> #include <Ice/Ice.h> #include <Ice/Network.h> -#include <Ice/ProtocolPluginFacade.h> // Just to get the hostname #include <IceStorm/Service.h> #include <IceSSL/IceSSL.h> @@ -592,6 +591,28 @@ RegistryI::startImpl() } int port = properties->getPropertyAsIntWithDefault("IceGrid.Registry.Discovery.Port", 4061); string interface = properties->getProperty("IceGrid.Registry.Discovery.Interface"); + string defaultHost = properties->getProperty("Ice.Default.Host"); + if(interface.empty() && !defaultHost.empty()) + { + // + // Make sure the interface is an IP address, the UDP --interface option + // doesn't support DNS names. + // + IceInternal::ProtocolSupport protocol = ipv4 && !preferIPv6 ? IceInternal::EnableIPv4 : IceInternal::EnableIPv6; + try + { + IceInternal::Address address = IceInternal::getAddressForServer(defaultHost, 0, protocol, preferIPv6); + if(IceInternal::isAddressValid(address)) + { + interface = IceInternal::inetAddrToString(address); + } + } + catch(const Ice::LocalException&) + { + // Ignore + } + } + if(properties->getProperty("IceGrid.Registry.Discovery.Endpoints").empty()) { ostringstream os; diff --git a/cpp/src/IceLocatorDiscovery/PluginI.cpp b/cpp/src/IceLocatorDiscovery/PluginI.cpp index bf30aa4cf8e..65844d39c3f 100644 --- a/cpp/src/IceLocatorDiscovery/PluginI.cpp +++ b/cpp/src/IceLocatorDiscovery/PluginI.cpp @@ -13,6 +13,8 @@ #include <IceLocatorDiscovery/PluginI.h> #include <IceLocatorDiscovery/IceLocatorDiscovery.h> +#include <Ice/Network.h> + using namespace std; using namespace IceLocatorDiscovery; @@ -202,6 +204,27 @@ PluginI::initialize() } int port = properties->getPropertyAsIntWithDefault("IceLocatorDiscovery.Port", 4061); string intf = properties->getProperty("IceLocatorDiscovery.Interface"); + string defaultHost = properties->getProperty("Ice.Default.Host"); + if(intf.empty() && !defaultHost.empty()) + { + // + // Make sure the interface is an IP address, the UDP --interface option + // doesn't support DNS names. + // + IceInternal::ProtocolSupport protocol = ipv4 && !preferIPv6 ? IceInternal::EnableIPv4 : IceInternal::EnableIPv6; + try + { + IceInternal::Address address = IceInternal::getAddressForServer(defaultHost, 0, protocol, preferIPv6); + if(IceInternal::isAddressValid(address)) + { + intf = IceInternal::inetAddrToString(address); + } + } + catch(const Ice::LocalException&) + { + // Ignore + } + } if(properties->getProperty("IceLocatorDiscovery.Reply.Endpoints").empty()) { |