コード例 #1
0
ファイル: DnsLookup.cs プロジェクト: ztcyun/CommunityServer
        /// <summary>
        /// Check existance Domain in PTR record
        /// </summary>
        /// <param name="ipAddress">IP address for PTR check</param>
        /// <param name="domainName">PTR domain name</param>
        /// <exception cref="ArgumentNullException">if domainName or ipAddress is empty/null</exception>
        /// <exception cref="ArgumentException">if domainName is invalid</exception>
        /// <returns>true if exists and vice versa</returns>
        public bool IsDomainPtrRecordExists(IPAddress ipAddress, string domainName)
        {
            if (string.IsNullOrEmpty(domainName))
            {
                throw new ArgumentNullException("domainName");
            }

            if (ipAddress == null)
            {
                throw new ArgumentNullException("ipAddress");
            }

            var domain = DomainName.Parse(domainName);

            var ptrDomain = _sDnsResolver.ResolvePtr(ipAddress);

            return(ptrDomain.Equals(domain));
        }