コード例 #1
0
        private void LoadEnvironmentSettings()
        {
            var logEnabled = _envVarReader.Get(EnvVars.LOG_ENABLED) ?? "true";

            if (Convert.ToBoolean(logEnabled))
            {
                _dnsServer.LogManager = _log;
            }

            var logQueryEnabled = _envVarReader.Get(EnvVars.LOG_QUERY_ENABLED) ?? "true";

            if (Convert.ToBoolean(logQueryEnabled))
            {
                _dnsServer.QueryLogManager = _log;
            }

            var ipV6Enabled = _envVarReader.Get(EnvVars.IPV6_ENABLED) ?? "true";
            var ipAddresses = new List <IPAddress> {
                IPAddress.Any
            };

            if (Convert.ToBoolean(ipV6Enabled))
            {
                ipAddresses.Add(IPAddress.IPv6Any);
            }
            _dnsServer.LocalAddresses = ipAddresses.ToArray();
        }
コード例 #2
0
        public Configs Load()
        {
            var configs = new Configs();
            var port    = _reader.Get(EnvVars.Port);

            if (!string.IsNullOrEmpty(port))
            {
                configs.Port = Convert.ToInt32(port);
            }

            return(configs);
        }
コード例 #3
0
        public DnsService(IEnvVarReader envVarReader)
        {
            ServerDomain = Environment.MachineName.ToLower();

            _log = new LogManager();

            _envVarReader = envVarReader;

            Assembly     assembly     = Assembly.GetEntryAssembly();
            AssemblyName assemblyName = assembly.GetName();

            _appName = assemblyName.Name;

            _currentVersion = assemblyName.Version.ToString();
            var configFolder = _envVarReader.Get(EnvVars.CONFIG_FOLDER);

            ConfigFolder = configFolder;

            if (ConfigFolder == null)
            {
                var appFolder = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
                ConfigFolder = Path.Combine(appFolder, _appName);
            }

            if (!Directory.Exists(ConfigFolder))
            {
                Directory.CreateDirectory(ConfigFolder);
            }

            string blockListsFolder = Path.Combine(ConfigFolder, "blocklists");

            if (!Directory.Exists(blockListsFolder))
            {
                Directory.CreateDirectory(blockListsFolder);
            }
        }