使用8.8.8.8dns服务器
This commit is contained in:
parent
a13aee0c60
commit
94e52b0729
@ -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<string, SemaphoreSlim> 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<IPAddress>();
|
||||
}
|
||||
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<IPAddress>(), this.minTimeToLive);
|
||||
return this.dnsLookupCache.Set(key, Array.Empty<IPAddress>(), this.maxTimeToLive);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
@ -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到多个任意字符
|
||||
|
||||
Loading…
Reference in New Issue
Block a user