From f2553e245e7765987beb0cc7b7b94406964604a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=9B=BD=E4=BC=9F?= <366193849@qq.com> Date: Thu, 18 Nov 2021 14:16:28 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BD=BF=E7=94=A8timeToLive=E5=B9=B3=E5=9D=87?= =?UTF-8?q?=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- FastGithub.DomainResolve/DnsClient.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/FastGithub.DomainResolve/DnsClient.cs b/FastGithub.DomainResolve/DnsClient.cs index 72177b7..63312ff 100644 --- a/FastGithub.DomainResolve/DnsClient.cs +++ b/FastGithub.DomainResolve/DnsClient.cs @@ -172,7 +172,13 @@ namespace FastGithub.DomainResolve addresses = await OrderByConnectAnyAsync(addresses, endPoint.Port, cancellationToken); } - var timeToLive = addressRecords.First().TimeToLive; + var totalTimeToLive = TimeSpan.Zero; + foreach (var record in addressRecords) + { + totalTimeToLive = totalTimeToLive.Add(record.TimeToLive); + } + + var timeToLive = totalTimeToLive / addressRecords.Count; if (timeToLive <= TimeSpan.Zero) { timeToLive = this.defaultEmptyTtl;