Skip to content

Commit

Permalink
域名测速优先级排序
Browse files Browse the repository at this point in the history
  • Loading branch information
xljiulang committed Nov 24, 2021
1 parent 2f9827a commit 5d01a7d
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion FastGithub.DomainResolve/DomainResolveHostedService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ protected override async Task ExecuteAsync(CancellationToken stoppingToken)

while (stoppingToken.IsCancellationRequested == false)
{
await this.domainResolver.TestAllEndPointsAsync(stoppingToken);
await this.domainResolver.TestSpeedAsync(stoppingToken);
await Task.Delay(this.testPeriodTimeSpan, stoppingToken);
}
}
Expand Down
6 changes: 3 additions & 3 deletions FastGithub.DomainResolve/DomainResolver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public DomainResolver(
{
this.dnsEndPointAddress.TryAdd(endPoint, Array.Empty<IPAddress>());
}
}
}

/// <summary>
/// 解析域名
Expand Down Expand Up @@ -79,9 +79,9 @@ public async IAsyncEnumerable<IPAddress> ResolveAsync(DnsEndPoint endPoint, [Enu
/// </summary>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public async Task TestAllEndPointsAsync(CancellationToken cancellationToken)
public async Task TestSpeedAsync(CancellationToken cancellationToken)
{
foreach (var keyValue in this.dnsEndPointAddress)
foreach (var keyValue in this.dnsEndPointAddress.OrderBy(item => item.Value.Length))
{
var dnsEndPoint = keyValue.Key;
var oldAddresses = keyValue.Value;
Expand Down
2 changes: 1 addition & 1 deletion FastGithub.DomainResolve/IDomainResolver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ public interface IDomainResolver
/// </summary>
/// <param name="cancellationToken"></param>
/// <returns></returns>
Task TestAllEndPointsAsync(CancellationToken cancellationToken = default);
Task TestSpeedAsync(CancellationToken cancellationToken = default);
}
}

0 comments on commit 5d01a7d

Please sign in to comment.