移除api.github.com的扫描
This commit is contained in:
parent
52f73f8790
commit
988d1d5399
@ -46,29 +46,30 @@ namespace FastGithub.Scanner
|
||||
|
||||
public async Task ScanAllAsync(CancellationToken cancellationToken = default)
|
||||
{
|
||||
this.logger.LogInformation("完整扫描开始");
|
||||
this.logger.LogInformation("完整扫描开始..");
|
||||
var meta = await this.metaService.GetMetaAsync(cancellationToken);
|
||||
if (meta != null)
|
||||
{
|
||||
var scanTasks = meta.ToGithubContexts().Select(ctx => ScanAsync(ctx));
|
||||
await Task.WhenAll(scanTasks);
|
||||
var results = await Task.WhenAll(scanTasks);
|
||||
var successCount = results.Count(item => item);
|
||||
this.logger.LogInformation($"完整扫描结束,成功{successCount}条共{results.Length}条");
|
||||
}
|
||||
|
||||
this.logger.LogInformation("完整扫描结束");
|
||||
|
||||
async Task ScanAsync(GithubContext context)
|
||||
async Task<bool> ScanAsync(GithubContext context)
|
||||
{
|
||||
await this.fullScanDelegate(context);
|
||||
if (context.Available == true)
|
||||
{
|
||||
this.contextCollection.Add(context);
|
||||
}
|
||||
return context.Available;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task ScanResultAsync()
|
||||
{
|
||||
this.logger.LogInformation("结果扫描开始");
|
||||
this.logger.LogInformation("结果扫描开始..");
|
||||
|
||||
var contexts = this.contextCollection.ToArray();
|
||||
foreach (var context in contexts)
|
||||
@ -76,7 +77,7 @@ namespace FastGithub.Scanner
|
||||
await this.resultScanDelegate(context);
|
||||
}
|
||||
|
||||
this.logger.LogInformation("结果扫描结束");
|
||||
this.logger.LogInformation($"结果扫描结束,共扫描{contexts.Length}条记录");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -48,17 +48,6 @@ namespace FastGithub.Scanner
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var range in IPRange.From(this.Api).OrderBy(item => item.Size))
|
||||
{
|
||||
if (range.AddressFamily == AddressFamily.InterNetwork)
|
||||
{
|
||||
foreach (var address in range)
|
||||
{
|
||||
yield return new GithubContext("api.github.com", address);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -12,8 +12,8 @@ namespace FastGithub.Scanner.Middlewares
|
||||
|
||||
public ConcurrentMiddleware()
|
||||
{
|
||||
var initialCount = Environment.ProcessorCount;
|
||||
this.semaphoreSlim = new SemaphoreSlim(initialCount, initialCount * 4);
|
||||
var currentCount = Environment.ProcessorCount * 4;
|
||||
this.semaphoreSlim = new SemaphoreSlim(currentCount, currentCount);
|
||||
}
|
||||
|
||||
public async Task InvokeAsync(GithubContext context, Func<Task> next)
|
||||
|
||||
@ -57,8 +57,18 @@ namespace FastGithub.Scanner.Middlewares
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
this.logger.LogTrace($"{context.Domain} {context.Address} {ex.Message}");
|
||||
}
|
||||
var message = GetInnerMessage(ex);
|
||||
this.logger.LogTrace($"{context.Domain} {context.Address} {message}");
|
||||
}
|
||||
}
|
||||
|
||||
private string GetInnerMessage(Exception ex)
|
||||
{
|
||||
while (ex.InnerException != null)
|
||||
{
|
||||
return GetInnerMessage(ex.InnerException);
|
||||
}
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user