diff --git a/FastGithub.DomainResolve/DnscryptProxy.cs b/FastGithub.DomainResolve/DnscryptProxy.cs index 853eac1..c986f19 100644 --- a/FastGithub.DomainResolve/DnscryptProxy.cs +++ b/FastGithub.DomainResolve/DnscryptProxy.cs @@ -37,9 +37,7 @@ namespace FastGithub.DomainResolve var tomlPath = Path.Combine(PATH, $"{NAME}.toml"); var port = LocalMachine.GetAvailablePort(IPAddress.Loopback.AddressFamily, min: 5533); var localEndPoint = new IPEndPoint(IPAddress.Loopback, port); - await TomlUtil.SetListensAsync(tomlPath, localEndPoint, cancellationToken); - await TomlUtil.SetEdnsClientSubnetAsync(tomlPath, cancellationToken); foreach (var process in Process.GetProcessesByName(NAME)) { diff --git a/FastGithub.DomainResolve/TomlUtil.cs b/FastGithub.DomainResolve/TomlUtil.cs index dfd8bc4..2b73381 100644 --- a/FastGithub.DomainResolve/TomlUtil.cs +++ b/FastGithub.DomainResolve/TomlUtil.cs @@ -1,10 +1,6 @@ -using FastGithub.Configuration; -using System; -using System.IO; +using System.IO; using System.Net; -using System.Net.Http; using System.Text; -using System.Text.RegularExpressions; using System.Threading; using System.Threading.Tasks; using Tommy; @@ -31,45 +27,6 @@ namespace FastGithub.DomainResolve return SetAsync(tomlPath, "listen_addresses", value, cancellationToken); } - /// - /// 设置ecs - /// - /// - /// - /// - public static async Task SetEdnsClientSubnetAsync(string tomlPath, CancellationToken cancellationToken = default) - { - try - { - var address = await GetPublicIPAddressAsync(cancellationToken); - var value = new TomlArray - { - $"{address}/32" - }; - await SetAsync(tomlPath, "edns_client_subnet", value, cancellationToken); - return true; - } - catch (Exception) - { - return false; - } - } - - /// - /// 获取公网ip - /// - /// - /// - private static async Task GetPublicIPAddressAsync(CancellationToken cancellationToken) - { - using var httpClient = new HttpClient { Timeout = TimeSpan.FromSeconds(3d) }; - var response = await httpClient.GetStringAsync("https://pv.sohu.com/cityjson?ie=utf-8", cancellationToken); - var match = Regex.Match(response, @"\d+\.\d+\.\d+\.\d+"); - return match.Success && IPAddress.TryParse(match.Value, out var address) - ? address - : throw new FastGithubException("无法获取外网ip"); - } - /// /// 设置指定键的值 ///