public static void ReadConfig(string path) { string configStr = File.ReadAllText(path); JsonValue configJson = Json.Parse(configStr); if (configStr.Contains("\"SecondDns\"")) { SecondDnsIp = IPAddress.Parse(configJson.AsObjectGetString("SecondDns")); } if (configStr.Contains("\"SecondHttpsDns\"")) { SecondHttpsDnsUrl = configJson.AsObjectGetString("SecondHttpsDns"); } ListenIp = IPAddress.Parse(configJson.AsObjectGetString("Listen")); BlackListEnable = configJson.AsObjectGetBool("BlackList"); WhiteListEnable = configJson.AsObjectGetBool("RewriteList"); ProxyEnable = configJson.AsObjectGetBool("ProxyEnable"); EDnsCustomize = configJson.AsObjectGetBool("EDnsCustomize"); DebugLog = configJson.AsObjectGetBool("DebugLog"); HttpsDnsUrl = configJson.AsObjectGetString("HttpsDns").Trim(); if (EDnsCustomize) { EDnsIp = IPAddress.Parse(configJson.AsObjectGetString("EDnsClientIp")); } if (ProxyEnable) { WProxy = new WebProxy(configJson.AsObjectGetString("Proxy")); } }
public static void ReadConfig(string path) { string configStr = File.ReadAllText(path); JsonValue configJson = Json.Parse(configStr); if (configStr.Contains("\"SecondDns\"")) { SecondDnsIp = IPAddress.Parse(configJson.AsObjectGetString("SecondDns")); } if (configStr.Contains("\"SecondHttpsDns\"")) { SecondHttpsDnsUrl = configJson.AsObjectGetString("SecondHttpsDns"); } if (configStr.Contains("\"EnableDnsMessage\"")) { DnsMsgEnable = configJson.AsObjectGetBool("EnableDnsMessage"); } if (configStr.Contains("\"EnableDnsCache\"")) { DnsCacheEnable = configJson.AsObjectGetBool("EnableDnsCache"); } if (configStr.Contains("\"EnableHttp2\"")) { Http2Enable = configJson.AsObjectGetBool("EnableHttp2"); } if (configStr.Contains("\"EnableAutoCleanLog\"")) { AutoCleanLogEnable = configJson.AsObjectGetBool("EnableAutoCleanLog"); } if (configStr.Contains("\"Port\"")) { ListenPort = configJson.AsObjectGetInt("Port", 53); } if (configStr.Contains("\"ChinaList\"")) { ChinaListEnable = configJson.AsObjectGetBool("ChinaList"); } ListenIp = IPAddress.Parse(configJson.AsObjectGetString("Listen")); BlackListEnable = configJson.AsObjectGetBool("BlackList"); WhiteListEnable = configJson.AsObjectGetBool("RewriteList"); ProxyEnable = configJson.AsObjectGetBool("ProxyEnable"); EDnsCustomize = configJson.AsObjectGetBool("EDnsCustomize"); DebugLog = configJson.AsObjectGetBool("DebugLog"); HttpsDnsUrl = configJson.AsObjectGetString("HttpsDns").Trim(); if (EDnsCustomize) { EDnsIp = IPAddress.Parse(configJson.AsObjectGetString("EDnsClientIp")); } if (ProxyEnable) { WProxy = new WebProxy(configJson.AsObjectGetString("Proxy")); } }
public static void ReadConfig(string path) { string configStr = File.ReadAllText(path); JsonValue configJson = Json.Parse(configStr); if (configStr.Contains("\"SecondDns\"")) { SecondDnsIp = IPAddress.Parse(configJson.AsObjectGetString("SecondDns")); } if (configStr.Contains("\"SecondHttpsDns\"")) { SecondHttpsDnsUrl = configJson.AsObjectGetString("SecondHttpsDns"); } if (configStr.Contains("\"EnableDnsMessage\"")) { DnsMsgEnable = configJson.AsObjectGetBool("EnableDnsMessage"); } if (configStr.Contains("\"EnableDnsCache\"")) { DnsCacheEnable = configJson.AsObjectGetBool("EnableDnsCache"); } if (configStr.Contains("\"EnableHttp2\"")) { Http2Enable = configJson.AsObjectGetBool("EnableHttp2"); } if (configStr.Contains("\"EnableAutoCleanLog\"")) { AutoCleanLogEnable = configJson.AsObjectGetBool("EnableAutoCleanLog"); } if (configStr.Contains("\"Port\"")) { ListenPort = configJson.AsObjectGetInt("Port", 53); } if (configStr.Contains("\"ChinaList\"")) { ChinaListEnable = configJson.AsObjectGetBool("ChinaList"); } if (configStr.Contains("\"StartupOverDoH\"")) { StartupOverDoH = configJson.AsObjectGetBool("StartupOverDoH"); } if (configStr.Contains("\"AllowSelfSignedCert\"")) { AllowSelfSignedCert = configJson.AsObjectGetBool("AllowSelfSignedCert"); } if (configStr.Contains("\"AllowAutoRedirect\"")) { AllowAutoRedirect = configJson.AsObjectGetBool("AllowAutoRedirect"); } if (configStr.Contains("\"HTTPStatusNotify\"")) { HTTPStatusNotify = configJson.AsObjectGetBool("HTTPStatusNotify"); } if (configStr.Contains("\"Ipv6Disable\"")) { Ipv6Disable = configJson.AsObjectGetBool("Ipv6Disable"); } if (configStr.Contains("\"Ipv4Disable\"")) { Ipv4Disable = configJson.AsObjectGetBool("Ipv4Disable"); } if (configStr.Contains("\"TTLRewrite\"")) { TtlRewrite = configJson.AsObjectGetBool("TTLRewrite"); } if (configStr.Contains("\"TTLMinTime\"")) { TtlMinTime = configJson.AsObjectGetInt("TTLMinTime"); } ListenIp = IPAddress.Parse(configJson.AsObjectGetString("Listen")); BlackListEnable = configJson.AsObjectGetBool("BlackList"); WhiteListEnable = configJson.AsObjectGetBool("RewriteList"); ProxyEnable = configJson.AsObjectGetBool("ProxyEnable"); EDnsCustomize = configJson.AsObjectGetBool("EDnsCustomize"); DebugLog = configJson.AsObjectGetBool("DebugLog"); HttpsDnsUrl = configJson.AsObjectGetString("HttpsDns").Trim(); if (EDnsCustomize) { EDnsIp = IPAddress.Parse(configJson.AsObjectGetString("EDnsClientIp")); } if (ProxyEnable) { WProxy = new WebProxy(configJson.AsObjectGetString("Proxy")); } }
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.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 (configJson.ToString().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.WhiteListEnable); Console.WriteLine(@"ProxyEnable : " + ADnsSetting.ProxyEnable); Console.WriteLine(@"DebugLog : " + ADnsSetting.DebugLog); Console.WriteLine(@"EDnsPrivacy : " + ADnsSetting.EDnsCustomize); Console.WriteLine(@"EDnsClient : " + ADnsSetting.EDnsIp); Console.WriteLine(@"HttpsDns : " + ADnsSetting.HttpsDnsUrl); if (ADnsSetting.AllowSelfSignedCert) { Console.WriteLine(@"AllowSelfSignedCert : " + ADnsSetting.AllowSelfSignedCert); } if (ADnsSetting.ProxyEnable) { ADnsSetting.WProxy = new WebProxy(configJson.AsObjectGetString("Proxy")); Console.WriteLine(@"ProxyServer : " + configJson.AsObjectGetString("Proxy")); } }
private static void ReadConfig(string path) { Console.WriteLine(@"------Read Config-------"); JsonValue configJson = Json.Parse(File.ReadAllText(path)); try { ADnsSetting.ListenIp = IPAddress.Parse(configJson.AsObjectGetString("Listen")); } catch { ADnsSetting.ListenIp = IPAddress.Any; } try { ADnsSetting.BlackListEnable = configJson.AsObjectGetBool("BlackList"); } catch { ADnsSetting.BlackListEnable = false; } try { ADnsSetting.WhiteListEnable = configJson.AsObjectGetBool("RewriteList"); } catch { ADnsSetting.WhiteListEnable = false; } try { ADnsSetting.ProxyEnable = configJson.AsObjectGetBool("ProxyEnable"); } catch { ADnsSetting.ProxyEnable = false; } try { ADnsSetting.IPv6Enable = configJson.AsObjectGetBool("IPv6Enable"); } catch { ADnsSetting.IPv6Enable = true; } try { ADnsSetting.EDnsCustomize = configJson.AsObjectGetBool("EDnsCustomize"); } catch { ADnsSetting.EDnsCustomize = false; } try { ADnsSetting.DebugLog = configJson.AsObjectGetBool("DebugLog"); } catch { ADnsSetting.DebugLog = false; } try { ADnsSetting.EDnsIp = IPAddress.Parse(configJson.AsObjectGetString("EDnsClient")); } catch { ADnsSetting.EDnsIp = IPAddress.Any; } try { ADnsSetting.HttpsDnsUrl = configJson.AsObjectGetString("HttpsDns"); if (string.IsNullOrEmpty(ADnsSetting.HttpsDnsUrl)) { ADnsSetting.HttpsDnsUrl = "https://1.0.0.1/dns-query"; } } catch { 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(@"ProxyEnable : " + ADnsSetting.ProxyEnable); Console.WriteLine(@"DebugLog : " + ADnsSetting.DebugLog); Console.WriteLine(@"EDnsPrivacy : " + ADnsSetting.EDnsCustomize); Console.WriteLine(@"EDnsClient : " + ADnsSetting.EDnsIp); Console.WriteLine(@"HttpsDns : " + ADnsSetting.HttpsDnsUrl); if (ADnsSetting.ProxyEnable) { ADnsSetting.WProxy = new WebProxy(configJson.AsObjectGetString("Proxy")); Console.WriteLine(@"ProxyServer : " + configJson.AsObjectGetString("Proxy")); } }