예제 #1
0
        async ValueTask <DnsRecord> IDomainCacheUpdatable <DnsRecord> .UpdateFromCache(DomainCache domainCache, CancellationToken cancellationToken)
        {
            var parentDomain = await domainCache.EnsureAndGet(ParentDomainId, cancellationToken).ConfigureAwait(false);

            var newName = parentDomain.WithSubdomain(Name);

            return(UpdateFromCache(newName, parentDomain));
        }
예제 #2
0
        public async IAsyncEnumerable <DnsRecord> GetAllRecords(DomainId domain, DomainName name, [EnumeratorCancellation] CancellationToken cancellationToken = default)
        {
            var parentDomainName = await DomainCache.EnsureAndGet(domain, cancellationToken).ConfigureAwait(false);

            var subDomain = name.WithoutParent(parentDomainName);

            await foreach (var record in Get <DnsRecord>($"dns/managed/{domain}/records?recordName={subDomain}").ProcessDomainCache(DomainCache, cancellationToken).ConfigureAwait(false))
            {
                yield return(record);
            }
        }
예제 #3
0
        public async IAsyncEnumerable <TRecord> GetAllRecords <TRecord>(DomainId domain, DomainName name, [EnumeratorCancellation] CancellationToken cancellationToken = default) where TRecord : DnsRecord
        {
            var type             = GetTypeString <TRecord>();
            var parentDomainName = await DomainCache.EnsureAndGet(domain, cancellationToken).ConfigureAwait(false);

            var subDomain = name.WithoutParent(parentDomainName);

            await foreach (var record in Get <DnsRecord>($"dns/managed/{domain}/records?recordName={subDomain}&type={type}").ProcessDomainCache(DomainCache, cancellationToken).ConfigureAwait(false))
            {
                if (record is not TRecord typedRecord)
                {
                    throw new InvalidOperationException("DNSMadeEasy returned records of the wrong type");
                }

                yield return(typedRecord);
            }
        }
예제 #4
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);
        }
예제 #5
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);
        }
예제 #6
0
        public async ValueTask <DnsRecords> CreateMultiRecordCollection(DomainId domain, CancellationToken cancellationToken = default)
        {
            var domainName = await DomainCache.EnsureAndGet(domain, cancellationToken).ConfigureAwait(false);

            return(new DnsRecords(domain, domainName));
        }