示例#1
0
        public static DNSServerModel FromServer(DNSManagement.Server server)
        {
            var model = new DNSServerModel();

            model.ServerName         = server.Name;
            model.ServerIPAddresses  = server.ServerAddresses;
            model.ListenAddresses    = server.ListenAddresses;
            model.Forwarders         = ResolvedServer.FromIPs(server.Forwarders);
            model.IsSlave            = server.IsSlave;
            model.Version            = server.Version.ToString();
            model.NoRecursion        = server.NoRecursion;
            model.BindSecondaries    = server.BindSecondaries;
            model.StrictFileParsing  = server.StrictFileParsing;
            model.RoundRobin         = server.RoundRobin;
            model.LocalNetPriority   = server.LocalNetPriority;
            model.SecureResponses    = server.SecureResponses;
            model.NameCheckFlag      = server.NameCheckFlag;
            model.BootMethod         = server.BootMethod;
            model.ScavengingInterval = server.ScavengingInterval;
            model.LogLevel           = server.LogLevel;
            model.LogIPFilterList    = server.LogIPFilterList;
            model.LogFilePath        = server.LogFilePath;
            model.LogFileMaxSize     = server.LogFileMaxSize;
            model.EventLogLevel      = server.EventLogLevel;

            //convert root hints to list for display
            List <ResolvedServer> roothintslist = new List <ResolvedServer>();
            var rhints = server.GetRootHints();

            foreach (var rh in rhints)
            {
                var records = rh.GetRecords();
                foreach (var r in records.Where(i => i.DomainName == "..RootHints"))
                {
                    if (r.ResourceRecordType != DNSManagement.RR.ResourceRecord.ResourceRecordEnum.NS)
                    {
                        continue;
                    }
                    var ns  = ((DNSManagement.RR.NSType)r.UnderlyingRecord);
                    var nsa = (records.Where(i => i.RecordType == typeof(DNSManagement.RR.AType) && ((DNSManagement.RR.AType)i.UnderlyingRecord).OwnerName == ns.NSHost)).Select(i => ((DNSManagement.RR.AType)i).IPAddress).ToList();
                    nsa.AddRange((records.Where(i => i.RecordType == typeof(DNSManagement.RR.AAAAType) && ((DNSManagement.RR.AAAAType)i.UnderlyingRecord).OwnerName == ns.NSHost)).Select(i => ((DNSManagement.RR.AAAAType)i).IPv6Address).ToArray());


                    roothintslist.Add(new ResolvedServer
                    {
                        ServerName = ns.NSHost,
                        IPAddress  = string.Join(", ", nsa.ToArray())
                    });
                }
            }
            model.RootHints = roothintslist.ToArray();

            return(model);
        }
示例#2
0
        public static DNSServerModel FromServer(DNSManagement.Server server)
        {
            var model = new DNSServerModel();
            model.ServerName = server.Name;
            model.ServerIPAddresses = server.ServerAddresses;
            model.ListenAddresses = server.ListenAddresses;
            model.Forwarders = ResolvedServer.FromIPs(server.Forwarders);
            model.IsSlave = server.IsSlave;
            model.Version = server.Version.ToString();
            model.NoRecursion = server.NoRecursion;
            model.BindSecondaries = server.BindSecondaries;
            model.StrictFileParsing = server.StrictFileParsing;
            model.RoundRobin = server.RoundRobin;
            model.LocalNetPriority = server.LocalNetPriority;
            model.SecureResponses = server.SecureResponses;
            model.NameCheckFlag = server.NameCheckFlag;
            model.BootMethod = server.BootMethod;
            model.ScavengingInterval = server.ScavengingInterval;
            model.LogLevel = server.LogLevel;
            model.LogIPFilterList = server.LogIPFilterList;
            model.LogFilePath = server.LogFilePath;
            model.LogFileMaxSize = server.LogFileMaxSize;
            model.EventLogLevel = server.EventLogLevel;

            //convert root hints to list for display
            List<ResolvedServer> roothintslist = new List<ResolvedServer>();
            var rhints = server.GetRootHints();
            foreach (var rh in rhints)
            {
                var records = rh.GetRecords();
                foreach (var r in records.Where(i => i.DomainName == "..RootHints"))
                {
                    if (r.ResourceRecordType != DNSManagement.RR.ResourceRecord.ResourceRecordEnum.NS)
                        continue;
                    var ns = ((DNSManagement.RR.NSType)r.UnderlyingRecord);
                    var nsa = (records.Where(i=>i.RecordType == typeof(DNSManagement.RR.AType) && ((DNSManagement.RR.AType)i.UnderlyingRecord).OwnerName == ns.NSHost)).Select(i=>((DNSManagement.RR.AType)i).IPAddress).ToList();
                    nsa.AddRange((records.Where(i => i.RecordType == typeof(DNSManagement.RR.AAAAType) && ((DNSManagement.RR.AAAAType)i.UnderlyingRecord).OwnerName == ns.NSHost)).Select(i=>((DNSManagement.RR.AAAAType)i).IPv6Address).ToArray());

                    roothintslist.Add(new ResolvedServer
                    {
                        ServerName = ns.NSHost,
                        IPAddress = string.Join(", ", nsa.ToArray())
                    });
                }
            }
            model.RootHints = roothintslist.ToArray();

            return model;
        }