Esempio n. 1
0
        private AuthZone CreateEmptyZone(AuthZoneInfo zoneInfo)
        {
            AuthZone zone;

            switch (zoneInfo.Type)
            {
            case AuthZoneType.Primary:
                zone = new PrimaryZone(_dnsServer, zoneInfo);
                break;

            case AuthZoneType.Secondary:
                zone = new SecondaryZone(_dnsServer, zoneInfo);
                break;

            case AuthZoneType.Stub:
                zone = new StubZone(_dnsServer, zoneInfo);
                break;

            case AuthZoneType.Forwarder:
                zone = new ForwarderZone(zoneInfo);
                break;

            default:
                throw new InvalidDataException("DNS zone type not supported.");
            }

            if (_root.TryAdd(zone))
            {
                return(zone);
            }

            throw new DnsServerException("Zone already exists: " + zoneInfo.Name);
        }
Esempio n. 2
0
        public AuthZoneInfo CreateStubZone(string domain, string primaryNameServerAddresses = null)
        {
            AuthZone authZone = new StubZone(_dnsServer, domain, primaryNameServerAddresses);

            if (_root.TryAdd(authZone))
            {
                (authZone as StubZone).RefreshZone();
                return(new AuthZoneInfo(authZone));
            }

            return(null);
        }
Esempio n. 3
0
        public async Task <AuthZoneInfo> CreateStubZoneAsync(string domain, string primaryNameServerAddresses = null)
        {
            AuthZone authZone = await StubZone.CreateAsync(_dnsServer, domain, primaryNameServerAddresses);

            if (_root.TryAdd(authZone))
            {
                (authZone as StubZone).RefreshZone();
                return(new AuthZoneInfo(authZone));
            }

            if (_root.TryGet(domain, out AuthZone existingZone) && (existingZone is SubDomainZone))
            {
                _root[domain] = authZone;
                (authZone as StubZone).RefreshZone();
                return(new AuthZoneInfo(authZone));
            }

            return(null);
        }