private static string GetDNSResolveableHostName()

in gateway/Program.cs [80:111]


        private static string GetDNSResolveableHostName(string hostname)
        {
            foreach (NetworkInterface networkInterface in NetworkInterface.GetAllNetworkInterfaces())
            {
                var dnsSuffix = networkInterface.GetIPProperties().DnsSuffix;
                if (string.IsNullOrWhiteSpace(dnsSuffix))
                {
                    continue;
                }

                if (hostname.EndsWith(dnsSuffix))
                {
                    // We have a hostname that matches one of the DNS suffix. 
                    // Don't try appending other suffixes and resolve
                    break;
                }
                
                var newHostName = hostname + "." + dnsSuffix;
                if (GetHostEntry(newHostName) != null)
                {
                    LogMessage(string.Format("Reachable hostname: {0}", newHostName));
                    return newHostName;
                }
            }

            LogMessage(string.Format("Did not find a reachable hostname for: {0}", hostname));
#if (DEVELOPMENT_ENVIRONMENT)
            return null;
#else
            return hostname;
#endif
        }