优先从github获取meta
This commit is contained in:
parent
e084a0992c
commit
2822745937
@ -20,6 +20,7 @@ namespace FastGithub.Scanner.DomainAddressProviders
|
||||
{
|
||||
private readonly IOptionsMonitor<GithubOptions> options;
|
||||
private readonly ILogger<GithubMetaProvider> logger;
|
||||
private const string META_URI = "https://api.github.com/meta";
|
||||
|
||||
/// <summary>
|
||||
/// Github公开的域名与ip关系提供者
|
||||
@ -49,7 +50,7 @@ namespace FastGithub.Scanner.DomainAddressProviders
|
||||
try
|
||||
{
|
||||
using var httpClient = new HttpClient();
|
||||
var meta = await httpClient.GetFromJsonAsync<Meta>(setting.MetaUri);
|
||||
var meta = await this.GetMetaAsync(httpClient, setting.MetaUri);
|
||||
if (meta != null)
|
||||
{
|
||||
return meta.ToDomainAddresses();
|
||||
@ -63,6 +64,25 @@ namespace FastGithub.Scanner.DomainAddressProviders
|
||||
return Enumerable.Empty<DomainAddress>();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 尝试获取meta
|
||||
/// </summary>
|
||||
/// <param name="httpClient"></param>
|
||||
/// <param name="metaUri"></param>
|
||||
/// <returns></returns>
|
||||
private async Task<Meta?> GetMetaAsync(HttpClient httpClient, Uri metaUri)
|
||||
{
|
||||
try
|
||||
{
|
||||
return await httpClient.GetFromJsonAsync<Meta>(META_URI);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return await httpClient.GetFromJsonAsync<Meta>(metaUri);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// github的meta结构
|
||||
/// </summary>
|
||||
|
||||
@ -13,7 +13,6 @@
|
||||
"DominAddressProviders": {
|
||||
"GithubMetaProvider": {
|
||||
"Enable": true,
|
||||
// "MetaUri": "https://api.github.com/meta", // meta×ÊÔ´uri
|
||||
"MetaUri": "https://gitee.com/jiulang/fast-github/raw/master/FastGithub/meta.json"
|
||||
},
|
||||
"IPAddressComProvider": {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user