FindBestAddress短路查找
This commit is contained in:
parent
03263598f5
commit
3dc9a7e7b3
@ -1,4 +1,5 @@
|
|||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using Microsoft.Extensions.Options;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
@ -13,6 +14,12 @@ namespace FastGithub.Scanner
|
|||||||
{
|
{
|
||||||
private readonly object syncRoot = new();
|
private readonly object syncRoot = new();
|
||||||
private readonly List<GithubContext> contexts = new();
|
private readonly List<GithubContext> contexts = new();
|
||||||
|
private readonly IOptionsMonitor<GithubLookupFactoryOptions> options;
|
||||||
|
|
||||||
|
public GithubScanResults(IOptionsMonitor<GithubLookupFactoryOptions> options)
|
||||||
|
{
|
||||||
|
this.options = options;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 添加GithubContext
|
/// 添加GithubContext
|
||||||
@ -51,6 +58,11 @@ namespace FastGithub.Scanner
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public IPAddress? FindBestAddress(string domain)
|
public IPAddress? FindBestAddress(string domain)
|
||||||
{
|
{
|
||||||
|
if (this.options.CurrentValue.Domains.Contains(domain) == false)
|
||||||
|
{
|
||||||
|
return default;
|
||||||
|
}
|
||||||
|
|
||||||
lock (this.syncRoot)
|
lock (this.syncRoot)
|
||||||
{
|
{
|
||||||
return this.contexts
|
return this.contexts
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user