コード例 #1
0
        /// <summary>
        /// Constructs a new instance of <see cref="DnsNSRecord"/>.
        /// </summary>
        /// <param name="zone">Associated zone</param>
        /// <param name="name">Owner name</param>
        /// <param name="class">Record class</param>
        /// <param name="timeToLive">Record time to live (TTL)</param>
        /// <param name="nameServer">A host which should be authoritative for the domain</param>
        public DnsNSRecord(DnsZone zone, string name, DnsRecordClasses @class, TimeSpan timeToLive, string nameServer)
            : base(zone, name, DnsRecordTypes.NS, @class, timeToLive)
        {
            if (string.IsNullOrWhiteSpace(nameServer))
            {
                throw new ArgumentNullException(nameof(nameServer));
            }

            NameServer = nameServer;
        }
コード例 #2
0
        /// <summary>
        /// Constructs a new instance of <see cref="DnsCNAMERecord"/>.
        /// </summary>
        /// <param name="zone">Associated zone</param>
        /// <param name="name">Owner name</param>
        /// <param name="class">Record class</param>
        /// <param name="timeToLive">Record time to live (TTL)</param>
        /// <param name="primaryName">Primary Name for <see cref="DnsRecord.Name"/></param>
        public DnsCNAMERecord(DnsZone zone, string name, DnsRecordClasses @class, TimeSpan timeToLive, string primaryName)
            : base(zone, name, DnsRecordTypes.CNAME, @class, timeToLive)
        {
            if (string.IsNullOrWhiteSpace(primaryName))
            {
                throw new ArgumentNullException(nameof(primaryName));
            }

            PrimaryName = primaryName;
        }
コード例 #3
0
        /// <summary>
        /// Constructs a new instance of <see cref="DnsPTRRecord"/>.
        /// </summary>
        /// <param name="zone">Associated zone</param>
        /// <param name="name">Owner name</param>
        /// <param name="class">Record class</param>
        /// <param name="timeToLive">Record time to live (TTL)</param>
        /// <param name="domainName">Pointer Domain Name</param>
        public DnsPTRRecord(DnsZone zone, string name, DnsRecordClasses @class, TimeSpan timeToLive, string domainName)
            : base(zone, name, DnsRecordTypes.PTR, @class, timeToLive)
        {
            if (string.IsNullOrWhiteSpace(domainName))
            {
                throw new ArgumentNullException(nameof(domainName));
            }

            DomainName = domainName;
        }
コード例 #4
0
ファイル: DnsMXRecord.cs プロジェクト: hyberdk/DnsServerApi
        /// <summary>
        /// Constructs a new instance of <see cref="DnsMXRecord"/>.
        /// </summary>
        /// <param name="zone">Associated zone</param>
        /// <param name="name">Owner name</param>
        /// <param name="class">Record class</param>
        /// <param name="timeToLive">Record time to live (TTL)</param>
        /// <param name="preference">Preference given to this record</param>
        /// <param name="domainName">Mail Exchange Domain Name</param>
        public DnsMXRecord(DnsZone zone, string name, DnsRecordClasses @class, TimeSpan timeToLive, ushort preference, string domainName)
            : base(zone, name, DnsRecordTypes.MX, @class, timeToLive)
        {
            if (string.IsNullOrWhiteSpace(domainName))
            {
                throw new ArgumentNullException(domainName);
            }

            Preference = preference;
            DomainName = domainName;
        }
コード例 #5
0
        /// <summary>
        /// Removes a DNS Zone
        /// </summary>
        /// <param name="zone">Zone to be removed</param>
        /// <returns>True if the zone was removed, otherwise false</returns>
        public virtual bool TryDeleteZone(DnsZone zone)
        {
            if (zone == null)
            {
                return(false);
            }

            try
            {
                DeleteZone(zone);
                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
コード例 #6
0
ファイル: DnsRecord.cs プロジェクト: hyberdk/DnsServerApi
        /// <summary>
        /// Constructs a new instance of <see cref="DnsRecord"/>.
        /// </summary>
        /// <param name="zone">Associated zone</param>
        /// <param name="name">Owner name</param>
        /// <param name="type">Record type</param>
        /// <param name="class">Record class</param>
        /// <param name="timeToLive">Record time to live (TTL)</param>
        public DnsRecord(DnsZone zone, string name, DnsRecordTypes type, DnsRecordClasses @class, TimeSpan timeToLive)
        {
            if (string.IsNullOrWhiteSpace(name))
            {
                throw new ArgumentNullException(nameof(name));
            }
            if (timeToLive.Ticks < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(timeToLive));
            }

            Zone       = zone;
            Name       = name;
            Type       = type;
            Class      = @class;
            TimeToLive = timeToLive;
        }
コード例 #7
0
        /// <summary>
        /// Adds a DNS Zone to this server
        /// </summary>
        /// <param name="zoneTemplate">Template of zone to be added</param>
        /// <param name="zone">Created zone</param>
        /// <returns>True if the zone is created, otherwise false</returns>
        public virtual bool TryCreateZone(DnsZone zoneTemplate, out DnsZone zone)
        {
            if (zoneTemplate == null)
            {
                zone = null;
                return(false);
            }

            try
            {
                zone = CreateZone(zoneTemplate);
                return(true);
            }
            catch (Exception)
            {
                zone = null;
                return(false);
            }
        }
コード例 #8
0
        /// <summary>
        /// Retrieves a DNS Zone
        /// </summary>
        /// <param name="domainName">Domain name of the zone to retrieve</param>
        /// <param name="zone">If successful, the retrieved zone</param>
        /// <returns>True if the zone was retrieved, otherwise false</returns>
        public virtual bool TryGetZone(string domainName, out DnsZone zone)
        {
            if (string.IsNullOrWhiteSpace(domainName))
            {
                zone = null;
                return(false);
            }

            try
            {
                zone = GetZone(domainName);
                return(true);
            }
            catch (Exception)
            {
                zone = null;
                return(false);
            }
        }
コード例 #9
0
        /// <summary>
        /// Constructs a new instance of <see cref="DnsSRVRecord"/>.
        /// </summary>
        /// <param name="zone">Associated zone</param>
        /// <param name="name">Owner name</param>
        /// <param name="timeToLive">Record time to live (TTL)</param>
        /// <param name="priority">Priority of the this target host</param>
        /// <param name="weight">Server selection mechanism</param>
        /// <param name="port">Port on this target host of this service. See <see cref="ServicePorts"/>.</param>
        /// <param name="targetDomainName">Domain name of the target host</param>
        public DnsSRVRecord(DnsZone zone, string name, TimeSpan timeToLive,
                            ushort priority, ushort weight, ushort port, string targetDomainName)
            : base(zone, name, DnsRecordTypes.SRV, DnsRecordClasses.IN, timeToLive)
        {
            var protocolStartIndex = name.IndexOf('.');

            if (protocolStartIndex < 1 || name.IndexOf('.', protocolStartIndex + 1) < 0)
            {
                throw new ArgumentException("The name does not meet RFC2782 requirements for a SRV record", nameof(name));
            }

            if (string.IsNullOrWhiteSpace(targetDomainName))
            {
                throw new ArgumentNullException(nameof(targetDomainName));
            }

            Priority         = priority;
            Weight           = weight;
            Port             = port;
            TargetDomainName = targetDomainName;
        }
コード例 #10
0
        /// <summary>
        /// Constructs a new instance of <see cref="DnsSOARecord"/>.
        /// </summary>
        /// <param name="zone">Associated zone</param>
        /// <param name="name">Owner name</param>
        /// <param name="class">Record class</param>
        /// <param name="timeToLive">Record time to live (TTL)</param>
        /// <param name="primaryServer">Domain Name of the original or primary source of data for this zone</param>
        /// <param name="responsiblePerson">A domain name which specifies the mailbox of the person responsible for this zone</param>
        /// <param name="serial">Version number of the zone</param>
        /// <param name="refreshInterval">Interval before the zone should be refreshed</param>
        /// <param name="retryDelay">Time interval that should elapse before a failed refresh should be retried</param>
        /// <param name="expireLimit">The upper limit on the time interval that can elapse before the zone is no longer authoritative</param>
        /// <param name="minimumTimeToLive">The minimum time-to-live (TTL) that should be exported with an record from this zone</param>
        public DnsSOARecord(DnsZone zone, string name, DnsRecordClasses @class, TimeSpan timeToLive,
                            string primaryServer, string responsiblePerson, uint serial, TimeSpan refreshInterval,
                            TimeSpan retryDelay, TimeSpan expireLimit, TimeSpan minimumTimeToLive)
            : base(zone, name, DnsRecordTypes.SOA, @class, timeToLive)
        {
            if (string.IsNullOrWhiteSpace(primaryServer))
            {
                throw new ArgumentNullException(nameof(primaryServer));
            }
            if (string.IsNullOrWhiteSpace(responsiblePerson))
            {
                throw new ArgumentNullException(nameof(responsiblePerson));
            }
            if (refreshInterval.Ticks < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(refreshInterval));
            }
            if (retryDelay.Ticks < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(retryDelay));
            }
            if (expireLimit.Ticks < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(expireLimit));
            }
            if (minimumTimeToLive.Ticks < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(minimumTimeToLive));
            }

            PrimaryServer     = primaryServer;
            ResponsiblePerson = responsiblePerson;
            Serial            = serial;
            RefreshInterval   = refreshInterval;
            RetryDelay        = retryDelay;
            ExpireLimit       = expireLimit;
            MinimumTimeToLive = minimumTimeToLive;
        }
コード例 #11
0
 /// <summary>
 /// Clones the record associating it with the provided zone
 /// </summary>
 /// <param name="zone">Record associated zone</param>
 /// <returns>A record clone</returns>
 public override DnsRecord Clone(DnsZone zone)
 => new DnsNSRecord(zone, Name, Class, TimeToLive, NameServer);
コード例 #12
0
ファイル: DnsARecord.cs プロジェクト: hyberdk/DnsServerApi
 /// <summary>
 /// Clones the record associating it with the provided zone
 /// </summary>
 /// <param name="zone">Record associated zone</param>
 /// <returns>A record clone</returns>
 public override DnsRecord Clone(DnsZone zone)
 => new DnsARecord(zone, Name, TimeToLive, IpAddress);
コード例 #13
0
 /// <summary>
 /// Constructs a new instance of <see cref="DnsSRVRecord"/>.
 /// </summary>
 /// <param name="zone">Associated zone</param>
 /// <param name="service">Symbolic name of the desired service. See <see cref="ServiceNames"/>.</param>
 /// <param name="protocol">Symbolic name of the desired protocol. See <see cref="ProtocolNames"/>.</param>
 /// <param name="timeToLive">Record time to live (TTL)</param>
 /// <param name="priority">Priority of the this target host</param>
 /// <param name="weight">Server selection mechanism</param>
 /// <param name="port">Port on this target host of this service. See <see cref="ServicePorts"/>.</param>
 /// <param name="targetDomainName">Domain name of the target host</param>
 public DnsSRVRecord(DnsZone zone, string service, string protocol, TimeSpan timeToLive,
                     ushort priority, ushort weight, ushort port, string targetDomainName)
     : this(zone, $"{service}.{protocol}.{zone.DomainName}", timeToLive, priority, weight, port, targetDomainName)
 {
 }
コード例 #14
0
 /// <summary>
 /// Clones the record associating it with the provided zone
 /// </summary>
 /// <param name="zone">Record associated zone</param>
 /// <returns>A record clone</returns>
 public override DnsRecord Clone(DnsZone zone)
 => new DnsSRVRecord(zone, Name, TimeToLive, Priority, Weight, Port, TargetDomainName);
コード例 #15
0
ファイル: DnsRecord.cs プロジェクト: hyberdk/DnsServerApi
 /// <summary>
 /// Clones the record associating it with the provided zone
 /// </summary>
 /// <param name="zone">Record associated zone</param>
 /// <returns>A record clone</returns>
 public abstract DnsRecord Clone(DnsZone zone);
コード例 #16
0
 /// <summary>
 /// Remove a DNS Zone
 /// </summary>
 /// <param name="zone">Zone to be removed</param>
 public abstract void DeleteZone(DnsZone zone);
コード例 #17
0
 /// <summary>
 /// Clones the record associating it with the provided zone
 /// </summary>
 /// <param name="zone">Record associated zone</param>
 /// <returns>A record clone</returns>
 public override DnsRecord Clone(DnsZone zone)
 => new DnsPTRRecord(zone, Name, Class, TimeToLive, DomainName);
コード例 #18
0
 /// <summary>
 /// Adds a DNS Zone to this server
 /// </summary>
 /// <param name="zoneTemplate">Template of zone to be added</param>
 /// <returns></returns>
 public abstract DnsZone CreateZone(DnsZone zoneTemplate);
コード例 #19
0
 /// <summary>
 /// Clones the record associating it with the provided zone
 /// </summary>
 /// <param name="zone">Record associated zone</param>
 /// <returns>A record clone</returns>
 public override DnsRecord Clone(DnsZone zone)
 => new DnsSOARecord(zone, Name, Class, TimeToLive, PrimaryServer, ResponsiblePerson, Serial, RefreshInterval, RetryDelay, ExpireLimit, MinimumTimeToLive);
コード例 #20
0
ファイル: DnsARecord.cs プロジェクト: hyberdk/DnsServerApi
 /// <summary>
 /// Constructs a new instance of <see cref="DnsARecord"/>.
 /// </summary>
 /// <param name="zone">Associated zone</param>
 /// <param name="name">Owner name</param>
 /// <param name="timeToLive">Record time to live (TTL)</param>
 /// <param name="ipAddress">IP address of the Host (A) record</param>
 public DnsARecord(DnsZone zone, string name, TimeSpan timeToLive, DnsIpAddress ipAddress)
     : base(zone, name, DnsRecordTypes.A, DnsRecordClasses.IN, timeToLive)
 {
     IpAddress = ipAddress;
 }
コード例 #21
0
 /// <summary>
 /// Clones the record associating it with the provided zone
 /// </summary>
 /// <param name="zone">Record associated zone</param>
 /// <returns>A record clone</returns>
 public override DnsRecord Clone(DnsZone zone)
 => new DnsCNAMERecord(zone, Name, Class, TimeToLive, PrimaryName);
コード例 #22
0
ファイル: DnsMXRecord.cs プロジェクト: hyberdk/DnsServerApi
 /// <summary>
 /// Clones the record associating it with the provided zone
 /// </summary>
 /// <param name="zone">Record associated zone</param>
 /// <returns>A record clone</returns>
 public override DnsRecord Clone(DnsZone zone)
 => new DnsMXRecord(zone, Name, Class, TimeToLive, Preference, DomainName);