예제 #1
0
 private protected DnsRecord(DnsRecordId id, DomainName name, DomainId parentDomainId, TimeToLive timeToLive, RecordSource recordSource = default, GlobalTrafficDirectorLocation?globalTrafficDirectorLocation = null)
 {
     Id             = id;
     Name           = name;
     Source         = recordSource;
     ParentDomainId = parentDomainId;
     TimeToLive     = timeToLive;
     GlobalTrafficDirectorLocation = globalTrafficDirectorLocation;
 }
예제 #2
0
 private protected DnsRecord(DnsRecordId id, DomainName name, RecordSource source, DomainId sourceId, TimeToLive ttl, GlobalTrafficDirectorLocation?gtdLocation)
 {
     Id             = id;
     Name           = name;
     Source         = source;
     ParentDomainId = sourceId;
     TimeToLive     = ttl;
     GlobalTrafficDirectorLocation = gtdLocation;
 }
예제 #3
0
        public DnsRecords CreateCNameRecord(DomainName name, DomainName target, TimeToLive timeToLive, GlobalTrafficDirectorLocation globalTrafficDirectorLocation = default)
        {
            if (!name.IsSubdomainOf(ParentDomain))
            {
                throw new ArgumentException($"The specified domain `{name}` is not a subdomain of the parent `{ParentDomain}`", nameof(name));
            }

            return(AddCreate(new
            {
                type = "CNAME",
                name = name.WithoutParent(ParentDomain),
                value = target.IsSubdomainOf(ParentDomain)
                                                                ? target.WithoutParent(ParentDomain)
                                                                : target + ".",
                ttl = timeToLive,
                gtdLocation = globalTrafficDirectorLocation
            }));
        }
예제 #4
0
        public DnsRecords CreateARecord(DomainName name, IPv4 target, TimeToLive timeToLive, string?dynamicDnsPassword = null, GlobalTrafficDirectorLocation globalTrafficDirectorLocation = default, bool isSystemMonitoringEnabled = false, bool isFailoverEnabled = false)
        {
            if (!name.IsSubdomainOf(ParentDomain))
            {
                throw new ArgumentException($"The specified domain `{name}` is not a subdomain of the parent `{ParentDomain}`", nameof(name));
            }

            return(AddCreate(new
            {
                type = "A",
                name = name.WithoutParent(ParentDomain),
                value = target,
                ttl = timeToLive,
                dynamicDns = dynamicDnsPassword != null,
                password = dynamicDnsPassword,
                gtdLocation = globalTrafficDirectorLocation,
                monitor = isSystemMonitoringEnabled,
                failover = isFailoverEnabled
            }));
        }
예제 #5
0
        public DnsRecords CreateTXTRecord(DomainName name, string value, TimeToLive timeToLive, GlobalTrafficDirectorLocation globalTrafficDirectorLocation = default)
        {
            if (!name.IsSubdomainOf(ParentDomain))
            {
                throw new ArgumentException($"The specified domain `{name}` is not a subdomain of the parent `{ParentDomain}`", nameof(name));
            }

            if (string.IsNullOrEmpty(value))
            {
                throw new ArgumentException("TXT record value cannot be empty or null");
            }

            return(AddCreate(new
            {
                type = "TXT",
                name = name.WithoutParent(ParentDomain),
                value,
                ttl = timeToLive,
                gtdLocation = globalTrafficDirectorLocation
            }));
        }
예제 #6
0
 public SRVRecord(Priority priority, Weight weight, Port port, DomainName target, DnsRecordId id, DomainName name, DomainId parentDomainId, TimeToLive timeToLive, RecordSource recordSource = default, GlobalTrafficDirectorLocation?globalTrafficDirectorLocation = null) : base(id, name, parentDomainId, timeToLive, recordSource, globalTrafficDirectorLocation)
 {
     Priority = priority;
     Weight   = weight;
     Port     = port;
     Target   = target;
     Service  = name.Labels[0] !;
     Protocol = name.Labels[1] !;
 }
예제 #7
0
 internal ANameRecord(string value, DnsRecordId id, DomainName name, RecordSource source, DomainId sourceId, TimeToLive ttl, GlobalTrafficDirectorLocation?gtdLocation) : base(id, name, source, sourceId, ttl, gtdLocation)
 {
     if (DomainName.TryParse(value, out var domainName))
     {
         TargetDomain          = domainName;
         TargetDomainWasRooted = value.EndsWith(".", StringComparison.OrdinalIgnoreCase);
     }
     else if (IPv4.TryParse(value, out var ipv4))
     {
         TargetIPv4 = ipv4;
     }
     else if (IPv6.TryParse(value, out var ipv6))
     {
         TargetIpv6 = ipv6;
     }
     else
     {
         throw new FormatException($"Unrecognised value for an ANAME record: `{value}`. Expecting a domain name, IPv4 or IPv6 address.");
     }
 }
예제 #8
0
 public ANameRecord(IPv6 targetIpv6, DnsRecordId id, DomainName name, DomainId parentDomainId, TimeToLive timeToLive, RecordSource recordSource = default, GlobalTrafficDirectorLocation?globalTrafficDirectorLocation = null) : base(id, name, parentDomainId, timeToLive, recordSource, globalTrafficDirectorLocation)
 {
     TargetIpv6 = targetIpv6;
 }
예제 #9
0
        public async Task CreateARecord(DomainId parentDomainId, DomainName name, IPv4 target, TimeToLive timeToLive, string?dynamicDnsPassword = null, GlobalTrafficDirectorLocation globalTrafficDirectorLocation = default, bool isSystemMonitoringEnabled = false, bool isFailoverEnabled = false, CancellationToken cancellationToken = default)
        {
            var parentDomain = await DomainCache.EnsureAndGet(parentDomainId, cancellationToken).ConfigureAwait(false);

            if (!name.IsSubdomainOf(parentDomain))
            {
                throw new ArgumentException($"The specified domain `{name}` is not a subdomain of the parent `{parentDomain}`", nameof(name));
            }

            await Post($"dns/managed/{parentDomainId}/records", new
            {
                type        = "A",
                name        = name.WithoutParent(parentDomain),
                value       = target,
                ttl         = timeToLive,
                dynamicDns  = dynamicDnsPassword != null,
                password    = dynamicDnsPassword,
                gtdLocation = globalTrafficDirectorLocation,
                monitor     = isSystemMonitoringEnabled,
                failover    = isFailoverEnabled
            }, cancellationToken).ConfigureAwait(false);
        }
예제 #10
0
 internal TXTRecord(DnsRecordId id, DomainName name, RecordSource source, DomainId sourceId, TimeToLive ttl, GlobalTrafficDirectorLocation?gtdLocation, string value) : base(id, name, source, sourceId, ttl, gtdLocation)
 {
     Value = value[0] == '"'
                         ? value.Substring(1, value.Length - 2)
                         : value;
 }
예제 #11
0
 internal NSRecord(DnsRecordId id, DomainName name, RecordSource source, DomainId sourceId, TimeToLive ttl, GlobalTrafficDirectorLocation?gtdLocation, string value) : base(id, name, source, sourceId, ttl, gtdLocation)
 {
     NameServer          = DomainName.Parse(value);
     NameServerWasRooted = value.EndsWith(".", StringComparison.OrdinalIgnoreCase);
 }
예제 #12
0
 public ARecord(IPv4 target, DnsRecordId id, DomainName name, DomainId parentDomainId, TimeToLive timeToLive, RecordSource recordSource = default, bool isDynamicDnsEnabled = false, string?dynamicDnsPassword = null, GlobalTrafficDirectorLocation?globalTrafficDirectorLocation = null, bool isSystemMonitoringEnabled = false, bool isFailoverEnabled = false, bool isInFailedState = false) : base(id, name, parentDomainId, timeToLive, recordSource, globalTrafficDirectorLocation)
 {
     Target = target;
     IsDynamicDnsEnabled       = isDynamicDnsEnabled;
     DynamicDnsPassword        = dynamicDnsPassword;
     IsSystemMonitoringEnabled = isSystemMonitoringEnabled;
     IsFailoverEnabled         = isFailoverEnabled;
     IsInFailedState           = isInFailedState;
 }
예제 #13
0
 internal AAAARecord(DnsRecordId id, DomainName name, DomainId sourceId, TimeToLive ttl, RecordSource source, GlobalTrafficDirectorLocation?gtdLocation, IPv6 value) : base(id, name, source, sourceId, ttl, gtdLocation)
 {
     Target = value;
 }
예제 #14
0
 public MXRecord(MxLevel mxLevel, DomainName target, DnsRecordId id, DomainName name, DomainId parentDomainId, TimeToLive timeToLive, RecordSource recordSource = default, GlobalTrafficDirectorLocation?globalTrafficDirectorLocation = null) : base(id, name, parentDomainId, timeToLive, recordSource, globalTrafficDirectorLocation)
 {
     MxLevel = mxLevel;
     Target  = target;
 }
예제 #15
0
 internal MXRecord(DnsRecordId id, DomainName name, RecordSource source, DomainId sourceId, TimeToLive ttl, GlobalTrafficDirectorLocation?gtdLocation, MxLevel mxLevel, string value) : base(id, name, source, sourceId, ttl, gtdLocation)
 {
     MxLevel         = mxLevel;
     Target          = DomainName.Parse(value);
     TargetWasRooted = value.EndsWith(".", StringComparison.OrdinalIgnoreCase);
 }
예제 #16
0
 public SPFRecord(string value, DnsRecordId id, DomainName name, DomainId parentDomainId, TimeToLive timeToLive, RecordSource recordSource = default, GlobalTrafficDirectorLocation?globalTrafficDirectorLocation = null) : base(id, name, parentDomainId, timeToLive, recordSource, globalTrafficDirectorLocation)
 {
     Value = value;
 }
예제 #17
0
 internal SPFRecord(DnsRecordId id, DomainName name, RecordSource source, DomainId sourceId, TimeToLive ttl, GlobalTrafficDirectorLocation?gtdLocation, string value) : base(id, name, source, sourceId, ttl, gtdLocation)
 {
     Value = value;
 }
예제 #18
0
 public NSRecord(DomainName nameServer, DnsRecordId id, DomainName name, DomainId parentDomainId, TimeToLive timeToLive, RecordSource recordSource = default, GlobalTrafficDirectorLocation?globalTrafficDirectorLocation = null) : base(id, name, parentDomainId, timeToLive, recordSource, globalTrafficDirectorLocation)
 {
     NameServer = nameServer;
 }
예제 #19
0
 internal SRVRecord(DnsRecordId id, DomainName name, RecordSource source, DomainId sourceId, TimeToLive ttl, GlobalTrafficDirectorLocation?gtdLocation, Priority priority, Weight weight, Port port, string value) : base(id, name, source, sourceId, ttl, gtdLocation)
 {
     Priority        = priority;
     Weight          = weight;
     Port            = port;
     Target          = DomainName.Parse(value);
     TargetWasRooted = value.EndsWith(".", StringComparison.OrdinalIgnoreCase);
     Service         = name.Labels[0] !;
     Protocol        = name.Labels[1] !;
 }
예제 #20
0
 internal ARecord(IPv4 value, DnsRecordId id, DomainName name, DomainId sourceId, TimeToLive ttl, bool monitor, bool failover, bool failed, bool dynamicDns, RecordSource source, string?password, GlobalTrafficDirectorLocation?gtdLocation) : base(id, name, source, sourceId, ttl, gtdLocation)
 {
     Target = value;
     IsDynamicDnsEnabled       = dynamicDns;
     DynamicDnsPassword        = password;
     IsSystemMonitoringEnabled = monitor;
     IsFailoverEnabled         = failover;
     IsInFailedState           = failed;
 }
예제 #21
0
 internal HttpRedirectionRecord(DnsRecordId id, DomainName name, RecordSource source, DomainId sourceId, TimeToLive ttl, GlobalTrafficDirectorLocation?gtdLocation, Uri value, string description, string keywords, string title, RedirectType redirectType, bool hardLink) : base(id, name, source, sourceId, ttl, gtdLocation)
 {
     Url          = value;
     Description  = description;
     Keywords     = keywords;
     Title        = title;
     RedirectType = redirectType;
     IsHardLink   = hardLink;
 }
예제 #22
0
        public async Task CreateTXTRecord(DomainId parentDomainId, DomainName name, string value, TimeToLive timeToLive, GlobalTrafficDirectorLocation globalTrafficDirectorLocation = default, CancellationToken cancellationToken = default)
        {
            var parentDomain = await DomainCache.EnsureAndGet(parentDomainId, cancellationToken).ConfigureAwait(false);

            if (!name.IsSubdomainOf(parentDomain))
            {
                throw new ArgumentException($"The specified domain `{name}` is not a subdomain of the parent `{parentDomain}`", nameof(name));
            }

            await Post($"dns/managed/{parentDomainId}/records", new
            {
                type = "TXT",
                name = name.WithoutParent(parentDomain),
                value,
                ttl         = timeToLive,
                gtdLocation = globalTrafficDirectorLocation
            }, cancellationToken).ConfigureAwait(false);
        }
예제 #23
0
 public HttpRedirectionRecord(Uri url, string description, string keywords, string title, RedirectType redirectType, bool isHardLink, DnsRecordId id, DomainName name, DomainId parentDomainId, TimeToLive timeToLive, RecordSource recordSource = default, GlobalTrafficDirectorLocation?globalTrafficDirectorLocation = null) : base(id, name, parentDomainId, timeToLive, recordSource, globalTrafficDirectorLocation)
 {
     Url          = url;
     Description  = description;
     Keywords     = keywords;
     Title        = title;
     RedirectType = redirectType;
     IsHardLink   = isHardLink;
 }