using System;
using System.Net;
namespace FastGithub.Scanner
{
    /// 
    /// 域名与ip关系
    /// 
    class DomainAddress : IEquatable
    {
        /// 
        /// 获取域名
        /// 
        public string Domain { get; }
        /// 
        /// 获取ip
        /// 
        public IPAddress Address { get; }
        /// 
        /// 域名与ip关系
        /// 
        /// 
        /// 
        public DomainAddress(string domain, IPAddress address)
        {
            this.Domain = domain;
            this.Address = address;
        }
        public override bool Equals(object? obj)
        {
            return obj is DomainAddress other && this.Equals(other);
        }
        public bool Equals(DomainAddress? other)
        {
            return other != null && other.Address.Equals(this.Address) && other.Domain == this.Domain;
        }
        public override int GetHashCode()
        {
            return HashCode.Combine(this.Domain, this.Address);
        }
        public override string ToString()
        {
            return $"{this.Domain} {this.Address}";
        }
    }
}