From: Michael Tremer Date: Fri, 27 Feb 2026 12:59:38 +0000 (+0000) Subject: lists: Remove dead domains from the exports again X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5bcd5d3f24d6c6279f1c36fbc9041bb8eb6a674d;p=dbl.git lists: Remove dead domains from the exports again Signed-off-by: Michael Tremer --- diff --git a/src/dbl/lists.py b/src/dbl/lists.py index 787f770..80edaa4 100644 --- a/src/dbl/lists.py +++ b/src/dbl/lists.py @@ -798,6 +798,27 @@ class List(sqlmodel.SQLModel, database.BackendMixin, table=True): ), ) + # 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 @@ -813,13 +834,6 @@ class List(sqlmodel.SQLModel, database.BackendMixin, table=True): # 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, - ), ), ) @@ -829,12 +843,17 @@ class List(sqlmodel.SQLModel, database.BackendMixin, table=True): # 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):