),
)
+ # Fetch all dead domains
+ dead_names = await self.backend.db.fetch_as_set(
+ sqlmodel
+ .select(
+ domains.Domain.name,
+ )
+ .where(
+ # Select only domains from this list
+ domains.Domain.list == self,
+
+ # Only select domains that should be blocked
+ domains.Domain.block == True,
+
+ # Ignore domains that have been removed
+ domains.Domain.removed_at == None,
+
+ # Only select domains confirmed dead
+ domains.Domain.dead == True,
+ ),
+ )
+
# Fetch all potentially blocked domains
names = await self.backend.db.fetch_as_set(
sqlmodel
# Ignore domains that have been removed
domains.Domain.removed_at == None,
-
- # Only select domains that are not dead
- # or have not been checked, yet.
- sqlmodel.or_(
- domains.Domain.dead == None,
- domains.Domain.dead == False,
- ),
),
)
# Collect all names that are redundant
redundant_names = set()
- # List everything that isn't whitelisted
- if whitelisted:
- for name in names:
+ # Walk through all names
+ for name in names:
+ # De-list everything that is whitelisted
+ if whitelisted:
if util.is_name_in(name, whitelisted):
delisted_names.add(name)
+ # Delist everything that is dead
+ if name in dead_names:
+ delisted_names.add(name)
+
# Find any redundant domains
for name in names:
if util.is_parent_in(name, names):