private static void ReadConfig(string path) { Console.WriteLine(@"------Read Config-------"); string jSrt = File.ReadAllText(path); JsonValue configJson = Json.Parse(jSrt); ADnsSetting.ListenIp = jSrt.Contains("Listen") ? IPAddress.Parse(configJson.AsObjectGetString("Listen")) : IPAddress.Any; ADnsSetting.BlackListEnable = jSrt.Contains("BlackList") && configJson.AsObjectGetBool("BlackList"); ADnsSetting.ChinaListEnable = jSrt.Contains("ChinaList") && configJson.AsObjectGetBool("ChinaList"); ADnsSetting.WhiteListEnable = jSrt.Contains("RewriteList") && configJson.AsObjectGetBool("RewriteList"); ADnsSetting.ProxyEnable = jSrt.Contains("ProxyEnable") && configJson.AsObjectGetBool("ProxyEnable"); ADnsSetting.IPv6Enable = !jSrt.Contains("IPv6Enable") || configJson.AsObjectGetBool("IPv6Enable"); ADnsSetting.AllowSelfSignedCert = jSrt.Contains("AllowSelfSignedCert") && configJson.AsObjectGetBool("AllowSelfSignedCert"); ADnsSetting.TlsVersion = jSrt.Contains("TlsVersion") ? configJson.AsObjectGetFloat("Listen") : 0; ADnsSetting.EDnsCustomize = jSrt.Contains("EDnsCustomize") && configJson.AsObjectGetBool("EDnsCustomize"); ADnsSetting.DebugLog = jSrt.Contains("DebugLog") && configJson.AsObjectGetBool("DebugLog"); ADnsSetting.EDnsIp = jSrt.Contains("EDnsClientIp") ? IPAddress.Parse(configJson.AsObjectGetString("EDnsClientIp")) : IPAddress.Any; if (jSrt.Contains("HttpsDns")) { ADnsSetting.HttpsDnsUrl = configJson.AsObjectGetString("HttpsDns"); if (string.IsNullOrEmpty(ADnsSetting.HttpsDnsUrl)) { ADnsSetting.HttpsDnsUrl = "https://1.0.0.1/dns-query"; } } else { ADnsSetting.HttpsDnsUrl = "https://1.0.0.1/dns-query"; } Console.WriteLine(@"Listen : " + ADnsSetting.ListenIp); Console.WriteLine(@"BlackList : " + ADnsSetting.BlackListEnable); Console.WriteLine(@"RewriteList : " + ADnsSetting.WhiteListEnable); Console.WriteLine(@"ChinaList : " + ADnsSetting.ChinaListEnable); Console.WriteLine(@"ProxyEnable : " + ADnsSetting.ProxyEnable); Console.WriteLine(@"IPv6Enable : " + ADnsSetting.IPv6Enable); Console.WriteLine(@"DebugLog : " + ADnsSetting.DebugLog); Console.WriteLine(@"EDnsClient : " + ADnsSetting.EDnsIp); Console.WriteLine(@"HttpsDns : " + ADnsSetting.HttpsDnsUrl); Console.WriteLine(@"EDnsCustomize : " + ADnsSetting.EDnsCustomize); if (ADnsSetting.AllowSelfSignedCert) { Console.WriteLine(@"AllowSelfSignedCert : " + ADnsSetting.AllowSelfSignedCert); } if (ADnsSetting.TlsVersion != 0) { Console.WriteLine(@"TlsVersion : " + ADnsSetting.TlsVersion); } if (ADnsSetting.ProxyEnable) { ADnsSetting.WProxy = new WebProxy(configJson.AsObjectGetString("Proxy")); Console.WriteLine(@"ProxyServer : " + configJson.AsObjectGetString("Proxy")); } }