Skip to content

Commit

Permalink
add strict list.
Browse files Browse the repository at this point in the history
  • Loading branch information
smeinecke committed Jan 29, 2025
1 parent 2563cfb commit b636aa7
Showing 1 changed file with 30 additions and 11 deletions.
41 changes: 30 additions & 11 deletions generate-cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,32 @@ def create_cache():
domain_cache[hash_prefix] = {}

domain_cache[hash_prefix][domain_hash] = {
'domain': domain
'domain': domain,
'strict': False,
'src': []
}

# Add domains from grey/strict list
with open('disposable/greylist.txt') as f:
for domain in f:
domain = domain.strip()
if domain.startswith('#') or domain == '':
continue
domain_hash = hashlib.sha1(domain.encode('utf8')).hexdigest()

hash_prefix = domain_hash[:2]
if hash_prefix not in domain_cache:
domain_cache[hash_prefix] = {}

domain_cache[hash_prefix][domain_hash] = {
'domain': domain,
'strict': True,
'src': [
{
'url': 'https://raw.githubusercontent.com/disposable/disposable/master/greylist.txt',
'ext': False
}
]
}

with open('domains_source_map.txt', 'r') as f:
Expand All @@ -60,16 +85,10 @@ def create_cache():
if domain_hash not in domain_cache.get(hash_prefix, {}):
continue

if 'src' in domain_cache[hash_prefix][domain_hash]:
domain_cache[hash_prefix][domain_hash]['src'].append({
'url': source_url,
'ext': source_url in external_sources
})
else:
domain_cache[hash_prefix][domain_hash]['src'] = [{
'url': source_url,
'ext': source_url in external_sources
}]
domain_cache[hash_prefix][domain_hash]['src'].append({
'url': source_url,
'ext': source_url in external_sources
})

for hash_prefix, domain_data in domain_cache.items():
with open('cache/' + hash_prefix + '.json', 'w') as f:
Expand Down

0 comments on commit b636aa7

Please sign in to comment.