mirror of
https://github.com/bitwarden/server.git
synced 2025-06-30 15:42:48 -05:00
[PM-1675] Timeout or transient error when verifying domains (#2835)
* Increased timeout of the dns resolve method and changed the lifetime of the dnsResolverService to scoped * Reverted to using singleton as this was recommneded on the docs and also registered lookup client as a singleton * Registerered a singleton service of ILookupClient * replaced unused serviceProvider with a discard
This commit is contained in:
@ -60,7 +60,8 @@ public class VerifyOrganizationDomainCommand : IVerifyOrganizationDomainCommand
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_logger.LogError("Error verifying Organization domain. {errorMessage}", e.Message);
|
||||
_logger.LogError("Error verifying Organization domain: {domain}. {errorMessage}",
|
||||
domain.DomainName, e.Message);
|
||||
}
|
||||
|
||||
domain.SetLastCheckedDate();
|
||||
|
@ -5,10 +5,15 @@ namespace Bit.Core.Services;
|
||||
|
||||
public class DnsResolverService : IDnsResolverService
|
||||
{
|
||||
private readonly ILookupClient _client;
|
||||
|
||||
public DnsResolverService(ILookupClient client)
|
||||
{
|
||||
_client = client;
|
||||
}
|
||||
public async Task<bool> ResolveAsync(string domain, string txtRecord, CancellationToken cancellationToken = default)
|
||||
{
|
||||
var lookup = new LookupClient();
|
||||
var result = await lookup.QueryAsync(new DnsQuestion(domain, QueryType.TXT), cancellationToken);
|
||||
var result = await _client.QueryAsync(new DnsQuestion(domain, QueryType.TXT), cancellationToken);
|
||||
if (!result.HasError)
|
||||
{
|
||||
return result.Answers.TxtRecords()
|
||||
|
Reference in New Issue
Block a user