This commit is contained in:
xljiulang 2021-06-16 00:14:33 +08:00
parent c5c5443922
commit a14720473f
5 changed files with 16 additions and 16 deletions

View File

@ -19,9 +19,9 @@ namespace FastGithub
{ {
var assembly = typeof(DnsServiceCollectionExtensions).Assembly; var assembly = typeof(DnsServiceCollectionExtensions).Assembly;
return services return services
.AddGithubScanner(configuration)
.AddServiceAndOptions(assembly, configuration) .AddServiceAndOptions(assembly, configuration)
.AddHostedService<DnsHostedService>(); .AddHostedService<DnsHostedService>()
.AddGithubScanner(configuration);
} }
} }
} }

View File

@ -2,7 +2,7 @@
namespace FastGithub.Scanner namespace FastGithub.Scanner
{ {
class GithubContextHashSet : HashSet<GithubContext> sealed class GithubContextHashSet : HashSet<GithubContext>
{ {
public readonly object SyncRoot = new(); public readonly object SyncRoot = new();
} }

View File

@ -3,7 +3,7 @@
namespace FastGithub.Scanner namespace FastGithub.Scanner
{ {
[Options("Github")] [Options("Github")]
class GithubOptions sealed class GithubOptions
{ {
public TimeSpan ScanAllInterval { get; set; } = TimeSpan.FromHours(12d); public TimeSpan ScanAllInterval { get; set; } = TimeSpan.FromHours(12d);

View File

@ -73,17 +73,17 @@ namespace FastGithub.Scanner
{ {
if (domain.Contains("github", StringComparison.OrdinalIgnoreCase)) 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 default;
{
return this.results
.Where(item => item.Domain == domain && item.HttpElapsed != null)
.OrderBy(item => item.HttpElapsed)
.Select(item => item.Address)
.FirstOrDefault();
}
} }
} }
} }

View File

@ -6,7 +6,7 @@ using System.Text.Json.Serialization;
namespace FastGithub.Scanner namespace FastGithub.Scanner
{ {
class Meta sealed class Meta
{ {
[JsonPropertyName("hooks")] [JsonPropertyName("hooks")]
public string[] Hooks { get; set; } = Array.Empty<string>(); public string[] Hooks { get; set; } = Array.Empty<string>();