private void AddSearchDomain(string searchDomain) { try { var dnsZoneProper = Cleaners.MakeDnsZoneProper(searchDomain); SearchDomains.Add(dnsZoneProper); Logger.Debug($"'{dnsZoneProper}' has been added as Domain Name Suffix"); } catch (Exception ex) { Logger.Error($"Could not add Domain Name Suffix", ex); } }
public DnsConfig() { _Config = new ConfigurationBuilder() .AddJsonFile("dns.json", optional: false, reloadOnChange: true) .Build(); var serverAliases = _Config.GetSection("serverAliases"); var dnsServers = _Config.GetSection("dnsServers"); var searchDomains = _Config.GetSection("searchDomains"); var hostOverrides = _Config.GetSection("hostOverrides"); var dnsZones = _Config.GetSection("dnsZones"); var fileZones = _Config.GetSection("fileZones"); var blackLists = _Config.GetSection("blackLists"); if (ConfigSectionArray(dnsServers)) { foreach (var dnsServer in dnsServers.GetChildren()) { AddDnsServer(dnsServer.Value); } } else { DnsServers.Add(Cleaners.MakeDnsIPEndPoint(dnsServers.Value)); } if (ConfigSectionArray(searchDomains)) { foreach (var searchDomain in searchDomains.GetChildren()) { AddSearchDomain(searchDomain.Value); } } else { SearchDomains.Add(Cleaners.MakeDnsZoneProper(searchDomains.Value)); } if (ConfigSectionArray(hostOverrides)) { foreach (var hostOverride in hostOverrides.GetChildren()) { AddHostOverride(hostOverride); } } else { AddHostOverride(hostOverrides.GetChildren().First()); } if (ConfigSectionArray(dnsZones)) { foreach (var dnsZone in dnsZones.GetChildren()) { AddDnsZone(dnsZone); } } else { AddDnsZone(dnsZones); } if (ConfigSectionArray(blackLists)) { foreach (var blackList in blackLists.GetChildren()) { AddBlackList(blackList); } } else { AddBlackList(blackLists); } Logger.Info("Configuration file has been loaded"); }