Kaynağa Gözat

修改Loopback IP缓存

陈国伟 4 yıl önce
ebeveyn
işleme
b69755a1b2
1 değiştirilmiş dosya ile 6 ekleme ve 0 silme
  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,请刷新重试");
             }
 
+            // 往往是被污染的dns
+            if (address.Equals(IPAddress.Loopback) == false)
+            {
+                expiration = TimeSpan.FromSeconds(2d);
+            }
+
             this.logger.LogInformation($"[{endPoint.Host}->{address}]");
             this.memoryCache.Set(endPoint, address, expiration);
             return address;