Skip to content

Commit

Permalink
Renaming blacklisted domains => excluded domains
Browse files Browse the repository at this point in the history
  • Loading branch information
definitelynotagoblin committed Jan 9, 2025
1 parent 5d23536 commit d52dc02
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/CommonLib/LdapConnectionPool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ internal class LdapConnectionPool : IDisposable{
private const int BackoffDelayMultiplier = 2;
private const int MaxRetries = 3;
private static readonly ConcurrentDictionary<string, NetAPIStructs.DomainControllerInfo?> DCInfoCache = new();
private static readonly ConcurrentHashSet _blacklistedDomains = new();
private static readonly ConcurrentHashSet _excludedDomains = new();

public LdapConnectionPool(string identifier, string poolIdentifier, LdapConfig config, PortScanner scanner = null, NativeMethods nativeMethods = null, ILogger log = null) {
_connections = new ConcurrentBag<LdapConnectionWrapper>();
Expand Down Expand Up @@ -596,8 +596,8 @@ private bool CallDsGetDcName(string domainName, out NetAPIStructs.DomainControll
}

public async Task<(bool Success, LdapConnectionWrapper ConnectionWrapper, string Message)> GetConnectionAsync() {
if (_blacklistedDomains.Contains(_identifier)) {
return (false, null, $"Identifier {_identifier} blacklisted for connection attempt");
if (_excludedDomains.Contains(_identifier)) {
return (false, null, $"Identifier {_identifier} excluded for connection attempt");
}

if (!_connections.TryTake(out var connectionWrapper)) {
Expand All @@ -618,10 +618,10 @@ private bool CallDsGetDcName(string domainName, out NetAPIStructs.DomainControll
}

public async Task<(bool Success, LdapConnectionWrapper ConnectionWrapper, string Message)> GetGlobalCatalogConnectionAsync() {
if (_blacklistedDomains.Contains(_identifier)) {
return (false, null, $"Identifier {_identifier} blacklisted for connection attempt");
if (_excludedDomains.Contains(_identifier)) {
return (false, null, $"Identifier {_identifier} excluded for connection attempt");
}

if (!_globalCatalogConnection.TryTake(out var connectionWrapper)) {
var (success, connection, message) = await CreateNewConnection(true);
if (!success) {
Expand Down Expand Up @@ -700,7 +700,7 @@ public void Dispose() {
_log.LogDebug(
"Could not get domain object from GetDomain, unable to create ldap connection for domain {Domain}",
_identifier);
_blacklistedDomains.Add(_identifier);
_excludedDomains.Add(_identifier);
return (false, null, "Unable to get domain object for further strategies");
}
tempDomainName = domainObject.Name.ToUpper().Trim();
Expand Down Expand Up @@ -735,7 +735,7 @@ public void Dispose() {
}
} catch (Exception e) {
_log.LogInformation(e, "We will not be able to connect to domain {Domain} by any strategy, leaving it.", _identifier);
_blacklistedDomains.Add(_identifier);
_excludedDomains.Add(_identifier);
}

return (false, null, "All attempted connections failed");
Expand Down

0 comments on commit d52dc02

Please sign in to comment.