Пример #1
0
        public static bool IsCnameSettedUpCorrectForDomain(string domain_name, string cname, string alias_name, ILogger logger = null)
        {
            try
            {
                var domain_alias = String.Format("{0}.{1}", cname, domain_name);

                var alias_host  = DnsClient.LookupHost(domain_alias);
                var needed_host = DnsClient.LookupHost(alias_name);

                if (alias_host == null || needed_host == null)
                {
                    throw new ArgumentException("Can't find host. Wait for dns updating.");
                }

                return(alias_host[0].Equals(needed_host[0]) && alias_host.Length == needed_host.Length);
            }
            catch (Exception ex)
            {
                if (logger != null)
                {
                    logger.Debug("DnsClient.LookupHost: domain: '{0}' cname: '{1}' alias: '{2}'\r\nException: {3}",
                                 domain_name, cname, alias_name, ex.ToString());
                }
                return(false);
            }
        }