diff --git a/FastGithub.DomainResolve/DnsClient.cs b/FastGithub.DomainResolve/DnsClient.cs index 3b0a2bf..54911f1 100644 --- a/FastGithub.DomainResolve/DnsClient.cs +++ b/FastGithub.DomainResolve/DnsClient.cs @@ -9,6 +9,7 @@ using Microsoft.Extensions.Options; using System; using System.Collections.Concurrent; using System.Collections.Generic; +using System.IO; using System.Linq; using System.Net; using System.Net.Sockets; @@ -33,7 +34,7 @@ namespace FastGithub.DomainResolve private readonly ConcurrentDictionary semaphoreSlims = new(); private readonly IMemoryCache dnsLookupCache = new MemoryCache(Options.Create(new MemoryCacheOptions())); - private readonly TimeSpan minTimeToLive = TimeSpan.FromSeconds(30d); + private readonly TimeSpan minTimeToLive = TimeSpan.FromMinutes(1d); private readonly TimeSpan maxTimeToLive = TimeSpan.FromMinutes(10d); private readonly int resolveTimeout = (int)TimeSpan.FromSeconds(4d).TotalMilliseconds; @@ -130,10 +131,10 @@ namespace FastGithub.DomainResolve { return Array.Empty(); } - catch (SocketException ex) + catch (IOException ex) when (ex.InnerException is SocketException) { this.logger.LogWarning($"{endPoint.Host}@{dns}->{ex.Message}"); - return this.dnsLookupCache.Set(key, Array.Empty(), this.minTimeToLive); + return this.dnsLookupCache.Set(key, Array.Empty(), this.maxTimeToLive); } catch (Exception ex) { diff --git a/FastGithub/appsettings.json b/FastGithub/appsettings.json index c75cf82..08a200e 100644 --- a/FastGithub/appsettings.json +++ b/FastGithub/appsettings.json @@ -3,8 +3,8 @@ "FastGithub": { "HttpProxyPort": 38457, // http代理端口,linux/osx平台使用 "FallbackDns": [ // 以下dns必须要支持tcp - "114.114.114.114:53", - "119.29.29.29:53" + "8.8.8.8:53", + "114.114.114.114:53" ], "DomainConfigs": { "*.fastgithub.com": { // 域名的*表示除.之外0到多个任意字符