diff options
Diffstat (limited to 'cpp/src/IceDiscovery/PluginI.cpp')
-rw-r--r-- | cpp/src/IceDiscovery/PluginI.cpp | 23 |
1 files changed, 23 insertions, 0 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()) { |