Browse Source

修改Loopback IP缓存

陈国伟 4 years ago
parent
commit
b69755a1b2
1 changed files with 6 additions and 0 deletions
  1. 6 0
      FastGithub.DomainResolve/DomainResolver.cs

+ 6 - 0
FastGithub.DomainResolve/DomainResolver.cs

@@ -92,6 +92,12 @@ namespace FastGithub.DomainResolve
                 throw new FastGithubException($"当前解析不到{endPoint.Host}可用的ip,请刷新重试");
                 throw new FastGithubException($"当前解析不到{endPoint.Host}可用的ip,请刷新重试");
             }
             }
 
 
+            // 往往是被污染的dns
+            if (address.Equals(IPAddress.Loopback) == false)
+            {
+                expiration = TimeSpan.FromSeconds(2d);
+            }
+
             this.logger.LogInformation($"[{endPoint.Host}->{address}]");
             this.logger.LogInformation($"[{endPoint.Host}->{address}]");
             this.memoryCache.Set(endPoint, address, expiration);
             this.memoryCache.Set(endPoint, address, expiration);
             return address;
             return address;