public void SetUp() { Environment.SetEnvironmentVariable("DnsRecordLookupTimeoutSeconds", "10"); ILookupClient CreateLookupClient(IServiceProvider provider) { return(RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? new LookupClient(NameServer.GooglePublicDns, NameServer.GooglePublicDnsIPv6) { Timeout = provider.GetRequiredService <IEnricherConfig>().DnsRecordLookupTimeout } : new LookupClient(provider.GetService <IDnsNameServerProvider>().GetNameServers() .Select(_ => new IPEndPoint(_, 53)).ToArray()) { Timeout = provider.GetRequiredService <IEnricherConfig>().DnsRecordLookupTimeout, UseTcpOnly = true, }); } _reverseDnsProvider = new ServiceCollection() .AddTransient <IReverseDnsProvider, ReverseDnsProvider>() .AddTransient <IReverseDnsLookup, ReverseDnsLookup>() .AddTransient <IOrganisationalDomainProvider, OrganisationalDomainProvider>() .AddTransient <IPublicSuffixDao, PublicSuffixDao>() .AddTransient <IConnectionInfoAsync>(_ => new StringConnectionInfoAsync(ConnectionString)) .AddTransient <ITldRuleProvider, DaoTldRuleProvider>() .AddTransient <IDnsResolver, DnsResolver>() .AddTransient <IEnricherConfig, EnricherConfig>() .AddTransient(CreateLookupClient) .AddEnvironment() .AddSerilogLogging() .BuildServiceProvider() .GetRequiredService <IReverseDnsProvider>(); }
public void Setup() { _asInfoProvider = A.Fake <IAsInfoProvider>(); _blocklistProvider = A.Fake <IBlocklistProvider>(); _reverseDnsProvider = A.Fake <IReverseDnsProvider>(); _log = A.Fake <ILogger <IpAddressLookup> >(); _clock = A.Fake <IClock>(); _ipAddressLookup = new IpAddressLookup(_asInfoProvider, _blocklistProvider, _reverseDnsProvider, _clock, _log); A.CallTo(() => _blocklistProvider.GetBlocklistAppearances(A <List <string> > ._)).ReturnsLazily((List <string> arguments) => { return(Task.FromResult(arguments.Select(x => new BlocklistResult(x, new List <BlocklistAppearance> { new BlocklistAppearance("flag", "source", Guid.NewGuid().ToString()) }) ).ToList())); }); A.CallTo(() => _reverseDnsProvider.GetReverseDnsResult(A <List <string> > ._)).ReturnsLazily((List <string> arguments) => { return(Task.FromResult(arguments.Select(x => new ReverseDnsResult(x, new List <ReverseDnsResponse> { new ReverseDnsResponse(Guid.NewGuid().ToString(), new List <string>()) })).ToList())); }); A.CallTo(() => _asInfoProvider.GetAsInfo(A <List <string> > ._)).ReturnsLazily((List <string> arguments) => { return(Task.FromResult(arguments.Select(x => new AsInfo { IpAddress = x, Description = Guid.NewGuid().ToString() }).ToList())); }); A.CallTo(() => _clock.GetDateTimeUtc()).Returns(new DateTime(1999, 01, 01)); }
public IpAddressLookup(IAsInfoProvider asInfoProvider, IBlocklistProvider blocklistProvider, IReverseDnsProvider reverseDnsProvider, IClock clock, ILogger <IpAddressLookup> log) { _asInfoProvider = asInfoProvider; _blocklistProvider = blocklistProvider; _reverseDnsProvider = reverseDnsProvider; _clock = clock; _log = log; }
public ReverseDnsBackfillLambda(IIpAddressDetailsDao ipAddressAddressDetailsDao, IReverseDnsProvider reverseDnsProvider, ILogger <ReverseDnsBackfillLambda> log) { _log = log; _ipAddressAddressDetailsDao = ipAddressAddressDetailsDao; _reverseDnsProvider = reverseDnsProvider; }