From a14720473f9c56d003ba8bc0ce5fb1d72b0fb294 Mon Sep 17 00:00:00 2001 From: xljiulang <366193849@qq.com> Date: Wed, 16 Jun 2021 00:14:33 +0800 Subject: [PATCH] fix bug --- .../DnsServiceCollectionExtensions.cs | 6 +++--- FastGithub.Scanner/GithubContextHashSet.cs | 2 +- FastGithub.Scanner/GithubOptions.cs | 2 +- FastGithub.Scanner/GithubScanService.cs | 18 +++++++++--------- FastGithub.Scanner/Meta.cs | 4 ++-- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/FastGithub.Dns/DnsServiceCollectionExtensions.cs b/FastGithub.Dns/DnsServiceCollectionExtensions.cs index ccbf60b..f8353a8 100644 --- a/FastGithub.Dns/DnsServiceCollectionExtensions.cs +++ b/FastGithub.Dns/DnsServiceCollectionExtensions.cs @@ -18,10 +18,10 @@ namespace FastGithub public static IServiceCollection AddGithubDns(this IServiceCollection services, IConfiguration configuration) { var assembly = typeof(DnsServiceCollectionExtensions).Assembly; - return services - .AddGithubScanner(configuration) + return services .AddServiceAndOptions(assembly, configuration) - .AddHostedService(); + .AddHostedService() + .AddGithubScanner(configuration); } } } diff --git a/FastGithub.Scanner/GithubContextHashSet.cs b/FastGithub.Scanner/GithubContextHashSet.cs index 828893a..b96f419 100644 --- a/FastGithub.Scanner/GithubContextHashSet.cs +++ b/FastGithub.Scanner/GithubContextHashSet.cs @@ -2,7 +2,7 @@ namespace FastGithub.Scanner { - class GithubContextHashSet : HashSet + sealed class GithubContextHashSet : HashSet { public readonly object SyncRoot = new(); } diff --git a/FastGithub.Scanner/GithubOptions.cs b/FastGithub.Scanner/GithubOptions.cs index c5f751c..faad619 100644 --- a/FastGithub.Scanner/GithubOptions.cs +++ b/FastGithub.Scanner/GithubOptions.cs @@ -3,7 +3,7 @@ namespace FastGithub.Scanner { [Options("Github")] - class GithubOptions + sealed class GithubOptions { public TimeSpan ScanAllInterval { get; set; } = TimeSpan.FromHours(12d); diff --git a/FastGithub.Scanner/GithubScanService.cs b/FastGithub.Scanner/GithubScanService.cs index 11755bf..795b81c 100644 --- a/FastGithub.Scanner/GithubScanService.cs +++ b/FastGithub.Scanner/GithubScanService.cs @@ -73,17 +73,17 @@ namespace FastGithub.Scanner { if (domain.Contains("github", StringComparison.OrdinalIgnoreCase)) { - return default; + lock (this.results.SyncRoot) + { + return this.results + .Where(item => item.Domain == domain && item.HttpElapsed != null) + .OrderBy(item => item.HttpElapsed) + .Select(item => item.Address) + .FirstOrDefault(); + } } - lock (this.results.SyncRoot) - { - return this.results - .Where(item => item.Domain == domain && item.HttpElapsed != null) - .OrderBy(item => item.HttpElapsed) - .Select(item => item.Address) - .FirstOrDefault(); - } + return default; } } } diff --git a/FastGithub.Scanner/Meta.cs b/FastGithub.Scanner/Meta.cs index cac86c0..94ceed1 100644 --- a/FastGithub.Scanner/Meta.cs +++ b/FastGithub.Scanner/Meta.cs @@ -6,7 +6,7 @@ using System.Text.Json.Serialization; namespace FastGithub.Scanner { - class Meta + sealed class Meta { [JsonPropertyName("hooks")] public string[] Hooks { get; set; } = Array.Empty(); @@ -59,6 +59,6 @@ namespace FastGithub.Scanner } } } - } + } } }