Ejemplo n.º 1
0
        public async Task <IActionResult> GetZones()
        {
            var hostEntry = await Dns.GetHostEntryAsync("infdir1.aaerox.com");

            var address = hostEntry.AddressList.First();

            using (var directoryClient = new DirectoryClient(address))
            {
                var zones = await directoryClient.GetZonesAsync();

                var models = new List <ZoneModel>();

                foreach (var zone in zones)
                {
                    // TODO: use automapper
                    var model = new ZoneModel()
                    {
                        Description   = zone.Description,
                        IsAdvanced    = zone.IsAdvanced,
                        Name          = zone.Name,
                        ServerAddress = zone.ServerAddress.ToString(),
                        ServerPort    = zone.ServerPort
                    };

                    models.Add(model);
                }

                return(this.Ok(models));
            }
        }
Ejemplo n.º 2
0
        public async Task GetZones_ValidServer_ZonesReturned()
        {
            using (var udpClient = new UdpClient())
            {
                var networkClient = new UdpNetworkClient(udpClient);
                var target        = new DirectoryClient(networkClient, IPAddress.Parse("108.61.133.122"));

                var actual = await target.GetZonesAsync();

                Assert.AreNotEqual(0, actual.Count);
            }
        }